Problems when creating pipeline outside main thread

Daniel Spiessberger daniel.spiessberger at sequality.at
Mon Dec 23 09:38:16 UTC 2024


Hi everyone,

I’m working on a QtQuick application that uses GStreamer to display 
video streams. On my target hardware, creating the video decoder element 
(v4l2h264dec) takes some time, which blocks the main thread and freezes 
the GUI.

To avoid this, I’ve moved the pipeline creation, starting, and stopping 
to a |QThread|. However, I’m encountering an occasional problem (~1 in 
100 runs): the |v4l2h264dec| element gradually accumulates latency, 
leading to delays of up to ~20 seconds. Strangely, this issue doesn’t 
occur when the same pipeline is initialized and run from the main thread.

Here’s the pipeline: udpsrc port=5000 ! application/x-rtp, payload=96, 
encoding-name=H264 ! queue max-size-buffers=0 ! rtph264depay ! h264parse 
! v4l2h264dec ! imxvideoconvert_g2d ! qtvideosink sync=false
I’ve tried repositioning the |queue| element, but it doesn’t affect the 
outcome.

My questions are:

 1. What is the recommended approach for creating and managing GStreamer
    elements outside the main thread?
 2. Are there any specific considerations for synchronization or thread
    safety when using |QThread| for this purpose?

Any advice or insights would be greatly appreciated!

Thank you,
Daniel Spießberger
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20241223/569415de/attachment.htm>


More information about the gstreamer-devel mailing list