Last month we posted a gstreamer pipeline for avi playback and simply presumed a working gstreamer installation. Now we have added a couple of packages to our growing repository, that make it very easy to install.
The packages include the
gst-omx module, which allows h264 de- and encoding with full use of the Raspberry Pi’s graphics hardware. But even with hardware support, the current stable series (1.2) doesn’t perform very well, because it does unnecessary copying of the video data. This is why these packages are based on the current development series (1.3), which means that they are not as mature and well tested as the slightly older 1.2 versions. But so far we haven’t run into any problems of that nature.
As a side note: The gstreamer versioning can be a little confusing. The packages you can find in software repositories are usually marked with “-0.10” or “-1.0”. The 1.x series is API and ABI stable and supersedes the previous stable 0.10 series and packages marked 1.0 can contain any version from the 1.x series.
The rest of the article will be about installing the packages, how to see if they work and a couple of things you can try if they don’t.
Add our repository and install
The omx plugins need
GST_OMX_CONFIG_DIR to be set. You can do that temporarily like this:
or add the same line to your
.profile as a permanent solution.
You can use
gst-inspect-1.0 to list all installed gstreamer plugins. Combine with
grep and it’s easy to find out if gstreamer knows about the omx plugins:
gst-inspect-1.0 | grep omx
should give you something like this:
omx: omxmpeg2videodec: OpenMAX MPEG2 Video Decoder omx: omxmpeg4videodec: OpenMAX MPEG4 Video Decoder omx: omxh263dec: OpenMAX H.263 Video Decoder omx: omxh264dec: OpenMAX H.264 Video Decoder omx: omxmjpegdec: OpenMAX MJPEG Video Decoder omx: omxvc1dec: OpenMAX WMV Video Decoder omx: omxh264enc: OpenMAX H.264 Video Encoder
To play a file you can use the previously mentioned pipeline:
gst-launch-1.0 filesrc location=test.avi ! avidemux ! h264parse ! omxh264dec ! autovideoconvert ! eglglessink
(Note that gstreamer is not a media player, but a framework that can be used by one. These commands are meant to support developers.)
Errors during playback
Make sure the memory split is generous with the video hardware, otherwise you may get seemingly random and unrelated errors during playback.
The omx plugins don’t show up
gst-inspect-1.0 doesn’t show the plugins, try deleting gstreamers registry:
A very useful feature for debugging pipelines is the possibility to create a visual graph of the pipeline. Set
GST_DEBUG_DUMP_DOT_DIR to a temporary directory before running the pipeline:
mkdir tmp GST_DEBUG_DUMP_DOT_DIR=./tmp/
Gstreamer will dump a lot of debugging information in
*.dot files in that directory. You can use
dot from the
graphviz package to create image files from those:
dot -Tpng x.xx.xx.xxxxxxxxx-gst-launch.FOO.dot > graph.png