diff --git a/CHANGES.rst b/CHANGES.rst index 46af8da38..97cef139f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -11,6 +11,10 @@ New Features in 25.1 - Guermok HDMI to USB 3.0 capture dongle supported +- The `USBVideoDriver`'s ``stream`` method can now be called with ``fps=True`` + to embed an overlay with FPS statistics into the video stream. + This is exposed in ``labgrid-client video`` via the new ``--fps`` option. + Breaking changes in 25.1 ~~~~~~~~~~~~~~~~~~~~~~~~ - The deprecated pytest plugin option ``--env-config`` has been removed. Use diff --git a/contrib/completion/labgrid-client.bash b/contrib/completion/labgrid-client.bash index 09b21eecc..d45b8f716 100644 --- a/contrib/completion/labgrid-client.bash +++ b/contrib/completion/labgrid-client.bash @@ -661,7 +661,7 @@ _labgrid_client_video() case "$cur" in -*) - COMPREPLY=( $(compgen -W "--quality --controls --name $_labgrid_shared_options" -- "$cur") ) + COMPREPLY=( $(compgen -W "--quality --controls --fps --name $_labgrid_shared_options" -- "$cur") ) ;; esac } diff --git a/labgrid/driver/usbvideodriver.py b/labgrid/driver/usbvideodriver.py index 09dd2ef12..b0f99d38e 100644 --- a/labgrid/driver/usbvideodriver.py +++ b/labgrid/driver/usbvideodriver.py @@ -139,13 +139,15 @@ def get_pipeline(self, path, caps, controls=None): return pipeline @Driver.check_active - def stream(self, caps_hint=None, controls=None): + def stream(self, caps_hint=None, controls=None, fps=False): caps = self.select_caps(caps_hint) pipeline = self.get_pipeline(self.video.path, caps, controls) tx_cmd = self.video.command_prefix + ["gst-launch-1.0", "-q"] tx_cmd += pipeline.split() rx_cmd = ["gst-launch-1.0", "playbin3", "buffer-duration=0", "uri=fd://0"] + if fps: + rx_cmd += ["video-sink=fpsdisplaysink"] tx = subprocess.Popen( tx_cmd, diff --git a/labgrid/remote/client.py b/labgrid/remote/client.py index 27108a7b4..22d5d514a 100755 --- a/labgrid/remote/client.py +++ b/labgrid/remote/client.py @@ -1313,6 +1313,7 @@ def telnet(self): def video(self): place = self.get_acquired_place() quality = self.args.quality + fps = self.args.fps controls = self.args.controls target = self._get_target(place) name = self.args.name @@ -1342,7 +1343,7 @@ def video(self): mark = "*" if default == name else " " print(f"{mark} {name:<10s} {caps:s}") else: - res = drv.stream(quality, controls=controls) + res = drv.stream(quality, controls=controls, fps=fps) if res: exc = InteractiveCommandError("gst-launch-1.0 error") exc.exitcode = res @@ -1972,6 +1973,7 @@ def main(): subparser = subparsers.add_parser("video", help="start a video stream") subparser.add_argument("-q", "--quality", type=str, help="select a video quality (use 'list' to show options)") + subparser.add_argument("-f", "--fps", action="store_true", help="Overlay FPS statistics") subparser.add_argument( "-c", "--controls", type=str, help="configure v4l controls (such as 'focus_auto=0,focus_absolute=40')" )