[gst-devel] webcam recording

Mark Nauwelaerts manauw at skynet.be
Mon Jun 16 23:40:25 CEST 2008


The pipeline you mentioned originally seems a bit complicated.
The following is my "favourite" one:
     v4l2src queue-size=15 \
       ! stamp silent=false progress=0 sync-margin=2 sync-interval=25 \
       ! video/x-raw-yuv,width=384,height=288,framerate=25/1 \
       ! queue max-size-buffers=0 max-size-bytes=0 max-size-time=4000000000 \
       ! theoraenc quality=32 ! oggmux name="mux" \
       ! filesink location=output.ogg \
     alsasrc latency-time=40000 buffer-time=4000000 \
       ! audio/x-raw-int,rate=48000,width=16,depth=16,channels=2 \
       ! queue max-size-buffers=0 max-size-bytes=0 max-size-time=4000000000 \
       ! audioconvert ! vorbisenc quality=0.5 ! mux.
(yes, the latency and buffer times are likely way overkill, they get adjusted
internally anyway, I'll take anything I can get there short of trying to fit the
entire recording in it, as in the original pipeline :) ..., just as with the
queues.  It is also highly adjusted to the tv capture card hardware in question)

A variation on the above one (different codecs, to give CPU a chance to keep up)
handles hours of uninterrupted capture with impeccable sync, and the one above
also has a/v sync just fine (though not the best possible video quality, due to
settings).  If one is wondering, stamp acts like videorate for formats needing
it, just uses a different approach/algorithm, and restricted to specific cases.

A somewhat looser version of it (among many possible) could then be:
     v4l2src queue-size=15 \
       ! stamp silent=false progress=0 sync-margin=2 sync-interval=5 \
       ! video/x-raw-yuv,width=384,height=288,framerate=20/1 \
       ! queue max-size-buffers=0 max-size-bytes=0 max-size-time=4000000000 \
       ! ffmpegcolorspace ! theoraenc quality=32 ! oggmux name="mux" \
       ! filesink location=output.ogg \
     alsasrc latency-time=40000 buffer-time=4000000 \
       ! audio/x-raw-int,rate=48000 \
       ! queue max-size-buffers=0 max-size-bytes=0 max-size-time=4000000000 \
       ! audioconvert ! vorbisenc quality=0.5 ! mux.
(well, (frame)rates might need adjusting here and there)
That should also handle other sync in v4l2src instances, e.g. webcam, though
have no (working) hardware to test the latter case.

Other thoughts and comments I can come up with:
- sync-margin=1 sync-interval=1 is not recommended;
if "heavy" sync forcing is really needed, sync-interval=2 sync-interval=2 or
something else in between extremes should do (though having to use this seems
already indicative of hardware in trouble)
- try a different container, e.g. matroskamux. In fact, since matroska records
time much more faithfully, there should be no need for fancy sync bits (such as
stamp, videorate)
- some variations in the capture parameters (??), framerate, size, etc
(might make hardware happier)
- I typically use entrans (rather than gst-launch) to run those pipelines;
this should make no difference at all w.r.t. a/v sync, but it has facilities
that e.g. monitor queue levels (to see if anything is choking along the way) and
has proper EOS handling upon SIGINT (which most formats need to end up with a
nicely playable result, e.g. matroska above)

Hopefully did not copy-and-paste error on some of the pipelines ...

Regards,
Mark.

Joshua N Pritikin wrote:
> On Sun, Jun 15, 2008 at 03:04:31PM -0700, Joshua N Pritikin wrote:
>> gst-launch-0.10 alsasrc device="hw:0,0" ! audio/x-raw-int,rate=16000,channels=1,depth=16 ! audioconvert ! alsasink
> 
> Oops, I meant:
> 
> gst-launch-0.10 alsasrc device="hw:0,0" ! audio/x-raw-int,rate=44100 ! audioconvert ! alsasink
> 
>> They work fine. However, when i record them together the video is either 
>> too slow (stamp sync-margin=1 sync-interval=1) or too fast (stamp 
>> sync-margin=2 sync-interval=5).
> 
> Actually the video seems to be consistently too fast. I can't remember 
> how I got the video to be too slow.
> 
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
> 




More information about the gstreamer-devel mailing list