gstreamerwebcammjpegmatroska

Saving webcam jpeg stream to multiple files with gstreamer


I'm trying to save a MJPEG stream from a logitech C920 webcam to multiple video files (matroska).

I've got this pipeline: (1 mkv file every 60s)

gst-launch-1.0 -ev v4l2src device=/dev/video0 \
! image/jpeg,width=1280,height=720,framerate=24/1 \
! matroskamux ! multifilesink next-file=max-duration max-file-duration=60000000000 location='test1-%02d.mkv'

It outputs several files, as expected, but the files have errors, so tools like avidemux can't play them back. mkvalidator reports these:

WRN080: Unknown element [FF] at 293 size 88
WRN080: Unknown element [FF] at 494 size 64
WRN080: Unknown element [7D][01] at 566 size w98603107602
WRN801: The segment has no SeekHead section
WRN0B8: Track #1 is defined but has no frame

BTW, saving to a single file using filesink produces an mkv file without errors.

Is there a way to save multiple mkv files properly? Any other container is also OK, but I cannot transcode (need low CPU load) and I cannot use raw (need HD with high fps).

I'm using GStreamer 1.8.2 on Ubuntu 16.04.1.

Thanks.

Update: Following the advice below, I tried with splitmuxsink:

gst-launch-1.0 -e v4l2src device=/dev/video1 \
! image/jpeg,width=1280,height=720,framerate=24/1 \
! splitmuxsink muxer=matroskamux location='test1-%02d.mkv' \
max-size-time=10000000000

But it doesn't work: The file is never split and keeps growing in size.


Solution

  • I've got success with an upgraded GStreamer (Ubuntu 18.04)

    $ gst-launch-1.0 --gst-version
    GStreamer Core Library version 1.14.1
    

    Here is a pipeline with an AVI container, where a new file is generated every ten seconds:

    gst-launch-1.0 -e v4l2src device=/dev/video1 \
    ! image/jpeg,width=1280,height=720,framerate=24/1 \
    ! splitmuxsink muxer=avimux location='test1-%02d.avi' max-size-time=10000000000
    

    It also works with matroskamux.