DEV Community

Cover image for Breaking in to a Live Stream on a Virtual Channel Powered by the Eyevinn Channel Engine
Nicholas Frederiksen for Eyevinn Video Dev-Team Blog

Posted on • Updated on

Breaking in to a Live Stream on a Virtual Channel Powered by the Eyevinn Channel Engine

In the early days, the term "breaking" referred to a technical procedure used inside a broadcasting studio. It was, put simply, a term used for when studios would interrupt a broadcast feed, with most usually, a live feed to some urgent news reporting.

This procedure has for a while been something we would like our virtual Channel Engine to one day simulate.
Fortunately, that day has come. In this blog post, I write about the newest feature coming to the Channel Engine, and about a Breaking News API build to best demonstrate this feature.

I am going to assume that you are at least somewhat familiar with the Eyevinn Channel Engine. If you aren't, then I'd recommend reading this article first.

Switching the feed abruptly? How does it do this?
Continue to the next chapter if you want to know, and if you just want to jump straight in to the demo, then skip to the last chapter.

Channel Engine V3

The latest release candidate, V3, for the Channel Engine includes a new major feature. The feature for the possibility to mix in a true live stream in a Channel Engine powered linear channel (VOD2Live) according to a set schedule. Just as a reminder, know that this feature is currently in Beta.

To achieve this, Channel Engine has gotten some new internal components, see the red boxes in the figure below.
Live-mix overview diagram
These components are what make this feature possible, and the following text provides a short overview of what they are.

Session-Live

This component is responsible for generating the customized live source manifests that will better match the context of the Channel Engine stream.

It also handles all the HLS manifest manipulations (stitching) necessary to have the live stream mix in properly with the VOD2Live stream. Resulting in a smooth overlapping of segments.

There is an internal playhead in this component that will make sure to always fetch the latest live source manifest at a given time interval.

However, before the Session-Live component can start its job, it will need two things. Segments from the latest media sequence on the VOD2Live stream, and a live source URI.

This is information that it receives from the next component we are going to talk about.

Stream Switcher

This component is a form of gate and essentially decides from what stream (VOD2Live or true live) the virtual channel should get the manifests from and return to clients, and its decision is based on an event schedule.

The schedule, in this sense, is just a list of JSON objects with some essential properties such as start time, ending time, URI, etc.

To learn about the specifics check out the "Live Mixing (BETA)" section in the Channel Engine V3 README

The Stream Switcher will, on a set frequency, obtain and inspect the schedule's content, and if it finds a JSON object whose event start time is now, then it will commence a switching operation where it will send the necessary data (live URI and VOD2Live segments) to the Session-Live component.

From there, the Session-Live component can generate proper manifests. Manifests that the Stream Switcher, from now on, will hand out to all client requests.

And as you'd expect, after a while, when the ending time of the event has been reached, the Stream Switcher will commence a switch-back operation where afterward it will start returning VOD2Live manifests to the clients once again.

Now, we have yet to disclose where the Stream Switcher actually obtains its schedule from. This brings us to our next and last new component.

Stream Switch Manager

This component holds the logic for managing and returning a schedule list to the Stream Switcher. This component and can be customized much like a Channel Engine Asset Manager component. It is a class that needs to be implemented following a certain interface.

Again, to learn about the specifics check out the "Live Mixing (BETA)" section in the Channel Engine V3 README

How does one populate the schedule list with events? Well, that's up to the implementer. It can be done through external API gateways or directly in the switch manager itself. The only requirement is that it has a getSchedule() function that returns a list of Event JSONs.

Extra Features

Here are some neat things that the breaking-in feature also does.
The switch doesn't only limit you to break in with a live stream, you can also break in with a VOD, allowing for a quicker way to broadcast prerecorded content on the fly. To do this one just needs to change the type property of the Event JSON.

Now if the event source gets compromised, e.g URI becomes unreachable, then the Stream Switcher will handle it by simply switching back to the VOD2Live stream, ensuring that the clients are continuously receiving content.

We would also like to mention that this feature is also compatible with the other Channel Engine feature which is also in Beta, the High Availability feature. Bringing you redundancy, strong up times, and the benefits of load balancers.

More on this feature can be found in the "High Availability" section in the Channel Engine V3 README

Delimitations

As mentioned, this feature is currently in Beta and has some delimitation in what it can do. In its current version, in order to operate properly, it must follow these restrictions.

Restrictions

  • Uniform transcoding. Segment duration must match (or be within a margin ~ ±2 sec) across all planned content (VOD and LIVE).
    Note: Sequence length can be customized in Channel Engine, but not on the fly.

  • Must not schedule a switch into or out of an Ad break on the VOD2Live stream.
    Note: This will be addressed in the next update.

  • Related to the previous point. The Live event must not include ad breaks in it. Ads can be played but the HLS cue-tags will be left out of the manifest.

  • Must not schedule back-to-back Live events, this is not allowed at the moment and could possibly cause issues.

Trying It Out with The Breaking News API

Now for the exciting part, testing it out yourself.
The Channel Engine V3 is only responsible for stitching in the true Live stream with the VOD2Live stream. The responsibility for choosing what specific Live stream it should stitch in and when it should stitch it falls to the Stream Switch Manager and the scheduling service.
Breaking News API Swagger page
A Breaking News API was built as a simple reference implementation on how you can create your own stream switch manager to then use with this Channel Engine V3 feature.

In brief, the Breaking News API has a /breaking POST endpoint where you can append an Event JSON (as mentioned earlier) to a channel's schedule.

A Proof-of-Concept nodeJs service has been built that will spin up a simple instance of the Channel Engine (which will loop over the same VOD over and over) and the Breaking News API to demonstrate the feature in a convenient way.

You will find the POC service here on GitHub

Just simply clone the repository, and follow the documentation, you can either run the service with docker or just with a good old npm install and npm start.

Once you have it up and running. View the virtual channel stream at:
https://web.player.eyevinn.technology/?manifest=http%3A%2F%2Flocalhost%3A8000%2Flive%2Fmaster.m3u8%3Fchannel%3D1

Then to populate the event schedule with an Event JSON, I'd recommend for you to go to the Swagger documentation page at: http://localhost:8001/api/docs
where you can execute a POST call with some already predefined values that should trigger a live stream break-in at the soonest possible moment. Of course, you can always set the start and end time to something else if you want to.

This is what you can expect
expect_1

expect_2


Eyevinn Technology is the European leading independent consultancy firm specializing in video technology and media distribution.

If you need assistance in the development and implementation of this, our team of video developers are happy to help out. If you have any questions or comments just drop us a line in the comments section to this post.

Discussion (0)