<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Orry Verducci on Medium]]></title>
        <description><![CDATA[Stories by Orry Verducci on Medium]]></description>
        <link>https://medium.com/@orryv?source=rss-cb1f09b54680------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mbgs-gdrKgS-JEOYY8IfoA.png</url>
            <title>Stories by Orry Verducci on Medium</title>
            <link>https://medium.com/@orryv?source=rss-cb1f09b54680------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 13:53:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@orryv/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Broadcast grade live streaming with GStreamer and Restreamer]]></title>
            <link>https://medium.com/@orryv/broadcast-grade-live-streaming-with-gstreamer-and-restreamer-4b8cc8f05bdb?source=rss-cb1f09b54680------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b8cc8f05bdb</guid>
            <category><![CDATA[broadcasting]]></category>
            <category><![CDATA[video-encoding]]></category>
            <category><![CDATA[live-streaming]]></category>
            <category><![CDATA[ffmpeg]]></category>
            <category><![CDATA[broadcast-technology]]></category>
            <dc:creator><![CDATA[Orry Verducci]]></dc:creator>
            <pubDate>Tue, 22 Aug 2023 11:53:05 GMT</pubDate>
            <atom:updated>2023-08-22T11:53:05.542Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*smBrvtRiqTghUR5d0OtYEw.png" /><figcaption>Ideal World YouTube stream as viewed in Restreamer</figcaption></figure><p>In the final few months of broadcasting at Ideal World TV, we embarked on a project to replace our ageing video encoding and streaming infrastructure with a modern solution. The goal was simple: to improve the quality of our live streams, give us the ability to stream in portrait (9:16) to the social media networks and to increase the number of streams we could run simultaneously.</p><p>As I like a challenge I made the decision early on to not purchase new hardware or commercial software solutions, but to instead build our new solution using open source software running on our existing infrastructure.</p><h3>The setup</h3><p>We decided to create a low latency, high bitrate ‘mezzanine’ encode of each output from our playout facility. These were 50 Mbps H.264 streams, encoded in our native 1080i50 production and playout format, distributed internally as UDP multicast MPEG Transport Streams.</p><p>For our public live streams we used <a href="https://datarhei.com/">Restreamer</a> to transcode the mezzanine streams and send them to each of the platforms we streamed on.</p><p>All of this was run on our existing encoder hardware, which were two standard Supermicro 40 core Xeon servers. These originally were running an out of support commercial ‘appliance’ software solution, using <a href="https://www.blackmagicdesign.com/products/decklink">Blackmagic Decklink SDI</a> cards as their video inputs.</p><p>The servers were wiped and re-imaged with Ubuntu 22.04 with Docker installed, setup as duplicates of each other for redundancy. Initially we kept the Decklink SDI cards. However, as our playout facility natively used SMPTE ST 2110 IP streams instead of SDI we replaced them with the new Decklink IP cards as they became available, allowing us to free up some of our IP/SDI conversion gateways.</p><h3>The mezzanine streams</h3><p>Gstreamer was chosen as the encoding software for the mezzanine streams. Usually FFmpeg would be my tool of choice, however as the mezzanine encodes and Restreamer would be running on the same server I needed to make the streams available as both unicast TCP streams (for use locally by Restreamer) and as multicast UDP streams (for use by our video on demand workflow). I found Gstreamer’s pipeline workflow and its tcpserversink output to be ideal for this situation.</p><p>Each encode ran in its own Gstreamer instance, running within a Docker container with host networking. We used the <a href="https://hub.docker.com/r/restreamio/gstreamer">GStreamer images built by restream.io</a>, however these came without the C++ standard library as required by Blackmagic’s drivers. So to use Decklink inputs we had to assemble our own image with restream.io’s image as a base and libc++1 installed on top, which we built with the following Dockerfile:</p><pre>FROM restreamio/gstreamer:x86_64-latest-prod<br><br>RUN export DEBIAN_FRONTEND=&quot;noninteractive&quot; &amp;&amp; \<br>    apt-get update &amp;&amp; apt-get -y --no-install-recommends install libc++1 &amp;&amp; \<br>    rm -rf /var/lib/apt/lists/*</pre><p>With that built, we could launch Gstreamer with the following command to encode the Decklink input as a H.264 stream, and split the output to both a UDP stream and a TCP server:</p><pre>gst-launch-1.0 decklinkvideosrc device-number=0 mode=1080i50 video-format=8bit-yuv drop-no-signal-frames=true output-afd-bar=true ! videoconvert ! &quot;video/x-raw, width=1920, height=1080, format=I420, colorimetry=bt709, framerate=25/1, interlace-mode=interleaved&quot; ! x264enc bitrate=30000 interlaced=true tune=zerolatency speed-preset=superfast key-int-max=25 ! queue max-size-time=3000000000 ! mpegtsmux alignment=7 name=mux decklinkaudiosrc device-number=0 ! fdkaacenc bitrate=256000 ! queue max-size-time=3000000000 ! mux. mux. ! tee name=split ! queue ! udpsink port=5000 host=&lt;put ip here&gt; bind-address=&lt;put ip here&gt; split. ! queue ! tcpserversink host=&lt;put ip here&gt; port=6001</pre><p>To use this command yourself you will need to replace `&lt;put ip here&gt;` with the IP address of the muticast group to be used, and the IP addresses of the host network adapters to bind to. You will also need to set the Decklink device numbers. We used 239.10.x.x for the muticast groups, with the first ‘x’ designating the server and the second ‘x’ designating the stream number (e.g. 239.10.1.1 for stream 1 from server 1). For the TCP server we incremented the port number for each stream.</p><p>We used Docker Compose to spin up all the GStreamer containers together with their required commands and settings. The final Compose file for the mezzanine encoders looked something very similar to this:</p><pre>services:<br><br>  encoder1:<br>    image: my-org/gstreamer:latest<br>    restart: unless-stopped<br>    network_mode: host<br>    environment:<br>      TZ: Europe/London<br>    volumes:<br>      - /usr/lib/libDeckLinkAPI.so:/usr/lib/libDeckLinkAPI.so:ro<br>      - /usr/lib/libDeckLinkPreviewAPI.so:/usr/lib/libDeckLinkPreviewAPI.so:ro<br>    devices:<br>      - /dev/blackmagic:/dev/blackmagic<br>    command: gst-launch-1.0 decklinkvideosrc device-number=0 mode=1080i50 video-format=8bit-yuv drop-no-signal-frames=true output-afd-bar=true ! videoconvert ! &quot;video/x-raw, width=1920, height=1080, format=I420, colorimetry=bt709, framerate=25/1, interlace-mode=interleaved&quot; ! x264enc bitrate=30000 interlaced=true tune=zerolatency speed-preset=superfast key-int-max=25 ! queue max-size-time=3000000000 ! mpegtsmux alignment=7 name=mux decklinkaudiosrc device-number=0 ! fdkaacenc bitrate=256000 ! queue max-size-time=3000000000 ! mux. mux. ! tee name=split ! queue ! udpsink port=5000 host=239.10.1.1 bind-address=192.168.1.2 split. ! queue ! tcpserversink host=192.168.1.2 port=6001<br><br>  encoder2:<br>    image: my-org/gstreamer:latest<br>    restart: unless-stopped<br>    network_mode: host<br>    environment:<br>      TZ: Europe/London<br>    volumes:<br>      - /usr/lib/libDeckLinkAPI.so:/usr/lib/libDeckLinkAPI.so:ro<br>      - /usr/lib/libDeckLinkPreviewAPI.so:/usr/lib/libDeckLinkPreviewAPI.so:ro<br>    devices:<br>      - /dev/blackmagic:/dev/blackmagic<br>    command: gst-launch-1.0 decklinkvideosrc device-number=1 mode=1080i50 video-format=8bit-yuv drop-no-signal-frames=true output-afd-bar=true ! videoconvert ! &quot;video/x-raw, width=1920, height=1080, format=I420, colorimetry=bt709, framerate=25/1, interlace-mode=interleaved&quot; ! x264enc bitrate=30000 interlaced=true tune=zerolatency speed-preset=superfast key-int-max=25 ! queue max-size-time=3000000000 ! mpegtsmux alignment=7 name=mux decklinkaudiosrc device-number=1 ! fdkaacenc bitrate=256000 ! queue max-size-time=3000000000 ! mux. mux. ! tee name=split ! queue ! udpsink port=5000 host=239.10.1.2 bind-address=192.168.1.2 split. ! queue ! tcpserversink host=192.168.1.2 port=6002</pre><h3>Streaming to the platforms</h3><p>Restreamer was chosen as the tool of choice to take the mezzanine streams, format and transcode them, and output them to the various platforms we streamed to. Restreamer is built on top of FFmpeg, with an intuitive web interface from which operators can setup streams and individually add and remove outputs to various platforms, making it ideal for the job.</p><p>As with Gstreamer, Restreamer was run within a Docker container alongside the mezzanine encode instances using the <a href="https://hub.docker.com/r/datarhei/restreamer">official images</a>. Once again Docker Compose was used to spin up Restreamer alongside the Gstreamer instances using this Compose file:</p><pre>services:<br><br>  server:<br>    image: &quot;datarhei/restreamer:latest&quot;<br>    restart: unless-stopped<br>    environment:<br>      TZ: Europe/London<br>    ports:<br>      - &quot;80:8080&quot;<br>      - &quot;1935:1935&quot;<br>      - &quot;1936:1936&quot;<br>      - &quot;6000:6000/udp&quot;<br>    volumes:<br>      - config:/core/config<br>      - data:/core/data<br><br>volumes:<br><br>  config:<br>  data:</pre><p>Restreamer was run on both servers with nearly the same configuration, the only difference being that the first server was set to stream to the main stream URL’s, and the second server was set to stream to the backup’s (where supported by the platform).</p><h4>24/7 channel streams</h4><p>For both of our channels, Ideal World and Ideal Extra, we setup two streams each in Restreamer.</p><p>The first was set up as a 1080p50 8 Mbps H.264 stream for delivery to the streaming platform used by our website and our smart TV apps. For this stream Restreamer was configured to deinterlace the input with full motion to 50 frames per second and re-encode it.</p><p>The second was set up as a 1440p60 16 Mbps H.264 stream for delivery to YouTube. Similar to the first, Restreamer was configured to deinterlace and re-encode by the stream, but in addition it was also set to scale it up to 2560x1440 and standards convert it from 50 fps to 60 fps.</p><p>I chose to do this to work around and take advantage of some of the quirks of the YouTube Live platform. Currently YouTube only supports two frame rates for live streams, 30 fps and 60 fps. 50 fps streams are converted down by YouTube to 30 fps, so the standards convert to 60 fps is necessary to make YouTube use the higher frame rate and maintain full motion. Many non-US broadcasters, at the time of writing, stream to YouTube in 25 fps (converted by the platform to 30 fps), with noticeably jerky streams as a result, so the choice to stream at 60 fps greatly improved our stream quality compared to others. YouTube Live also currently chooses a higher quality encode workflow for streams with resolutions greater than 1920x1080, so I also chose to upscale to 1440p to take advantage this.</p><h4>Social media streams</h4><p>In addition to the continuous streams of our channels, Restreamer was used for ‘pop up’ streams to Facebook, Instagram and TikTok. Restreamer’s web UI made it easy for our operators to put in the stream keys for each of these streaming events, and switch the streams on before the event and back off after.</p><p>These streams were setup very similarly to the continuous streams of our channels, albeit as only a single stream. But they were also configured to rotate our native 16:9 (landscape) production format to 9:16 (portrait) as required by the social media platforms, which once again Restreamer made really easy.</p><h3>The end result</h3><p>This setup was put in to production, and all our streams switch over to it, at the start of 2023. It proved to be extremely reliable and versatile, and served us well up to the closure of our services in July 2023. It would have happily run for much longer, and indeed that was the original plan, but sadly other factors prevented that.</p><p>Some of the requirements for this project also resulted in upstream improvements to the Restreamer project. Support for <a href="https://ffmpeg.org/ffmpeg-filters.html#bwdif-1">FFmpeg’s bwdif deinterlacing filter</a> was added following a request to Restreamer’s maintainers, adding high quality deinterlacing support to the software. I’ve also contributed a change to add support for <a href="https://ffmpeg.org/ffmpeg-filters.html#framerate">FFmpeg’s framerate filter</a>, which carries out standards conversion by interpolating new frames instead of duplicating/dropping frames. This has not yet been merged in to the project so it has not yet made available for everyone, but it is available as a <a href="https://github.com/datarhei/restreamer-ui/pull/38">pull request</a> and I hope it will be merged soon.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b8cc8f05bdb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>