问题描述:

We're generating MP3 files on the fly in Python, and need to edit the ID3 headers in-memory using a file-like object.

All the ID3 libraries on PyPI appear to require you to pass a filesystem path as a string. I find this rather frustrating!

Writing our generated MP3 out to disk (or ramdisk) just to add ID3 tags is unacceptable for a number of reasons, especially performance.

Given the plentitude of ID3 libraries, is there an ID3 library that simply works with file-like objects?

网友答案:

Does StringIO help? http://docs.python.org/library/stringio.html

网友答案:

Well, the answer seems to be that no such animal exists. The advantages of programming to an interface are apparently lost on the python MP3 frame hackers. We solved the problem by modifying an existing library.

网友答案:

AFAIR tags are appended to the end of file. You might want to study the format and make a simple library yourself, that should not be very difficult.

Also, you could consider storing them temporary on a filesystem like tmpfs (ramdisk).

相关阅读:
Top