Video Guestbook with Gstreamer on Rpi

Nicolas Dufresne nicolas.dufresne at collabora.com
Sat May 23 07:58:08 PDT 2015


Le samedi 23 mai 2015 à 11:51 +0100, mathieu gosselin a écrit :
> Hello,
> 
> I m a newbie with gstreamer and I try to use it on a raspberry with a 
> webcam Logitech C920. This is a project guestbook video: the goal is 
> to record with the camera in a file (in good quality and with sound) 
> and, in parallel, display just the image on a screen.

Note that there is a firmware bug in this camera that cause the
timestamp to be wrong. You may need to enable do-timestamp=1 on the
source (v4l2src) (or use development version of GStreamer).

> 
> For now I managed to get the video on the screen but very jerky and 
> not very clear unless I drop the resolution with the command line:
> gst-launch-1.0 -e v4l2src device=/dev/video0 ! video/x-h264, 
> width=320, height=240, framerate=15/1 ! avdec_h264 ! eglglessink 
> sync=false

The fact you use sync=false is most likely because of the above. The
main issue here though is that you have chosen a software decoder. The
Rapsberry Pi have a very small CPU. You should use the HW decoder
instead. For simplicity, just use decodebin, it will pick the right
decoder for you.

Also note that the C920 can also be used with uvch264src element, which
will enable more features. It can providing you with two stream, a raw
preview and an encoded H264 stream. It also let you choose the stream
quality and bitrate.

> 
> 
> I also managed to generate a record in a file (oddly the video seems 
> a little accelerated) but without sound, with this command:
> gst-launch-1.0 -e v4l2src device=/dev/video0 ! video/x-h264, 
> width=800,height=600,framerate=30/1 ! queue ! avimux ! filesink 
> location=yop.avi

The speed issue could be a bug in avimux, or simply that AVI does not
tolerate variable framerate (the C920 does that by default). Note that
AVI is rarely used these days, hence may have less testing.

> 
> in fact impossible to operate the sound I tried with this command 
> that I found on the net done by a guy with the same webcam. But it 
> does not recognize "voaacenc"
> gst-launch-1.0 v4l2src device=/dev/video0 ! video/x
> -h264,width=1280,height=720,framerate=30/1 ! h264parse ! muxout. 
> pulsesrc device="alsa_input.usb-046d_HD_Pro_Webcam_C920_696E9EDF-02
> -C920.analog-stereo" ! queue ! audioconvert ! voaacenc bitrate=65536 
> ! muxout. matroskamux name=muxout streamable=true ! filesink 
> location=muxed-long.mp4

This is element is likely introduced in GStreamer 1.4, you seem to be
using GStreamer 1.2. It is possible that you could use faac element
instead. Notice that you save a Matroska stream into a file name .mp4,
this can be confusing. Extension .mkv is usually expected.

Nicolas



More information about the gstreamer-devel mailing list