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:
Alternatively, source your own AVI file and convert with:
and alter the config below as required.
#!/usr/bin/pythonSource: Examples/example10/SimpleDiracEncodeDecode.py
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()
(C) 2006 Kamaelia Contributors, including the British Broadcasting Corporation, All Rights Reserved, 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.