April 2024 - This site, and Kamaelia are being updated. There is significant work needed, and PRs are welcome.

Kamaelia.Codec.Dirac

Dirac video decoder

This component decodes a stream of video, coded using the Dirac codec, into frames of YUV video data.

This component is a thin wrapper around the Dirac Python bindings.

Example Usage

A simple video player:

Pipeline(ReadFileAdapter("diracvideofile.drc", ...other args...),
         DiracDecoder(),
         RateLimit(framerate),
         VideoOverlay()
        ).activate()

More detail

Reads a raw dirac data stream, as strings, from the "inbox" inbox.

Sends out frames of decoded video to the "outbox" outbox.

The frames may not be emitted at a constant rate. You may therefore need to buffer and rate limit them if displaying them.

The decoder will terminate if it receives a shutdownMicroprocess message on its "control" inbox. The message is passed on out of the "signal" outbox.

It will ignore producerFinished messages.

The decoder is able to work out from the data stream when it has reached the end of the stream. It then sends a producerFinished message out of the "signal" outbox and terminates.

For more information see the Dirac Python bindings documentation.

Dirac video encoder

This component encodes frames of YUV video data with the Dirac codec.

This component is a thin wrapper around the Dirac Python bindings.

Example Usage

Raw video file encoder:

imagesize = (352, 288)      # "CIF" size video

Pipeline(ReadFileAdapter("raw352x288video.yuv", ...other args...),
         RawYUVFramer(imagesize),
         DiracEncoder(preset="CIF"),
         WriteFileAdapter("diracvideo.drc")
        ).activate()

RawYUVFramer is needed to frame raw YUV data into individual video frames.

More detail

Reads video frames from the "inbox" inbox.

Sends out encoded video data (as strings) in chunks to the "outbox" outbox.

The encoder can be configured with simple presets and/or more detailed encoder and sequence parameters. Encoder and sequence parameters override those set with a preset.

For more information see the Dirac Python bindings documentation.

The encoder will terminate if it receives a shutdownMicroprocess or producerFinished message on its "control" inbox. The message is passed on out of the "signal" outbox. If the message is producerFinished, then it will also send any data still waiting to be sent out of the "outbox" outbox, otherwise any pending data is lost.

The component does not yet support output of instrumentation or locally decoded frames (the "verbose" option).

UNCOMPRESSED FRAME FORMAT

Uncompresed video frames are output by the decoder, as dictionaries. Each contains the following entries:

{
  "yuv" : (y_data, u_data, v_data)  # a tuple of strings
  "size" : (width, height)          # in pixels
  "frame_rate" : fps                # frames per second
  "interlaced" : 0 or not 0         # non-zero if the frame is two interlaced fields
  "topfieldfirst" : 0 or not 0      # non-zero the first field comes first in the data
  "pixformat" :  "YUV420_planar"    # format of raw video data
  "chroma_size" : (width, height)   # in pixels, for the u and v data
}

The encoder expects data in the same format, but only requires "yuv", "size", and "pixformat".


Kamaelia.Codec.Dirac.DiracDecoder

class DiracDecoder(Axon.Component.component)

DiracDecoder() -> new Dirac decoder component

Creates a component that decodes Dirac video.

Inboxes

  • control : for shutdown signalling
  • inbox : Strings containing an encoded dirac video stream

Outboxes

  • outbox : YUV decoded video frames
  • signal : for shutdown/completion signalling

Methods defined here

Warning!

You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers.

__init__(self)

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

main(self)

Main loop

Kamaelia.Codec.Dirac.DiracEncoder

class DiracEncoder(Axon.Component.component)

DiracEncoder([preset][,verbose][,encParams][,seqParams][,allParams]) -> new Dirac encoder component

Creates a component to encode video using the Dirac codec. Configuration based on optional preset, optionally overriden by individual encoder and sequence parameters. All three 'params' arguments are munged together, so do what you like :)

Keyword arguments:

  • preset -- "CIF" or "SD576" or "HD720" or "HD1080" (presets for common video formats)
  • verbose -- NOT YET IMPLEMENTED (IGNORED)
  • encParams -- dict of encoder setup parameters only
  • seqParams -- dict of video sequence parameters only
  • allParams -- dict of encoder setup parameters, sequence parameters, and source parameters, all munged together

Inboxes

Outboxes

Methods defined here

Warning!

You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers.

__init__(self[, preset][, verbose][, encParams][, seqParams][, allParams])

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

main(self)

Main loop

Feedback

Got a problem with the documentation? Something unclear that could be clearer? Want to help improve it? Constructive criticism is very welcome - especially if you can suggest a better rewording!

Please leave you feedback here in reply to the documentation thread in the Kamaelia blog.

-- Automatic documentation generator, 05 Jun 2009 at 03:01:38 UTC/GMT