Capturing jpegs from an h264 stream

Marc Olzheim marc at your.tv
Tue Jun 4 05:12:00 PDT 2013


On Tue, Jun 04, 2013 at 10:25:03AM +0100, Alex Hewson wrote:
> 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:

This builds the master branch, not 1.0.

For that I'd replace the commands like:

git clone git://anongit.freedesktop.org/git/gstreamer/gstreamer
cd gstreamer
...

with:

git clone -n git://anongit.freedesktop.org/git/gstreamer/gstreamer
cd gstreamer
git checkout -t origin/1.0
...

> 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?

I don't have a raspberrypi here, but simply connecting to a tcp source,
it works (well, it creates snapshots at least) here.

marcolz:/extra0/tmp/test>gst-launch-1.0 tcpclientsrc host=server042 port=26056 ! decodebin ! videorate ! video/x-raw,framerate=1/1 ! jpegenc ! multifilesink location=img_%03d.jpeg
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Missing element: private/teletext decoder
Missing element: DVB subtitles decoder
Missing element: DVB subtitles decoder
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
^CCaught interrupt -- handling interrupt.
Interrupt: Stopping pipeline ...
Execution ended after 4255232909 ns.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
marcolz:/extra0/tmp/test>ls -latr
total 7048
drwxrwxrwt 13 root    root          4096 Jun  4 14:02 ..
-rw-r--r--  1 marcolz development 355529 Jun  4 14:03 img_005.jpeg
-rw-r--r--  1 marcolz development 355567 Jun  4 14:03 img_004.jpeg
...

The framerate conversion you try to do does not work though; it seems to
dump one image per frame.

Marc


More information about the gstreamer-devel mailing list