Cookbook Example

How can I...?

Example 10: Simple dirac encoder/decoder. Shows how to read raw video frames from a file, encode them using dirac, decode them again, and then playback via a video overlay. Components used: ReadFileAdaptor, RawYUVFramer, DiracEncoder, DiracDecoder, VideoOverlay .

Download and build dirac first!

Get the source raw video file (in rgb format) from here, and gunzip it:

http://sourceforge.net/project/showfiles.php?group_id=102564&package_id=119507

To convert RGB to YUV:

    RGBtoYUV420 snowboard-jum-352x288x75.rgb snowboard-jum-352x288x75.yuv 352 288 75

Alternatively, source your own AVI file and convert with:

    ffmpeg -i file_from_digital_camera.avi rawvideo.yuv

and alter the config below as required.

    #!/usr/bin/python

    from Kamaelia.Util.PipelineComponent import pipeline
    from Kamaelia.ReadFileAdaptor import ReadFileAdaptor
    from Kamaelia.Codec.RawYUVFramer import RawYUVFramer
    from Kamaelia.Codec.Dirac import DiracEncoder, DiracDecoder
    from Kamaelia.UI.Pygame.VideoOverlay import VideoOverlay

    FILENAME = "/data/dirac-video/snowboard-jum-352x288x75.yuv"
    SIZE = (352,288)
    DIRACPRESET = "CIF" # dirac resolution and encoder settings preset

    # encoder param sets it to iframe only (no motion based coding, faster)
    # (overrides preset)
    ENCPARAMS = {"num_L1":0}

    pipeline( ReadFileAdaptor(FILENAME, readmode="bitrate", bitrate= 1000000),
    RawYUVFramer( size=SIZE ),
    DiracEncoder(preset=DIRACPRESET, encParams=ENCPARAMS ),
    DiracDecoder(),
    VideoOverlay()
    ).run()
    Source: Examples/example10/SimpleDiracEncodeDecode.py

 

Kamaelia is an open source project originated from and guided by BBC Research. For more information browse the site or get in contact.

This is an ongoing community based development site. As a result the contents of this page is the opinions of the contributors of the pages involved not the organisations involved. Specificially, this page may contain personal views which are not the views of the BBC. (the site is powered by a wiki engine)

(C) Copyright 2008 Kamaelia Contributors, including the British Broadcasting Corporation, All Rights Reserved

This web site is powered by the same code created for the bicker manor project. For more details, contact Michael Sparks at BBC Research directly (cf contact)