【问题标题】:Lost artwork while converting .m4a to .mp3 (Python)将 .m4a 转换为 .mp3 (Python) 时丢失图稿
【发布时间】:2018-07-10 09:58:49
【问题描述】:

我正在尝试将带有艺术品(封面)的 m4a 音频文件转换为 mp3。我正在使用 ffmpeg 转换音频。

一旦复制,艺术品就会丢失。我不太确定,如何保留封面。我找到了一些关于 mutagen 库的参考资料,但又不确定如何使用它来复制艺术品。

任何帮助都会很棒。

ffmpeg -i source/file -acodec libmp3lame -ab 128k destination.mp3

更新:

我正在阅读艺术品和 m4a 以便能够将其附加回来。 我可以通过使用获得艺术品

artwork = audio.tags['covr']

现在我的问题是如何将艺术品保存为新文件中的图像?

我尝试了以下方法:

with open(path/to/write, 'wb') as img: img.write(artwork)

这给了我一个错误

'list' does not support the buffer interface line

任何建议,我如何保存提取的艺术作品 covr 数据?

【问题讨论】:

    标签: python mp3 m4a audio-converter


    【解决方案1】:

    我现在无法测试它,但如果专辑封面是元数据的一部分,ma​​p_metadata 应该会有所帮助。

    ffmpeg -i source/file -acodec libmp3lame -ab 128k -map_metadata 0:s:0 destination.mp3
    

    【讨论】:

    • 感谢您的回答,但不幸的是没有为我工作。文件是使用浏览器上传的临时文件。不确定,如果这有什么不同。
    【解决方案2】:

    如果有人遇到同样的问题;

    我最终从原始文件中读取了艺术作品并将其附加回 mp3

    if audioFileNameWithM4AExtension.startswith("covr"): #checks if it has cover cover = audioFileNameWithM4AExtension.tags['covr'][0] #gets the cover

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-28
      • 2019-01-07
      • 1970-01-01
      • 1970-01-01
      • 2012-05-04
      相关资源
      最近更新 更多