Python Bindings for Dirac, (sorta announcement)

M

Michael Sparks

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.
--
(e-mail address removed), 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.
 
M

Matt Hammond

We now also have python bindings for Dirac /encoding/ too.

If you feel like playing with this (please do!) the same caveats Michael
mentioned apply, and the dependancies are the same (pyrex and dirac).

A sample video encoding->decoding->viewing pipeline is in:
/Code/Python/Kamaelia/Examples/example10
.... in Kamaelia's tree in the CVS repository.

Again, the input format is 'raw' yuv video files. Follow Michael's
instructions
to build your own from AVI files using ffmpeg. Alternatively, download the
sample
video files from the dirac website, and prepare them by following the
instructions
you'll find within comments in the example python program.


regards


Matt Hammond
http://kamaelia.sf.net/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top