<!DOCTYPE html>
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <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>
    <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>
    <p>My questions are:</p>
    <ol>
      <li>What is the recommended approach for creating and managing
        GStreamer elements outside the main thread?</li>
      <li>Are there any specific considerations for synchronization or
        thread safety when using <code>QThread</code> for this purpose?</li>
    </ol>
    <p>Any advice or insights would be greatly appreciated!</p>
    <p>Thank you,<br>
      Daniel Spießberger<br>
    </p>
    <p></p>
  </body>
</html>