Encore – Video transcoding at its core

Choosing the appropriate level of video quality introduces an interesting dilemma for any public service broadcaster who operates and provides an online streaming service. On the one hand they want to produce the best possible experience for anyone watching their videos, but on the other hand they want to keep the amount of required bandwidth low to decrease costs. This particular predicament certainly applies to us at SVT as well, and it is a quandary we are constantly working to improve.

(Before I move on, since the notion of a Tekniksprint at SVTi has been covered somewhat extensively in earlier blog posts, for instance https://blogg.svt.se/svti/building-hbbtv-application-es7-react-redux/ , I will refrain from repeating that information in this text. I will say however, that it is a fantastic opportunity to engage in, and experiment through, new cross-team constellations where we can leverage each other’s strengths whilst simultaneously trying out new ideas.)

For the first biannual Tekniksprint of 2018 I joined a temporary team that was assembled following a convincing pitch by one of the members of the VideoCore-Team. Our goal was to achieve improvements to the one feature that is arguably at the heart (core if you will) of what we do, video quality. The initial idea was to create a convincing enough POC to eventually pave the way for our very own in-house transcoder, which could in time replace various expensive commercial software products. As it turned out however, we managed to create something far grander and it certainly surpassed our own expectations.

We call it: SVT Encore.

Encore is a fully functional, albeit far from complete, video transcoding solution that is able to inspect, ingest, organize, transcode, mux, demux, package and distribute digital media files.

That is to say: It can take videos and re-encode them into new videos.

A slightly more technical description is that Encore, at its core (see what I did there?), is a set of predefined logical procedures running command lines through a custom compilation of the ubiquitous FFMPEG framework. This function in turn is encapsulated within a flexible Node.js environment operating a stable BullQueue towards a custom Redis instance.

In its current form, Encore has the ability to import virtually any media file, regardless of stream layout, and transcode it into almost any format we want. It is able to analyse the media streams and adaptively apply filters and operations, such as deinterlacing and scaling, where appropriate. Likewise Encore has been programmed to handle a wide array of audio stream setups, and cleverly down-mix the various variations into formats better suited for streaming. To top it all off it is accompanied by a slick and simple GUI which has been streamlined enough to be usable even if the user knows nothing about video encoding.

  • “Hold on a second!”

A healthy but unappreciated sceptic might say.

  • “So it is just a glorified implementation of FFMPEG, what is the big deal?”

To which I would hopefully answer:

  • “No, it is so much more”

First off, Encore as a service is easy to scale thanks to the way the architecture is set up. For instance it is hardware agnostic, which means it will run on a myriad of readily available circuits. Furthermore, since all of the imported components are either open source or royalty free, we are able to extend the solution in whatever way we see fit. Simply put, if we want more capacity we buy more (relatively) cheap hardware.

Secondly, Encore has some formidable “SVT-magic” tricks up its sleeve. For instance, we have created a set of content specific parameters for the encoder, i.e. sub optimizing its operations, corresponding to different kinds of content. In addition, Encore also makes use of custom quantizer matrices to improve perceived visual quality. The latter example is currently quite unique seeing as the usage of such matrices is often considered counter productive in an age of adaptive quantizers.

So, what are the results? I think a couple of images will say more than a thousand words. To the right is Encore, and to the left is the current commercial solution we are using.

Finally, it is worth noting that we are very happy with the results. The flexibility of FFMPEG means that Encore is able to blow our current proprietary equipment out of the water, by a huge margin, when comparing visual quality. Having access to some very potent video encoders, such as x264 and x265, alongside a standard CLI, is the key here. We are hoping that we will be able to continue our work with Encore, further developing it towards a complete solution.