Capturing jpegs from an h264 stream

Alex Hewson mock at mocko.org.uk
Tue Jun 4 02:25:03 PDT 2013


Hi gstreamer folks.  This is my first post on the list so if I've come 
to the wrong place just point me to the right forum for questions about 
CLI usage.

I have one of the new camera add-ons for a Raspberry Pi. It doesn't yet 
have video4linux support but comes with a small program that spits out a 
1080p h264 stream. I have verified this works and got it pushing the 
video to stdout with:

raspivid -n -t 1000000 -vf -b 2000000 -fps 25 -o -

I would like to process this stream such that I end up with a snapshot 
of the video taken once a second.

Since it's 1080p I will need to use the rpi's hardware support for H264 
encoding. I believe gstreamer is the only app to support this so 
solutions using ffmpeg or avconv won't work. I've used the build script 
at http://www.trans-omni.co.uk/pi/GStreamer-1.0/build_gstreamer to make 
gstreamer and the plugin for hardware H264 encoding and it appears to work:

root at raspberrypi:~/streamtest# GST_OMX_CONFIG_DIR=/etc/gst 
gst-inspect-1.0 | grep 264
...
omx:  omxh264enc: OpenMAX H.264 Video Encoder
omx:  omxh264dec: OpenMAX H.264 Video Decoder

So I need to construct a gst-launch pipeline that takes video on stdin 
and spits out a fresh jpeg once a second. I know I can use gstreamer's 
'multifilesink' sink to do this so have come up with the following short 
script to launch it:

root at raspberrypi:~/streamtest# cat test.sh
#!/bin/bash

export GST_OMX_CONFIG_DIR=/etc/gst

raspivid -n -t 1000000 -vf -b 2000000 -fps 25 -o - |  \
gst-launch-1.0 fdsrc fd=0 ! decodebin ! videorate ! 
video/x-raw,framerate=1/1 ! jpegenc ! multifilesink location=img_%03d.jpeg

Trouble is it doesn't work: gstreamer just sits forever in the 
prerolling state and never spits out my precious jpegs.

root at raspberrypi:~/streamtest# ./test.sh
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
[waits forever]

In case it's helpful output with gstreamer's -v flag set is at 
http://pastebin.com/q4WySu4L

Can anyone explain what I'm doing wrong?

-- 
Alex Hewson
m: +44 7895 265219 | e: mock at mocko.org.uk | Skype: alex.hewson



More information about the gstreamer-devel mailing list