Skip to content

Commit

Permalink
[docs] Updated GStreamer receive UDP command to ommit audio quality p…
Browse files Browse the repository at this point in the history
…roblems. (#630)
  • Loading branch information
brzep authored Jul 18, 2024
1 parent 9fa38a5 commit 4bedea0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
18 changes: 13 additions & 5 deletions docs/pages/guides/deliver-input.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ ffmpeg -re -i path_to_file -vn -c:a libopus -f rtp rtp://127.0.0.1:9001?rtcpport

#### GStreamer

Stream audio and video from a MP4 file over RTP TCP:
Stream audio and video from a MP4 file over RTP:
- video to `127.0.0.1:9001`
- audio to `127.0.0.1:9002`

Using TCP:
```bash
gst-launch-1.0 filesrc location=path_to_file.mp4 ! qtdemux name=demux \
! demux.video_0 ! queue ! h264parse ! rtph264pay config-interval=1 \
Expand All @@ -71,12 +72,19 @@ gst-launch-1.0 filesrc location=path_to_file.mp4 ! qtdemux name=demux \
! "application/x-rtp,payload=97" ! rtpstreampay ! tcpclientsink host=127.0.0.1 port=9002
```

- `"application/x-rtp,payload=97"`/`"application/x-rtp,payload=97"` - Compositor detects audio stream based on payload type. It needs
- `"application/x-rtp,payload=97"`/`"application/x-rtp,payload=97"` - Compositor detects audio stream based on payload type. It needs
to be set to 96 for video and 97 for audio.
- `decodebin ! audioconvert ! audioresample ! opusenc` - Transcode audio (most likely from AAC) from MP4 file into Opus. If you know
- `decodebin ! audioconvert ! audioresample ! opusenc` - Transcode audio (most likely from AAC) from MP4 file into Opus. If you know
what format is inside you can simplify this part.
- Compositor supports multiplexing audio and video stream on the same port, but it is hard to create a GStreamer pipeline that demuxes
- Compositor supports multiplexing audio and video stream on the same port, but it is hard to create a GStreamer pipeline that demuxes
audio and video tracks converts them to RTP and multiplex them on the same port.

To stream over UDP replace `rtpstreampay ! tcpclientsink host=127.0.0.1 port=9002` with <nobr>`udpsink host=127.0.0.1 port=9002`</nobr>.
Using UDP:
```bash
gst-launch-1.0 filesrc location=path_to_file.mp4 ! qtdemux name=demux \
! demux.video_0 ! queue ! h264parse ! rtph264pay config-interval=1 \
! "application/x-rtp,payload=96" ! udpsink host=127.0.0.1 port=9001 \
! demux.audio_0 ! queue ! decodebin ! audioconvert ! audioresample ! opusenc ! rtpopuspay \
! "application/x-rtp,payload=97" ! udpsink host=127.0.0.1 port=9002
```
Additionally, you can use the same port for video and audio.
20 changes: 11 additions & 9 deletions docs/pages/guides/receive-output.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,25 @@ ffmpeg -protocol_whitelist "file,rtp,udp" -i output.sdp out.mp4

#### GStreamer

Receive RTP stream over TCP by connecting to `127.0.0.1:9001`. Play both audio and video streams using `autovideosink`
Receive RTP stream on port `127.0.0.1:9001`. Play both audio and video streams using `autovideosink`
and `autoaudiosink`.

Connecting over TCP:
```bash
gst-launch-1.0 rtpptdemux name=demux \
tcpclientsrc host=127.0.0.1 port=9001 ! \"application/x-rtp-stream\" ! rtpstreamdepay ! demux. \
tcpclientsrc host=127.0.0.1 port=9001 ! \"application/x-rtp-stream\" ! rtpstreamdepay ! queue ! demux. \
demux.src_96 ! \"application/x-rtp,media=video,clock-rate=90000,encoding-name=H264\" ! queue \
! rtph264depay ! decodebin ! videoconvert ! autovideosink \
demux.src_97 ! \"application/x-rtp,media=audio,clock-rate=48000,encoding-name=OPUS\" ! queue \
! rtpopusdepay ! decodebin ! audioconvert ! autoaudiosink
```

To use UDP instead replace
```
tcpclientsrc host=127.0.0.1 port=9001 ! \"application/x-rtp-stream\" ! rtpstreamdepay
```
with
```
udpsrc port=9001 ! \"application/x-rtp\"
Using UDP:
```bash
gst-launch-1.0 rtpptdemux name=demux \
udpsrc port=9001 ! \"application/x-rtp\" ! queue ! demux. \
demux.src_96 ! \"application/x-rtp,media=video,clock-rate=90000,encoding-name=H264\" ! queue \
! rtph264depay ! decodebin ! videoconvert ! autovideosink \
demux.src_97 ! \"application/x-rtp,media=audio,clock-rate=48000,encoding-name=OPUS\" ! queue \
! rtpopusdepay ! decodebin ! audioconvert ! autoaudiosink sync=false
```

0 comments on commit 4bedea0

Please sign in to comment.