Advanced Examples

From RidgeRun Developer Wiki

Follow Us On Twitter LinkedIn Email Share this page









Advanced examples with rrmoq plugin

The following examples showcase several useful examples using the plugin’s element.

Send multiple video tracks on the same channel with rrmoqbin

You can send any number of video tracks using rrmoqbin:

gst-launch-1.0 -v \
  rrmoqbin relay-mode=local relay-server-host-addr=https://127.0.0.1:4443 name=moq channel=test \
    sink_0::track-name=video1 sink_0::channel=test sink_1::track-name=video2 sink_1::channel=test sink_2::track-name=video3 sink_2::channel=test  \
  videotestsrc is-live=true pattern=smpte  ! videoconvert ! x264enc speed-preset=ultrafast tune=zerolatency ! h264parse ! queue ! moq.sink_0 \
  videotestsrc is-live=true pattern=ball   ! videoconvert ! x264enc speed-preset=ultrafast tune=zerolatency ! h264parse ! queue ! moq.sink_1 \
  videotestsrc is-live=true pattern=white  ! videoconvert ! x264enc speed-preset=ultrafast tune=zerolatency ! h264parse ! queue ! moq.sink_2

Catch any with rrmoqsrc:

gst-launch-1.0 rrmoqsrc relay-url=https://127.0.0.1:4443 channel=test name=src \
    src.video1 ! decodebin ! videoconvert ! autovideosink

Send multiple video and audio to the same channel with rrmoqbin

gst-launch-1.0 -v \
  rrmoqbin relay-mode=local relay-server-host-addr=https://127.0.0.1:4443 name=moq channel=test \
    sink_0::track-name=video1 sink_0::channel=test sink_1::track-name=audio2 sink_1::channel=test sink_2::track-name=video3 sink_2::channel=test sink_3::track-name=audio4 sink_3::channel=test  \
  videotestsrc is-live=true pattern=smpte ! videoconvert ! x264enc speed-preset=ultrafast tune=zerolatency ! h264parse ! queue ! moq.sink_0  \
  videotestsrc is-live=true pattern=ball  ! videoconvert ! x264enc speed-preset=ultrafast tune=zerolatency ! h264parse ! queue ! moq.sink_1 \
  audiotestsrc is-live=true wave=ticks ! audioresample ! audioconvert ! voaacenc !  queue ! moq.sink_2 \
  audiotestsrc is-live=true wave=sine  ! audioresample ! audioconvert ! voaacenc !  queue ! moq.sink_3

Catch any audio or video with rrmoqsrc:

gst-launch-1.0 rrmoqsrc relay-url=https://127.0.0.1:4443 channel=test name=src \
    src.video2 ! decodebin ! videoconvert ! autovideosink
gst-launch-1.0 rrmoqsrc relay-url=https://127.0.0.1:4443 channel=test name=src \
    src.audio3 ! decodebin ! audioconvert ! autoaudiosink

Send multiple video and audio tracks through different channels with rrmoqbin

You can set the channel for any sink pad in the rrmoqbin:

gst-launch-1.0 -v \
  rrmoqbin relay-mode=local relay-server-host-addr=https://127.0.0.1:4443 name=moq \
    sink_0::track-name=video1 sink_0::channel=test-video1 sink_1::track-name=audio2 sink_1::channel=test-video2 sink_2::track-name=video3 sink_2::channel=test-video3 sink_3::track-name=audio4 sink_3::channel=test-audio4  \
  videotestsrc is-live=true pattern=smpte ! videoconvert ! x264enc speed-preset=ultrafast tune=zerolatency ! h264parse ! queue ! moq.sink_0  \
  videotestsrc is-live=true pattern=ball  ! videoconvert ! x264enc speed-preset=ultrafast tune=zerolatency ! h264parse ! queue ! moq.sink_1 \
  audiotestsrc is-live=true wave=ticks ! audioresample ! audioconvert ! voaacenc !  queue ! moq.sink_2 \
  audiotestsrc is-live=true wave=sine  ! audioresample ! audioconvert ! voaacenc !  queue ! moq.sink_3

Publish multiple video and audio from different sources:

gst-launch-1.0 -v \
  rrmoqbin relay-mode=local relay-server-host-addr=https://127.0.0.1:4443 name=moq \
    sink_0::track-name=video1 sink_0::channel=test-video1 sink_1::track-name=audio3 sink_1::channel=test-audio3 sink_2::track-name=video2 sink_2::channel=test-video2 sink_3::track-name=audio4 sink_3::channel=test-audio4  \
  filesrc location=/path/to/video  ! qtdemux name=d  \
  d.video_0 ! queue ! moq.sink_0 \
  d.audio_0 ! queue ! moq.sink_1 \
  videotestsrc is-live=true pattern=smpte ! videoconvert ! x264enc speed-preset=ultrafast tune=zerolatency !  parsebin ! queue ! moq.sink_2 \
  audiotestsrc is-live=true wave=ticks ! audioresample ! audioconvert ! voaacenc !  parsebin ! queue ! moq.sink_3

