Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gstreamer - display and record video using Tee element hangs

Tags:

gstreamer

My target is to stream and record video at the same time.

Gstreamer version: 1.16.1, OS: debian 11

Initially I had more complex pipeline containing compositor on one branch and different custom filters. The simplified version of my constructed pipeline is as follows:

gst-launch-1.0 videotestsrc ! "video/x-raw,width=500,height=300,framerate=50/1"  !  tee name=t \
 t. ! queue !  x264enc ! splitmuxsink name=mux_sink  max-files=10000 next-file=5 max-size-time=600000000 location=video%02d.mp4 \
 t. ! queue !  "video/x-raw,width=500,height=300,framerate=50/1"  !  glimagesink

How this pipeline acts on my system is that it starts without problems but goes from NULL state to READY state and hangs there. The displayed video is also stationary and no video file is saved.

Here is svg file generated from the dot dump null->ready state: https://drive.google.com/file/d/1oGwDufDdljbuKr8b0YURvg5VxPzMtQWb/view?usp=sharing

I have already tried both branches separately without tee element - both working. I have also tried different combinations of caps filters on both queues. I tried raising gstreamer debug level to see if there was something suspicious there - nothing.

The task should be quite straight-forward, I must be missing something here.

Thanks in advance!

like image 376
Martin Appo Avatar asked Jan 20 '26 03:01

Martin Appo


1 Answers

The latency for the default x264 settings are too high for this use case. Use tune=zerolatency option for the x264enc element or increase the queue size after the tee for the display path. This will prevent deadlocking for preroll.

like image 82
Florian Zwoch Avatar answered Jan 23 '26 20:01

Florian Zwoch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!