Tool/software:
Hello,
I'm trying to split my video recording into three separate files, each containing 10 seconds of footage, using a camera as the video source.
According to GStreamer's official documentation, splitmuxsink
is typically used with x264enc
. However, on the TI AM68A platform, there are three hardware video encoders available, and for saving purposes, I believe v4l2h264enc
and v4l2h265enc
should be suitable.
I attempted the following pipeline:
gst-launch-1.0 v4l2src device=/dev/video2 num-buffers=100 ! \
video/x-raw, width=1280, height=720 ! videoconvert ! queue ! \
tee name=t \
t. ! queue ! v4l2h264enc extra-controls="encode,key_int_max=10" ! h264parse ! queue ! \
splitmuxsink location=video%02d.mkv max-size-time=10000000000 max-files=3 muxer-factory=matroskamux \
muxer-properties="properties,streamable=true" \
t. ! queue ! autovideosink
While this pipeline successfully records video, it does not continuously save as expected. I initially set num-buffers=100
, which resulted in a 10-second recording. However, when I increased num-buffers
to 500, the video duration extended to 50 seconds.Also tried removing the num-buffers then the video is streaming but creating one file of video00.mkv and video is empty, 0kb file.
I assumed that max-size-time
should control the duration of each file (10 seconds), while max-files
should limit the total number of files. However, the pipeline does not seem to be functioning as intended.
Hello,
Thanks for your question. It could the queueing and parsing steps need to restructured. Additionally, num-buffers will stop the source at a certain number of frames which is around a 1:1 relationship with the number of buffers specified depending on stream characteristics.
Also what SDK version are you using?
Thanks,
Sarabesh S.
The SDK version is 10.0.1. I tried removing the "num-buffers" property from the source, which made autovideosink
work correctly. However, the video is not being saved—the file video00.mkv
is created but remains empty and no further file is created.
The logs show that splitmuxsink is waiting for the end of a GOP, and I’ve set key_int_max=5 to ensure frequent keyframes and increased the queue size to prevent overflows, but the issue persists.. I’ve tested the encoder and muxer independently, and they work fine.
Thanks
Hi Nihal,
Wasn't able to look into this today, I'll have an update for you next week.
Thanks,
Sarabesh S.
gst-launch-1.0 v4l2src device=/dev/video2 ! video/x-raw,width=1280,height=720 ! videoconvert ! queue ! timeoverlay ! x264enc key_int_max=10 ! h264parse ! splitmuxsink location=video%02d.mkv max-size-time=10000000000 max-files=3 muxer-factory=matroskamux muxer-properties="properties,streamable=true"
This pipeline I tried on my PC, which uses x264enc
, works perfectly. However, when I try a similar pipeline on my TI platform using v4l2h264enc
, it doesn't work as expected. This suggests that the issue might be with the v4l2h264enc
element or how I've configured the parsing and muxing elements. Unfortunately, the TI platform doesn't have the x264enc
element available, so I need to troubleshoot the v4l2h264enc
setup. Could you help me identify what might be going wrong?
Solved the problem:
I added h264_i_frame_period=10 this property to v4l2h264enc has resolved the problem. The final pipeline is:
gst-launch-1.0 v4l2src device=/dev/video2 ! video/x-raw,format=YUY2,width=640,height=480,framerate=30/1 ! videoconvert ! timeoverlay ! tee name=t t. ! queue ! videoconvert ! autovideosink sync=false t. ! queue ! v4l2h264enc extra-controls="encode,h264_i_frame_period=10,speed-preset=ultrafast" ! h264parse ! splitmuxsink location=video%02d.mkv max-size-time=10000000000 max-files=3 muxer=matroskamux