python - 在 Python 中编辑类文件对象上的 MP3 元数据?

标签 python mp3 metadata id3

我们正在用 Python 动态生成 MP3 文件,需要使用类似文件的对象在内存中编辑 ID3 header 。

PyPI 上的所有 ID3 库似乎 要求您将文件系统路径作为字符串传递。我觉得这很令人沮丧!

将我们生成的 MP3 写入磁盘(或 ramdisk)只是为了添加 ID3 标签是 Not Acceptable ,原因有很多,尤其是性能。

鉴于 ID3 库的丰富性,是否有一个 ID3 库可以简单地处理类文件对象?

最佳答案

对于那些在遥远的 future 找到这个答案的人,mutagen , 对我来说工作得很好,它的一个 MP3 对象的构造函数采用一个文件路径一个类似文件的对象(文档称它为“filething”) .

来自 https://mutagen.readthedocs.io/en/latest/user/filelike.html :

The first argument passed to a FileType or Metadata can either be a file name or a file-like object, such as StringIO (BytesIO in Python 3) and mutagen will figure out what to do.

MP3("myfile.mp3")
MP3(myfileobj)

关于python - 在 Python 中编辑类文件对象上的 MP3 元数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1534374/

相关文章:

actionscript-3 - 如何从 ActionScript 3 中的缓冲区 (ByteArray/Stream) 播放 MP3 声音?

python - 炼金术;将主键设置为预先存在的数据库表(不使用 sqlite)

python:如何配对分开的字典?

python - 在 python 中解析 pcap 文件

ffmpeg - 无法使用 ffmpeg 将 .mp3 转换为 .m4a

java - 将自定义元数据添加到二进制文件

python - 在 Python 中操作 WebP 图像

Java 媒体框架 : extract audio info from mp3 file

java - 如何高效读取元数据文件?

java - 如何清除 Eclipse 内部 Web 浏览器历史记录或浏览器首选项?