From 5d372e450279fed11ceb3f7a457403a311e51de4 Mon Sep 17 00:00:00 2001 From: Fabien Danieau Date: Mon, 30 Oct 2023 14:54:01 +0100 Subject: [PATCH] enhancement #29 : use custom version of aiortc. add example for record video --- setup.cfg | 2 +- src/example/videostream-cli/README.rst | 16 +++++++++++++++- src/example/videostream-cli/cli.py | 7 +++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/setup.cfg b/setup.cfg index f366318..bf1e899 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,7 +16,7 @@ include_package_data = True package_dir= =src install_requires = - aiortc + aiortc @ git+https://github.com/pollen-robotics/aiortc.git@gstreamer numpy pyee websockets diff --git a/src/example/videostream-cli/README.rst b/src/example/videostream-cli/README.rst index d09d79d..17d753a 100644 --- a/src/example/videostream-cli/README.rst +++ b/src/example/videostream-cli/README.rst @@ -60,4 +60,18 @@ Get a frame from a video stream and open it with open cv. .. code-block:: console - $ python src/example/videostream-cli/opencv.py consumer --remote-producer-peer-name robot \ No newline at end of file + $ python src/example/videostream-cli/opencv.py consumer --remote-producer-peer-name robot + + +Video record example +-------------- + +Record AV stream from the robot + +.. code-block:: console + + $ python src/example/videostream-cli/opencv.py consumer --remote-producer-peer-name robot --record-to test.mp4 + + + +*These two last examples need our custom version of aiortc. It should come automatically if you `pip install .` this repo (see setup.cfg)* diff --git a/src/example/videostream-cli/cli.py b/src/example/videostream-cli/cli.py index f6b4477..987bada 100644 --- a/src/example/videostream-cli/cli.py +++ b/src/example/videostream-cli/cli.py @@ -12,9 +12,10 @@ VideoStreamTrack, ) from aiortc.contrib.media import MediaBlackhole, MediaPlayer, MediaRecorder -from gst_signalling.aiortc_adapter import BYE, add_signaling_arguments, create_signaling from av import VideoFrame +from gst_signalling.aiortc_adapter import BYE, add_signaling_arguments, create_signaling + class FlagVideoStreamTrack(VideoStreamTrack): """ @@ -143,7 +144,9 @@ def on_track(track): # create media sink if args.record_to: - recorder = MediaRecorder(args.record_to) + recorder = MediaRecorder( + args.record_to, options={"video_size": "1280x720"}, framerate=60 + ) else: recorder = MediaBlackhole()