<div dir="auto"><div><br><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">Le lun. 23 déc. 2024, 06 h 15, Daniel Spiessberger via gstreamer-devel <<a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>

  

    
  
  <div>
    <p>Hi everyone,</p>
    <p>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.</p>
    <p>To avoid this, I’ve moved the pipeline creation, starting, and
      stopping to a <code>QThread</code>. However, I’m encountering an
      occasional problem (~1 in 100 runs): the <code>v4l2h264dec</code>
      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.</p></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">20s is a lot more then v4l2h264dec element can allocate memory.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
    <p>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<br>
      I’ve tried repositioning the <code>queue</code> element, but it
      doesn’t affect the outcome.</p></div></blockquote></div></div><div dir="auto">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.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
    <p>My questions are:</p>
    <ol>
      <li>What is the recommended approach for creating and managing
        GStreamer elements outside the main thread?</li></ol></div></blockquote></div></div><div dir="auto">One initialized, the pipeline will run on its own thread. Nothing special should be needed.</div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><ol>
      <li>Are there any specific considerations for synchronization or
        thread safety when using <code>QThread</code> for this purpose?</li></ol></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">If you handle asynchronous messages in that new thread, then you need internal threadsafety in you app.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><ol>
    </ol>
    <p>Any advice or insights would be greatly appreciated!</p>
    <p>Thank you,<br>
      Daniel Spießberger<br>
    </p>
    <p></p>
  </div>

</blockquote></div></div></div>