Creating HTML5-Compatible Video Streams From a V4l2 Device

Antonio Ospite ao2 at ao2.it
Fri Oct 3 01:20:16 PDT 2014


On Thu, 2 Oct 2014 18:45:47 -0500
Timm Murray <tmurray at wumpus-cave.net> wrote:

> I'm trying to create an video and container format for HTML5 streams that
> works from the Raspberry Pi camera, which is accessible as a v4l2 device.
> The eventual goal is to stream this live, but for now, I'm testing by using
> fakesink and filesink.  I can take still photos with raspistill just fine.
> 
> The problem I keep running into is that the stream data seems to get stuck
> at some point in the pipeline.  I started with setting the v4l2 device with
> v4l2-ctl:
> 
> v4l2-ctl --set-fmt-video=width=1920,height=1080,pixelformat="yuv420" -d
> /dev/video0
>

When using v4l2src you don't need to use v4l2-ctl in advance, the
GStreamer source element sets the video format when you pass the correct
caps.

> My first attempt used v4l2src directly:
> 
> gst-launch -v v4l2src device=/dev/video0 !
> 'video/x-raw-yuv,width=1080,height=1080,framerate=25/1' ! fakesink dump=TRUE
>

Width is wrong, and format is missing, and please use GStreamer 1.x,
the command line would look like:

gst-launch-1.0 -v v4l2src device=/dev/video0 ! 'video/x-raw,format=I420,width=1920,height=1080,framerate=25/1' ! fakesink dump=TRUE

> This hit an error:
> 
> libv4l2: error got 4 consecutive frame decode errors, last error:
> v4l-convert: error resolution is not a multiple of dctsizeERROR: from
> element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Error reading 1749600
> bytes from device '/dev/video0'.
> Additional debug info:
> gstv4l2src.c(893): gst_v4l2src_get_read ():
> /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
> system error: Input/output error
>

You are using the wrong width and a 12bpp pixel format.
1749600 = 1080 * 1080 * 1.5

> I couldn't find much with Google on how to fix dctsize errors.  My next
> approach used filesrc to read directly from /dev/video0:
>

filesrc won't work with video nodes in general.

> gst-launch-1.0 -e -v filesrc location=/dev/video0 ! videoparse format=i420
> width=1920 height=1080 framerate=30/1 pixel-aspect-ratio=1920/1080 !
> fakesink dump=true
> 
> The fakesink starts dumping hex data, so that seems to work as far as it
> goes.  However, adding theoraenc to the pipeline:
> 
> gst-launch-1.0 -e -v filesrc location=/dev/video0 ! videoparse format=i420
> width=1920 height=1080 framerate=30/1 pixel-aspect-ratio=1920/1080 !
> theoraenc ! fakesink dump=true
>

If you are not absolutely sure that the encoder accepts the pixelformat
you'd better put a videoconvert element before the encoder.

> No data gets dumped from fakesink, though there is quite a bit of debug
> info.  Full output is below.  I also gave x264enc a try, with similar
> results.
> 
> In each run, I give it a minute or so to start dumping data, then hit
> Ctrl-c.
> 
> Once I can get an encoder working, the next step is to add oggmux or some
> other HTML5-compatible container, but I need to get the encoder working
> before I can get that far.
> 
> Thanks,
> Timm
> 

Ciao,
   Antonio

-- 
Antonio Ospite
http://ao2.it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?


More information about the gstreamer-devel mailing list