Python Bindings for Dirac, (sorta announcement)

Michael Sparks ms at cerenity.org
Tue Sep 13 20:14:07 EDT 2005


Hi,


We're in the process of creating python bindings for Dirac. We currently
have /decode/ of dirac functioning nicely, so I've packaged up the bindings
separately from the rest of the Kamaelia project for those that are
interested and would want a play. (Encoding will naturally follow next)

To build the bindings, you need:
   * Pyrex (0.9.3) installed:
      http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/
   * Dirac (0.5.3) installed, from source:
      http://dirac.sf.net/
      (Also, includes should be living in /usr/local/include/dirac)

A sample video player, entirely written in python/python extensions 
(eg pygame) for playing back dirac is in ...
   /Code/Python/Kamaelia/Examples/example10
... in Kamaelia's tree in the CVS head. (I'd point at view CVS, but it
hasn't caught up yet)

What is Dirac?
==============
Not my project, but colleagues', so description from project page:

"""Dirac is a general-purpose video codec aimed at resolutions from QCIF
(180x144) to HDTV (1920x1080) progressive or interlaced. It uses wavelets,
motion compensation and arithmetic coding and aims to be competitive with
other state of the art codecs."""

How Do I Get Video To Decode?
=============================

The easiest way to get some dirac video is to use ffmpeg to convert a file
to yuv and then the dirac encoder. eg:

# ffmpeg -i file_from_digital_camera.avi rawvideo.yuv
...
  Stream #0.0: Video: mjpeg, 320x240, 16.10 fps
...

Useful line from ffmpeg's output pulled out. (in this case the avi file
above came from a cheap digital camera's video mode)

# dirac_encoder -qf 5 -width 320 -height 240 -fr 16 rawvideo myvideo

The resulting myvideo.drc that the above line would create is what the
decoder can handle. The -width & -height flags should be obvious, and
came from the output from ffmpeg. The -fr flag is the frame rate (fps),
again from ffmpeg. The -qf is a "quality factor". 

Bigger is better quality, but bigger also requires beefier systems for
decoding dirac.

The above settings result in something decodable using dirac using a 1.6Ghz
machine. If you have a beefier system you can use a higher quality factor,
if you have a less beefy system, a lower quality factor is preferable.

Caveats
=======

Finally, I'm mentioning this for people who'd want to play/tinker - it's not
really suitable for (say) someone wanting to convert all their home
videos to yet, largely because dirac's bitstream isn't yet finalised. (If
you don't understand this, this might be a hint to stay away, if you do
understand this you'll hopefully understand why I'm giving this warning)
Also, the API and usage are also subject to change.

For reference an example file encoded with the above settings:
   * 2,694,380 bytes before
   * 293,579 bytes after

To my untrained eye there's not a /huge/ amount of difference in quality,
though there *is* a drop in quality (since that is a rather drastic drop). 
That's ~ 10 seconds of video.

Right now the easiest way to play with this is to do a cvs checkout of
Kamaelia's CVS head, install and play with example10 and tinker with
the components used, but the bindings aren't tied to Kamaelia and could
be used with other things. (We just happened to write them because we
need them)

If anyone's interesting in integrating these with other python libraries
we'd be interested in chatting :-)

The reason I say this is "sorta" an announcement is because I'm really
curious as to whether people think the API is sensible or not, but I'll
skip spammin the group with those details and ask anyone prepared to
take a look download the bindings from: http://tinyurl.com/arbk2 . 

Best Regards,


Michael.
--
Michael.Sparks at rd.bbc.co.uk, http://kamaelia.sourceforge.net/
British Broadcasting Corporation, Research and Development
Kingswood Warren, Surrey KT20 6NP

This message (and any attachments) may contain personal views
which are not the views of the BBC unless specifically stated.



More information about the Python-list mailing list