Using ffmpeg and SRT to Transport Video Signal to the Cloud

Transporting the video signal to a public cloud often means transportation over Internet
RTMP is the simplest option available today
A “bridge” from RTMP to Multicast may be required for some of the live transcoding softwares
Principle of using commercial options such as Zixi to transfer MPEG-TS over Internet

Secure Reliable Transport

SRT is an open source video transport protocol and technology stack backed by the SRT Alliance. Today the SRT Alliance consists of over 40 vendors including Haivision, Wowza, Teradek, and many more. The standard is open and available to anyone who wants to implement it and SRT is also open source which means that the software (technology stack) required to implement SRT is available from a public repository and there are no fees to incorporate the technology into any device or service.

Compiling SRT with ffmpeg

Havision, one of the founders of SRT, provides an open source SDK to enable SRT support in your software. This is the SDK that we will compile and include in our ffmpeg build.

$ git clone https://github.com/Haivision/srt.git
$ cd srt
$ ./configure
$ make && make install
$ apt-get install libssl-dev tclsh
$ ./configure --enable-libsrt ...
Using SRT to transport an MPEG-TS video stream over the Internet

SRT Tx

To setup an SRT Transmitter that takes an MPEG-TS video stream and transmit it to an SRT Receiver over the Internet you start ffmpeg with the following command.

$ ffmpeg -fflags +genpts -listen 1 -re -i udp://239.0.0.1:1234?pkt_size=1316 -acodec copy -vcodec copy -strict -2 -y -f mpegts srt://0.0.0.0:9998?pkt_size=1316&mode=listener
$ ffmpeg -fflags +genpts -listen 1 -re -i udp://239.0.0.1:1234?pkt_size=1316 -acodec copy -vcodec copy -strict -2 -y -f mpegts srt://192.168.1.42:9998?pkt_size=1316
$ docker run --rm -p 9998:9998/udp eyevinntechnology/toolbox-srttx --inputtype=mpegts --passthrough --listener 239.0.0.1:1234 0.0.0.0:9998

SRT Rx

To setup an SRT Receiver with ffmpeg that outputs the incoming stream over a multicast network you start ffmpeg with this command.

$ ffmpeg -re -i srt://0.0.0.0:9998?pkt_size=1316&mode=listener -vcodec copy -acodec copy -strict -2 -y -f mpegts udp://239.0.0.2:1234?pkt_size=1316
$ ffmpeg -re -i srt://192.168.1.19:9998?pkt_size=1316 -vcodec copy -acodec copy -strict -2 -y -f mpegts udp://239.0.0.2:1234?pkt_size=1316
Generate an MPEG-TS stream to transport over SRT and view in VLC
$ docker run --rm -v $PWD:/mnt eyevinntechnology/toolbox-loopts --withtc testfile.mp4 "srt://192.168.1.2:9998?pkt_size=1316"
$ docker run --rm -p 9998:9998/udp eyevinntechnology/toolbox-srtrx --listener 0.0.0.0:9998 239.0.0.3:1234
udp://@239.0.0.3:1234

Using OBS and SRT

The SRT Transmitter in the toolbox can also take an RTMP stream and transport using SRT to an SRT Receiver. Spin up the SRTTx Docker container on the computer running for example OBS or Wirecast and you can use SRT instead of RTMP to transfer the signal to the cloud.l

Use SRT with OBS instead of RTMP
$ docker run --rm -p 1935:1935 eyevinntechnology/toolbox-srttx --passthrough --inputtype=rtmp input_stream 192.168.1.6:9998
$ docker run --rm -p 9998:9998/udp eyevinntechnology/toolbox-srtrx --listener 0.0.0.0:9998 239.0.0.3:1234
udp://@239.0.0.3:1234

Summary

In this article I have shown how you with ffmpeg can transport an MPEG-TS stream over the Internet using SRT as the protocol. I personally believe that we in a not so distant future will see more support for SRT on both the Sender and Receiver side as the SDK is available as open source and can easily (without a fee) be incorporated in the software. I would assume that Wirecast or OBS will soon have support for SRT given the number of companies now joining the SRT Alliance.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Eyevinn Technology

Eyevinn Technology

925 Followers

We are consultants sharing the passion for the technology for a media consumer of the future.