Try Live Demo

In this blog post, we will learn how to stream SRT to an Ant media server and play it back using the WebRTC protocol. 

Streaming high-quality video content over the Internet requires a robust and reliable infrastructure. With the growing demand for real-time and low-latency video delivery, SRT (secure and reliable transport) and WebRTC have become industry-leading technologies. 

Ant Media Server provides a powerful platform to bridge these two technologies.

We will explore the steps required to easily ingest an SRT stream and play it back via WebRTC on Ant Media Server.

Ingesting SRT

While there are many different tools available for streaming SRT, in this post we’ll look at the most popular tools and technologies for streaming SRT.

Ingest SRT with OBS

1. Open OBS
2. click on the add button in the Sources tab and select Media Sources

8fUA30As1eq0QAAAAASUVORK5CYII=

3. Select a video file from your computer by hitting browse
4. Click on settings

bK9R1G925NEAAAAASUVORK5CYII=
5. In the stream tab add the URL in the below format
Make sure you replace IP_ADDRESS with the IP address of your Ant Media Server

URL FORMAT:

srt://IP_ADDRESS:4200/WebRTCAppEE/?streamid=WebRTCAppEE/stream1

6. Click Start Streaming.

AWoVNitNSuLbAAAAAElFTkSuQmCC

7. The SRT stream is now publishing into Ant Media Server.  Navigate to the bottom of the page to learn how to playback the published stream with WebRTC.

Ingest SRT with FFmpeg

Run the below FFMPEG command, replacing INPUT_FILE.mp4with the actual file you want to stream and the IP address of your ant media server

ffmpeg -re -i ./INPUT_FILE.mp4 -vcodec libx264 -profile:v baseline -g 60 -acodec aac -f mpegts srt://ant.media.server.address:4200?streamid=WebRTCAppEE/stream1

Ingest SRT with Gstreamer 

Make sure to replace INPUT_FILE.mp4 with the file you want to stream and AMS_IP_ADDRESS with your ant media server in the command

gst-launch-1.0 filesrc location=./INPUT_FILE.mp4 ! qtdemux ! decodebin ! x264enc tune=zerolatency ! mpegtsmux ! srtsink uri=srt://AMS_IP_ADDRESS:4200?streamid=WebRTCAppEE/stream1

Playing an SRT ingested stream with WebRTC

  1. navigate to AMS_IP:PORT/WebRTCAppEE/player.html
  2. enter the stream id of the published live stream
  3. hit the start playing button
  4. The application will establish a WebRTC connection with your Ant Media Server and play the stream.

AUKORL2yT0VSAAAAAElFTkSuQmCC


Usama Tahseen

Usama is a Software Engineer at Ant Media. His technical stack includes WebRTC, Gstreamer , FFmpeg , Python, Javascript, Node.js

chatsimple
Warning: Undefined array key "promocode" in /home/mirror.antmedia.io/public_html/wp-content/themes/hestia-child/footer.php on line 70