Saving Camera Stream to Multiple Files Using Gstreamer Without Frameloss


I have a e-CAM131_CUTX2 13MP MIPI camera attached to my TX1 board, and I want to save the video stream into discrete files, of 5 min each, then later reassemble the video recordings together again, without ANY frameloss, and also preferably while recording form an USB microphone.

I have earlier worked with FFMPEG, however I’d like to use Gstreamer for this project.

As I wanna use the Jetson board’s encoding capabilities, I’m using nvvidcon and omxh265enc to encode the video stream. The pipeline I have the best luck with is as follows;

gst-launch-1.0 -e
v4l2src device=$VIDEO_DEV
! queue max-size-buffers=0 max-size-time=0 max-size-bytes=0
! “video/x-raw, format=(string)UYVY, framerate=30/1, width=(int)3840, height=(int)2160”
! nvvidconv
! “video/x-raw(memory:NVMM), format=(string)I420, width=(int)3840, height=(int)2160, framerate=30/1”
! omxh265enc
! mux.
alsasrc device=$AUDIO_DEV
! queue max-size-buffers=0 max-size-time=0 max-size-bytes=0
! audioconvert
! voaacenc
! mux.
matroskamux name=mux
! multifilesink next-file=max-duration max-file-duration=300000000000 location=$FILENAME-%05d.mkv

However with this, I loose at least a couple of frames between files. I have tried removing different elements, like the audio part, however this changes nothing with the frameloss, I don’t think it’s a matter of CPU resources, as it only uses about 20% of the total CPU.

I thought I would try to set the number of Iframes encoded to a higher number, but when I use omxh265enc’s iframeinterval setting, it just keeps on sending Iframes every 60 frames.

Any help or input would be appreciated, thanks.

Hi SKThomassen,
Configuring iframeinterval shall work fine on r28.1.
[url]More Clarity on H.265 Encode Parameters? - Jetson TX1 - NVIDIA Developer Forums

do you run on r28.1?


No, I’m running R24.2.

How can I easily upgrade to R28.1? Or will I have to completely re-flash the board?

You may flash r28.1 via Jetpack3.1.

On r24.2.1, you can try to build the prebuilt lib:
[url]problem about gstreamer plugin omxh265enc - Jetson TX1 - NVIDIA Developer Forums


I can’t get the second method to work, as I don’t have “egl” software installed.

so I will try to re-flash with r.28.1.

You may try splitmuxsink

Not sure but multifilesink may not split at key frames.


So, I have flashed the TX1 board sucessfully to R28.1, and the omxh265enc element can now set the key-frame interval without problems. But this didn’t solve my issue with frameloss between split-files.

I then as sugested moved on to trying with splitmuxsink. This seems to works if I use omxh264enc, without any frameloss between generated files, but I can’t get splitmuxsink to work together with h265.

What I do is something like:
omxh265enc ! matroskamux ! splitmuxsink location=$FILENAME-%05d.mkv max-size-time=300000000000 muxer=matroskamux

But this gives me errors like “could not link matroskamux to splitmuxsink”, and I can’t seem to find what I need to sink these elements together.

You should set ‘muxer’ property. Not all muxer elements support video/x-h265

Have you been able to split with qtmux?

Example that works:

gst-launch-1.0 -e v4l2src num-buffers=500 ! video/x-raw,width=320,height=240 ! videoconvert ! queue ! timeoverlay ! x264enc key-int-max=10 ! h264parse ! splitmuxsink max-size-time=10000000000 max-size-bytes=1000000

example that doesn’t [ just runs one file write]:

gst-launch-1.0 v4l2src device=/dev/video5 num-buffers=1800 ! video/x-h264,width=1920,height=1080,framerate=25/1 !    h264parse ! splitmuxsink max-size-time=10000000000 max-size-bytes=1000000

if I add qtmux to the line above it will throw exceptions.
However, I shall address the issue to gstreamer dev group.