SoC proposal: multimedia library
Hello everyone, I would like to participate as a student in google Summer of Code and I'm interested in feedback on a multimedia library for Python. The library I propose should have the following features: * the capability to extract and decompress video and audio from a few common multimedia file format; * and, vice versa, it can create a compressed video file from a series of still images and from uncompressed audio; * it should have an interface as simple and pythonic as possible; * it must be cross-platform, easy to extend and not be limited to a single file container format or to some specific audio or video compression format; * at least a subset of the supported formats should be available without any external dependency. Why? I think this can be an useful addition to the standard library: the goal isn't to reimplement a full fledged media player like mplayer or VLC, but to offer, e.g., a very simple way to add multimedia animations to a Tkinter application. Or, for an application that generates animations, a simple way to save them in a common file format that can be played by existing media players. How? I know that this may sound like a project way too big for SoC, but I think it may be feasible: I plan to split it in two parts. A low level part responsible for splitting encoded audio and video data from multimedia files (demuxing) and putting it together in new multimedia files (muxing). I plan to initially only support AVI and MOV/Quicktime files because they are relatively simple and well documented (and I have already written Python programs for manipulating these two formats, so I know them pretty well). New container formats can be added later and, if the library interface meets the requirements, existing application will be able to use them without any modification. The second part of the library is a collection of codecs for compressing and decompressing audio and video streams. I don't plan to invest too much time here: the idea is to write only a few ctypes wrappers around existing libraries for common formats (e.g. MPEG4/XVID and Theora for video and MP3 and Vorbis for audio) and/or use existing third-part Python bindings. Again, new codecs can be added later. Similar libraries. There are already a number of multimedia libraries both inside and outside of the standard library, but AFAIK they all have limitations: * a lot of them are specific for a single container format or codec (e.g. aifc, wave, oggpy, python-vorbis...); * they aren't cross-platform (e.g. videoreader). Is there any interest in a library of this kind (inside or outside of the stdlib)? Suggestions? Criticism? -- Lino Mastrodomenico E-mail: l.mastrodomenico@gmail.com
"Lino Mastrodomenico" <l.mastrodomenico@gmail.com> wrote in message news:cc93256f0703242052m2072e9f2ve90ea6632076bd1@mail.gmail.com... | Is there any interest in a library of this kind (inside or outside of | the stdlib)? | Suggestions? Criticism? There is a Python wrapping of the cross-platform Simple Directmedia Library (C) that is a major part of PyGame. Are you familiar with both and how does your proposal improve on the current situation. tjr
"Lino Mastrodomenico" <l.mastrodomenico@gmail.com> wrote:
Is there any interest in a library of this kind (inside or outside of the stdlib)?
For decoding, not many packages can currently match VLC. It has wrappers for most major GUI toolkits, and seems to be easily accessable via ctypes. There are also bindings for various media players in wxPython, though they are strictly play only - no screenshots, etc. For encoding, MediaCoder exists, but seems to be Windows only. I would personally suggest limiting support and going for ffmpeg (via ctypes would be quickest, though a SWIG wrapping could make it more convenient). Is it desireable? I don't know. Make it available and we will likely see a slimmed down iMovie clone in a couple months. Is the wrapping of VLC and ffmpeg sufficient for a SoC project? I don't know - I've never wrapped a 3rd party library before. - Josiah
2007/3/25, Terry Reedy <tjreedy@udel.edu>:
There is a Python wrapping of the cross-platform Simple Directmedia Library (C) that is a major part of PyGame. Are you familiar with both and how does your proposal improve on the current situation.
Yes I know both Pygame and SMPEG (the SDL MPEG library used by Pygame). The differences with my proposal are: * SMPEG is not a general purpose library: it only supports MPEG-1 video in a MPEG system stream container (and the corresponding audio); * it only supports decoding, not encoding; * the Pygame wrapper is strictly tied to Pygame itself and direct playback; e.g.: AFAIK there is no way to access the uncompressed audio track of a MPEG file, you can only "play" a movie; * it's CPython specific: my plan is to use only Python and ctypes, to make it easily portable to PyPy. The nearest existing library to what I propose that I was able to find is PyMedia (http://www.pymedia.org/ ). But it still isn't what I want: their interface is too low level and not exactly pythonic and their implementation is written in C and C++ (a very old fork of the ffmpeg library). 2007/3/25, Josiah Carlson <jcarlson@uci.edu>:
For decoding, not many packages can currently match VLC. It has wrappers for most major GUI toolkits, and seems to be easily accessable via ctypes. There are also bindings for various media players in wxPython, though they are strictly play only - no screenshots, etc.
Yes, but I don't want to implement yet another media player, my proposal is for a library that supports both encoding and decoding and doesn't force the use of a specific output layer. E.g. you should be able to get the uncompressed data of a video frame and pass it to Tkinter.Image, or PIL (the Python Imaging Library), or do fancy things to it with numpy...
For encoding, MediaCoder exists, but seems to be Windows only.
Well, technically it works under Linux too, with Wine. ;-) But, yes, I want something a bit more cross-platform than that.
I would personally suggest limiting support and going for ffmpeg (via ctypes would be quickest, though a SWIG wrapping could make it more convenient).
Yes, I thought about simply writing a wrapper around ffmpeg, but I think it would be preferable to write at least the (de)muxing part of the library in Python since this should guarantee that at least a subset of the functionality (e.g. an AVI file with MJPEG video and u-law sound) is always available without any dependecy outside of the standard library and of libraries that are pretty much always available on Linux/MacOSX/Windows. Of course the CPU intensive work of encoding and decoding audio and video will be done by existing C libraries. As I said before I have a slight preference for using ctypes instead of the CPython APIs because this means that the library will (probably) be usable unmodified by PyPy, but I can change my mind if the community prefers something else. -- Lino Mastrodomenico E-mail: l.mastrodomenico@gmail.com
I would personally suggest limiting support and going for ffmpeg (via ctypes would be quickest, though a SWIG wrapping could make it more convenient).
Python wrapper for FFmpeg using Pyrex is available on google code ( http://code.google.com/p/pyffmpeg/)
Lino Mastrodomenico <l.mastrodomenico <at> gmail.com> writes:
I would like to participate as a student in google Summer of Code and I'm interested in feedback on a multimedia library for Python.
The library I propose should have the following features: * the capability to extract and decompress video and audio from a few common multimedia file format; * and, vice versa, it can create a compressed video file from a series of still images and from uncompressed audio; * it should have an interface as simple and pythonic as possible;
My main question is what is the image and sound container passed back to Python? This single thing along would be worth a SoC if it could be implemented across all libraries. Will your image objects be transferrable to PIL, Pygame, PyOpengl, Numpy, Pythonmagick, Pycairo, wxPython, etc? It would be best if this could avoid the "fromstring/tostring" mojo that always requires and extra copy of the data for each transfer. If the core numpy arrays could ever get added to the Python standard library, this problem would be mostly solved. I believe there was a SoC for Python last year for this exact array problem. Your proposal sounds dangerously close to implementing some file demuxing by yourself. Do not dare touch any of the file bits in your own library. This proposal should only be for getting data from existing decompression libraries into some general Python container.
Pete Shinners wrote:
Will your image objects be transferrable to PIL, Pygame, PyOpengl, Numpy, Pythonmagick, Pycairo, wxPython, etc? It would be best if this could avoid the "fromstring/tostring" mojo that always requires and extra copy of the data for each transfer.
This would be an excellent test case for the enhanced buffer protocol that's currently being worked on. I wouldn't worry about this too much initially, though. Just get some kind of library-independent image/sound object working, and a buffer interface can be added later once the details are worked out. -- Greg
Lino Mastrodomenico wrote:
Hello everyone,
I would like to participate as a student in google Summer of Code and I'm interested in feedback on a multimedia library for Python.
The library I propose should have the following features: * the capability to extract and decompress video and audio from a few common multimedia file format; * and, vice versa, it can create a compressed video file from a series of still images and from uncompressed audio; * it should have an interface as simple and pythonic as possible; * it must be cross-platform, easy to extend and not be limited to a single file container format or to some specific audio or video compression format; * at least a subset of the supported formats should be available without any external dependency.
Except I guess for the last point, don't the Python bindings for GStreamer already provide this? -Andrew.
participants (7)
-
Andrew Bennetts -
Greg Ewing -
Josiah Carlson -
Lino Mastrodomenico -
Navtej Singh -
Pete Shinners -
Terry Reedy