<div dir="ltr">Good morning,<div><br></div><div>I am trying to decode several video streams using GStreamer and Python. I can't tell you how much I will appreciate your help!</div><div><br></div><div>Here's my code:<br><br></div><div><pre class="gmail-code gmail-highlight" lang="plaintext"><span id="gmail-LC1" class="gmail-line" lang="plaintext">self.video_capture = cv2.VideoCapture(self.pipeline, cv2.CAP_GSTREAMER)</span>
<span id="gmail-LC2" class="gmail-line" lang="plaintext">if self.video_capture.isOpened() is False:</span>
<span id="gmail-LC3" class="gmail-line" lang="plaintext">    raise Error</span>
<span id="gmail-LC4" class="gmail-line" lang="plaintext">while True:</span>
<span id="gmail-LC5" class="gmail-line" lang="plaintext">    status, image = self.video_capture.read()</span>
<span id="gmail-LC6" class="gmail-line" lang="plaintext">    # do slow stuff</span>
</pre><pre class="gmail-code gmail-highlight" lang="plaintext"><br></pre>I am encountering the following issue:<br><br></div><div><b>Option 1</b></div><div>If I use the pipeline:</div><div><code>self.pipeline = f"rtspsrc location={self.url} latency=10 ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! appsink max-buffers=1 drop=true"</code><br></div><div><br></div><div>I get extremely high CPU consumption. Also, I am probably decoding more frames than the number my application can actually consumes.</div><div><br></div><div><br></div><div><b>Option 2</b></div><div>If I use this pipeline</div><div><code>self.pipeline = f"rtspsrc location={self.url} latency=10 ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! appsink max-buffers=1 drop=false"</code><br></div><div><br></div><div>After a few hours the application is returning me old frames. E.g. at 9am my application was receiving frames at nighttime (from the night before).</div><div><br></div><div><br></div><div>Is this the expected behavior? How can I solve this problem?</div><div><br></div><div>Thank you a lot,</div><div><br></div><div>Matteo</div><div><br></div></div>