Salim Fadhley
2005-Jun-19 15:13 UTC
[ogg-dev] Extracting Ogg metadata from File-like python objects
Dear Ogg-dev list; I'm having some difficulty with the python libraries for extracting comment/header info out of Ogg files... Would somebody more experienced than me offer some advice? I'm working on expanding a Python/Zope product for dealing with MP3 files so that it can also handle a spectrum of other file-formats including Ogg-Vorbis. Initially we will be storing all of our media files on a local filesystem which is just fine for the python ogg libraries, but soon we will want to start using the ZODB to store all our data, including media. The upshot of this is that all our data will be stored as file-like objects, which implement all of the classic file object's behavior but have no traditional existence in the file system. In order to read or write Ogg comment/header information from these files, the only way I have found is to dump the files to a local file system (on the server), use the python ogg tools on that file and then re-pickle any changes back into the database. We would rather not do that for a number of reasons; firstly it's a hassle and it seems inelegant. Secondly, the ZODB has some great features I can use to prevent me from having to unpickle the whole of a file. If the header info I am interested in is at the start or end of the file, then the bits in the middle need not be woken up. The ZODB can do a whole load of cool things that I shall not go into at this point. The problem with the python ogg libraries is that they seem to expect the file in question to be a regular file system file. The libs dont expect that other kinds of file-like entity may exist, or be simulated (a very common pythonic idiom). Does anybody know of an alternative lib or tool that will allow me to query ogg-files? Ideally this tool would take the form of something that I can mix-in with any kind of file-like object. Best regards and invitations to RTFM graciously accepted. Sal
Ralph Giles
2005-Jun-20 02:25 UTC
[ogg-dev] Extracting Ogg metadata from File-like python objects
On Sun, Jun 19, 2005 at 11:13:15PM +0100, Salim Fadhley wrote:> The problem with the python ogg libraries is that they seem to expect > the file in question to be a regular file system file. The libs dont > expect that other kinds of file-like entity may exist, or be simulated > (a very common pythonic idiom).Ouch. I'm not at all familiar with the python tools, but that certainly sounds like a bug. Any interest in fixing it? Parsing the comment headers for Ogg Vorbis and Ogg Theora files in pure python is simple enough, so that might be an easier approach to what you want to do. Maybe a simple extension on top of http://svn.xiph.org/trunk/py-ogg2/ -r
Salim Fadhley
2005-Jun-20 02:37 UTC
[ogg-dev] Extracting Ogg metadata from File-like python objects
I wouldnt go so far to call it a bug; the pyOgg software does what it says it does very well, my beef is with the unPythonic design of the component; In most languages a file is a file is a file, however in Python a very commonly used idiom is to make classes emulate certain archetypal classes, For example a class representing betting-odds might emulate a floating-point number, despute having very different arethmetic properties. Rather than re-implement the low-level details of file access; it would be nifty if the pyOgg libs were supplied as mixins, so I could just combine them with my file-like classes in order to make a file-like Ogg-aware class, for example: class OggVorbisFile(virtualFile, oggCommentAwareMixin): # Blah By the way, the projects we require this for are 'Plodcasting' (a Podcasting tool for Zope/Plone), and it's component ATAudio, a plone product for representing Audio files as content with mutable metadata. Sal