Problems when creating pipeline outside main thread

Nicolas Dufresne nicolas at ndufresne.ca
Tue Dec 24 00:29:24 UTC 2024


Le lun. 23 déc. 2024, 06 h 15, Daniel Spiessberger via gstreamer-devel <
gstreamer-devel at lists.freedesktop.org> a écrit :

> 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.
>

20s is a lot more then v4l2h264dec element can allocate memory.

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.
>
By not using rtpjitterbuffer and ideally an proper rtpbin with RTCP, your
pipeline is enable to compensate delays and time shift. It's possible you
simply have been lucky so far, and changing the timing triggered the issue.

My questions are:
>
>    1. What is the recommended approach for creating and managing
>    GStreamer elements outside the main thread?
>
> One initialized, the pipeline will run on its own thread. Nothing special
should be needed.



>    1. Are there any specific considerations for synchronization or thread
>    safety when using QThread for this purpose?
>
>
If you handle asynchronous messages in that new thread, then you need
internal threadsafety in you app.


>
> 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/d2f3807a/attachment.htm>


More information about the gstreamer-devel mailing list