A “cheap” way to generate a 24/7 SRT live stream
Today me an my colleagues at Eyevinn joined the SRT Alliance, to contribute to the adoption of the open source video transport protocol that addresses the main challenges our clients face. And working with the SRT protocol to build applications that solves different use cases often requires a live source of some kind. It can quickly become very costly to have a live test stream running 24/7 as a source, so in this blog I will describe a more “cheap” way to setup a live test source.
Back in 2018 we developed a prototype or a proof-of-concept on how you could take a library of already transcoded and HLS packaged VOD files and by using a clever manifest manipulation technique a “fake” live HLS stream was generated, without requiring any additional CPU intensive media processing. We made this technology and concept available as open source and published the Channel Engine library.
Based on this library we have recently developed and launched a software component we call Consuo that implements this technology and deployed as a Docker containerized micro service. It has a basic API where you can create and manage schedules for these fake live HLS streams. In this example we will use Consuo to generate a live HLS stream from a library of already transcoded HLS assets. The HLS packages (manifest and segments) are stored on an S3 bucket which we have connected a Cloudfront CDN to. These HLS packages can be played as stand-alone and normal VOD files, for example: https://maitv-vod.lab.eyevinn.technology/VINN.mp4/master.m3u8
Then we create an Atom RSS feed with a list of these assets, for example: http://testcontent.eyevinn.technology/atom/feed-eyevinn.xml
In Consuo we create a channel that we call “atom” and enable the auto-populate configuration with a link to the created Atom RSS feed. This means that the auto scheduler in Consuo will randomly choose an asset from the Atom RSS feed and create events in the schedule. We now have a live HLS stream that can be played in an HLS player.
http://engine.demo.consuo.tv/live/master.m3u8?channel=atom
The next step is to take this HLS live stream that is generated by Consuo and transport it using SRT. For that we can use ffmpeg:
ffmpeg -fflags +genpts -re -i http://engine.demo.consuo.tv/live/master.m3u8?channel=atom -strict -2 -y -acodec copy -vcodec copy -f mpegts srt://<IP>:<PORT>?pkt_size=1316&mode=listener
Also available in our Docker container toolbox and called hls2srt which you find the source code for here: https://github.com/Eyevinn/toolbox
Then you have a cheap 24/7 live stream that you can connect any SRT capable device to or use with the SRT application you are developing. Consuo can be running either in your public cloud or on a computer at home. It has a low CPU footprint in comparison with live encoding, and the ffmpeg command above only copy data and does not do any media processing either.
If you have any further questions and comments on this blog drop a comment below or tweet me on Twitter (@JonasBirme). If you want to know more about Consuo and how to get a trial license key, contact sales@eyevinn.se.
Eyevinn Technology is the leading independent consultant firm specializing in video technology and media distribution, and proud organizer of the yearly nordic conference Streaming Tech Sweden.