From a9295fca1f5e605073b7754604ec1cc1d01766c1 Mon Sep 17 00:00:00 2001 From: Michael Tretter Date: Wed, 11 Sep 2024 16:28:57 +0200 Subject: [PATCH] driver/usbvideodriver: reduce latency of GStreamer pipeline The playbin3 uses a urisourcebin to open and read the uri. The urisourcebin detects the fd as a stream uri and internally crates a multiqueue with a default buffer duration of 5 s and a high watermark of 0.60 to buffer the stream. This adds 3 s latency to the video stream. If the source signals that is it a live source, the urisourcebin would avoid buffering of the stream. Unfortunately, the fdsrc doesn't signal that the data is live, and doesn't have a property to change this. Use buffer-duration to set the size of the queue for buffering to 0 to avoid this additional latency. The queue could be completely removed by setting "buffering" in the flags property of playbin3 to 0, which would be equal to the behavior of a live source, but the changed flags are more difficult to understand than the buffer duration. --- labgrid/driver/usbvideodriver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/labgrid/driver/usbvideodriver.py b/labgrid/driver/usbvideodriver.py index 15fad97ed..5a604d570 100644 --- a/labgrid/driver/usbvideodriver.py +++ b/labgrid/driver/usbvideodriver.py @@ -131,7 +131,7 @@ def stream(self, caps_hint=None, controls=None): tx_cmd = self.video.command_prefix + ["gst-launch-1.0", "-q"] tx_cmd += pipeline.split() rx_cmd = ["gst-launch-1.0"] - rx_cmd += "playbin3 uri=fd://0".split() + rx_cmd += "playbin3 buffer-duration=0 uri=fd://0".split() tx = subprocess.Popen( tx_cmd,