Shared relay between rrmoqbin

Use one rrmoqbin with relay-mode=local to spawn a relay server:

gst-launch-1.0 rrmoqbin channel=test-video name=bin \
  sink_0::track-name=video \
  videotestsrc is-live=true ! videoconvert ! x264enc ! queue ! bin.sink_0

Then use another rrmoqbin with relay-mode=external to set it to use the same relay:

gst-launch-1.0 rrmoqsrc relay-mode=external relay-url=https://127.0.0.1:4443 channel=test-video name=src \
  src.video ! decodebin ! videoconvert ! autovideosink

Or use a simpler rrmoqsink to publish to the same relay:

gst-launch-1.0  videotestsrc is-live=true ! videoconvert ! x264enc ! h264parse ! queue ! \
  rrmoqsink relay-url=https://127.0.0.1:4443 channel=test-video track-name=video

Examples with elements with hw acceleration

X86 platform with vaapi elements:

Simple sender with rrmoqsink

gst-launch-1.0 autovideosrc ! vaapipostproc ! vaapih264enc ! h264parse ! rrmoqsink relay-url="http://127.0.0.1:4443" channel=test

Receiver:

gst-launch-1.0 -v \
  rrmoqsrc relay-url=https://127.0.0.1:4443 channel=test name=src \
  src.track ! queue  \
    ! vaapidecodebin  \
    ! vaapipostproc ! xvimagesink

ARM platform Jetson AGX Orin with Jetpack 6.0:

Simple sender with rrmoqbin

gst-launch-1.0 rrmoqbin relay-mode=local   relay-server-host-addr=https://192.168.0.15:4443   channel=test-video name=bin   sink_0::track-name=video   videotestsrc is-live=true ! nvvideoconvert !  nvv4l2h264enc idrinterval=1  ! h264parse !  queue ! video/x-h264,stream-format=avc,alignment=au ! bin.sink_0

Or if you have a camera use nvarguscamerasrc:

gst-launch-1.0 rrmoqbin relay-mode=external   relay-server-host-addr=https://127.0.0.1:4443   channel=test-video name=bin   sink_0::track-name=video   nvarguscamerasrc sensor-id=0 sensor-mode=3 ! nvvideoconvert !  nvv4l2h264enc ! queue ! bin.sink_0

Note: For this test we used an IMX477

Receiver:

gst-launch-1.0 -v rrmoqsrc relay-url=https://192.168.0.15:4443 channel=test-video name=src     src.video ! queue       ! h264parse        ! video/x-h264,stream-format=byte-stream,alignment=au       ! nvv4l2decoder        ! nvvideoconvert ! fakesink

Using web server

You can use a web server sample to subscribe to a video track this can allow to see video from a browser which can provide useful or serve as example.

Make sure have built the project with web features:

cargo build --features web
cd web-server/
npm install
npm run build

Launch a rrmoqbin with run-web-server=true to spawn the web server on the default port (5157):

gst-launch-1.0 videotestsrc is-live=true pattern=ball ! queue ! videoconvert ! queue ! x264enc tune=zerolatency speed-preset=ultrafast ! video/x-h264,profile=baseline ! bin.sink_0 rrmoqbin relay-mode=local name=bin  run-web-server=true sink_0::channel=web-test sink_0::track-name=video1

Then you can access the web server in http://127.0.0.1:5173/ which should look like this:

Web server
Web server MoQ

Enter the appropiate Relay URL and channel to watch video playback.

Or set a different port for the web server:

gst-launch-1.0 videotestsrc is-live=true  pattern=ball ! queue ! videoconvert  ! queue ! tee name=t ! queue ! x264enc tune=zerolatency speed-preset=ultrafast  ! video/x-h264,profile=baseline ! bin.sink_0 rrmoqbin relay-mode=external web-server-host-addr=http://127.0.0.1:5174   relay-server-host-addr=http://127.0.0.1:4443 name=bin   run-web-server=true sink_0::channel=cam1 sink_0::track-name=video1

Note: you can still use rrmoqsrc to subscribe to the same stream simultaneously.


Warning

If you don't see video when receiving in your web browser, check the H264 profile used. When receiving video with your web browser, you need to ensure the video’s profile is baseline.

With x264 encoder this can be done by adding baseline profile to the encoder caps as follows:

gst-launch-1.0 videotestsrc is-live=true pattern=ball ! queue ! videoconvert ! queue ! x264enc tune=zerolatency speed-preset=ultrafast ! video/x-h264,profile=baseline ! bin.sink_0 rrmoqbin relay-mode=local name=bin  run-web-server=true sink_0::channel=web-test sink_0::track-name=video1