Python 3.x:从FLAC文件中提取前盖并保存



我试图在过去几个月中学习python的基础知识,我在Stackoverflow上找到了许多答案。但是现在是时候问我的第一个问题了,因为我找不到任何有帮助的东西了。

我有一个FLAC音频文件,想提取前盖并使用Python 3.x将其保存到硬盘上。我阅读了诱变剂,audiotools,eied3的文档...但是我仍然无法弄清楚信息的存储方式以及如何存储。

任何人都可以提供代码段吗?

非常感谢。

from mutagen.flac import FLAC, Picture
song = "Anathema - Empty.flac"
var = FLAC(song)
pics = var.pictures
print (pics)
for p in pics:
    if p.type == 3:
        print("nfound front cover") 
        # how can I save the picture???

这是我的解决方案。非常感谢您的帮助!

from mutagen.flac import FLAC, Picture
song = "Anathema - Empty.flac"
var = FLAC(song)
pics = var.pictures
print (pics)
for p in pics:
    if p.type == 3: #front cover
        print("nfound front cover") 
        with open("cover.jpg", "wb") as f:
            f.write(p.data)

最新更新