Skip to content

driver: usbvideodriver: add support for overlaying FPS #1710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion contrib/completion/labgrid-client.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 3 additions & 1 deletion labgrid/driver/usbvideodriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion labgrid/remote/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')"
)
Expand Down