Skip to content

Commit

Permalink
enhancement #29 : use custom version of aiortc. add example for recor…
Browse files Browse the repository at this point in the history
…d video
  • Loading branch information
FabienDanieau committed Oct 30, 2023
1 parent e5bded7 commit 5d372e4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 15 additions & 1 deletion src/example/videostream-cli/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
$ 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)*
7 changes: 5 additions & 2 deletions src/example/videostream-cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 5d372e4

Please sign in to comment.