diff --git a/setup.cfg b/setup.cfg index aea3ecc..088bf38 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,7 +33,8 @@ dev = black==23.10.1 [options.entry_points] console_scripts = - gst-webrtc-producer-list = example.get_producer_list:main + gst-webrtc-producer-list = examples.get_producer_list:main + gst-webrtc-video-recorder = examples.recorder.simple_recorder:main [flake8] diff --git a/src/examples/README.md b/src/examples/README.md index a3e95e6..40bc5f5 100644 --- a/src/examples/README.md +++ b/src/examples/README.md @@ -4,12 +4,24 @@ WebRTC client that records the streams into gdp files, and then mux them into a mp4. Gstreamer rust plugins must be installed. Please follow the [documentation](https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/tree/main/net/webrtc). -You can directly provided the peer webrtc name (i.e. *robot* for Reachy), or the peer id. Please use --help for more details about the command. +You can directly provide the peer webrtc name (i.e. *robot* for Reachy), or the peer id. Please use --help for more details about the command. The recorder can be started as follow and will generate a mp4 file. ```shell -python src/examples/simple_recorder.py --remote-producer-peer-name robot +python src/examples/recorder/simple_recorder.py --remote-producer-peer-name robot --signaling-host +``` + +A Dockerfile is also provided to ease the avoid the compilation of the rust plugins. Navigate to the parent folder of the cloned repo (i.e. `cd ../../..` from this README.md), and build the image + +```shell +docker build -t webrtcrecorder -f gst-signalling-py/src/examples/recorder/Dockerfile . +``` + +Then run the recorder from within a container. Change `~/Videos/`by the path where you want the recording to be saved to. + +```shell +docker run --network host -v ~/Videos/:/root/output webrtcrecorder --remote-producer-peer-name robot --signaling-host --output /root/output/recording.mp4 ``` ## Signalling tools diff --git a/src/examples/recorder/Dockerfile b/src/examples/recorder/Dockerfile new file mode 100644 index 0000000..d75d87e --- /dev/null +++ b/src/examples/recorder/Dockerfile @@ -0,0 +1,33 @@ +FROM ubuntu:24.04 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + curl libssl-dev git python3-pip pkg-config libcairo2-dev gcc python3-dev \ + libgirepository1.0-dev python3-gst-1.0 gir1.2-gst-plugins-bad-1.0 gstreamer1.0-plugins-bad \ + gstreamer1.0-nice libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev \ + libgstreamer-plugins-bad1.0-dev gstreamer1.0-tools python3-pyee python3-numpy python3-websockets + +# Rust +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y +ENV PATH="/root/.cargo/bin:${PATH}" +RUN cargo install cargo-c + +RUN mkdir /src + +#Compile gstreamer webrtc plugin. +WORKDIR /src + +RUN git clone -b 0.12.8 --depth 1 https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git +WORKDIR /src/gst-plugins-rs +RUN cargo cbuild -p gst-plugin-webrtc --prefix=/usr +RUN cargo cinstall -p gst-plugin-webrtc --prefix=/usr + + +COPY gst-signalling-py /src/gst-signalling-py +WORKDIR /src/gst-signalling-py + +RUN pip install --no-deps --break-system-packages . + +WORKDIR /root +RUN mkdir /root/output + +ENTRYPOINT [ "gst-webrtc-video-recorder" ] \ No newline at end of file diff --git a/src/examples/recorder/__init__.py b/src/examples/recorder/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/examples/simple_recorder.py b/src/examples/recorder/simple_recorder.py similarity index 100% rename from src/examples/simple_recorder.py rename to src/examples/recorder/simple_recorder.py