Implement Live-to-VoD with the Bitmovin API

Written by:
February 22nd, 2017

Setup Live to VoD encoding ans storage for higher ROI

Get your VoD assets online immediately after the live event with Bitmovin Live-to-VoD. Decrease your encoding costs, reduce your hardware footprint and create a higher quality of experience for your users.

Live events have, and probably always will be one of the most marketable video experiences on any screen. Whether it is a football match, a rock concert or a live election speech, people want to watch it as it happens. “Live” is a great selling point but the very nature of live video creates a few weaknesses. For example, what if a user wants to rewind something to watch it again? What if they want to hit pause, so they can grab a beer from the fridge? What if their computer crashes and they miss the event completely?

In many livestreaming implementations, the data is lost as soon it is delivered, making the experience very one dimensional for the user. At Bitmovin we have just enabled our Live-to-VoD API for all customers, which not only allows you to give your customers control over their experience, but also creates a number of extra monetization opportunities that will help you to increase your ROI on live events.

Bitmovin live streaming was designed with the VoD workflow in mind from the very beginning. That is why generating VoD streams out of your live stream is as simple as making a few calls to our API. That means that as soon as your live event has finished you can monetize and deploy the VoD stream to your website and allow viewers to start watching the replay. It also creates opportunities to reuse the content while the event is still running, for example, promotional highlights for social media marketing, or “latest news” snippets.

Live Video to VoD with Bitmovin

Create VoD Manifests After the Live Event

The following examples can be used to implement your Live to VoD workflow. This should be setup in addition to the standard live streaming configuration explained here. It is as simple as just creating another MPEG-DASH and HLS manifest as the same encoded segments from the live stream can be re-used for the VoD stream. The following example will show how to create VoD manifests for MPEG-DASH and HLS from the whole live stream.

Create the VoD MPEG-DASH manifest

var manifestDash = bitmovin.Manifest.Dash.Create(new Dash
{
	Name = "MPEG-DASH VoD Manifest",
	ManifestName = "stream_vod.mpd",
	Outputs = new List<Encoding.Output> { manifestOutput }
});

Create the VoD HLS manifest

var manifestHls = bitmovin.Manifest.Hls.Create(new Hls
{
    Name = "HLS VoD Manifest",
    ManifestName = "stream_vod.m3u8",
    Outputs = new List<Encoding.Output> { manifestOutput }
});

Create a VoD manifest from your whole live stream
The period, adaptation sets, and fMP4 representations for MPEG-DASH are created exactly the same way as for the manifest of the live stream. The same holds for the media infos and stream infos for HLS. The difference when creating the VoD manifests is that instead of using its reference to start the live encoding, you directly call start to generate the VoD manifests in your defined output location:

bitmovin.Manifest.Dash.Start(manifestDash.Id);
bitmovin.Manifest.Hls.Start(manifestHls.Id);

After you started the manifest creation just wait until the manifests have been created and are uploaded to your storage:

var status = bitmovin.Manifest.Dash.RetrieveStatus(manifestDash.Id);
while (status.Status == Status.RUNNING)
{
    status = bitmovin.Manifest.Dash.RetrieveStatus(manifestDash.Id);
    Thread.Sleep(2500);
}

var status = bitmovin.Manifest.Hls.RetrieveStatus(manifestHls.Id);
while (status.Status == Status.RUNNING)
{
    status = bitmovin.Manifest.Hls.RetrieveStatus(manifestHls.Id);
    Thread.Sleep(2500);
}

Now you can playback the generated VoD manifest with your player as VoD stream, meaning you can directly seek to every position of the stream.

Trim Start and end for Your VoD Manifest

Usually you will start your live stream some time before the real live event starts and also have it running a few seconds or minutes after the event has finished. When creating the VoD stream you usually want to trim the start and end of the live stream so the VoD stream would only contain video of your real live event.

Of course this is also possible with our Live to VoD service. The previously generated VoD manifest of the whole livestream comes in handy when searching for the actual start and end of the live event. Note down the time that is shown in the player when your live event starts and ends. Let’s say the start is at 00:32:04 (1924 seconds) and the end is at 01:38:07 (5887 seconds).

When trimming the start and end from your live stream you need to provide the start segment and end segment when adding the fMP4 representation to the adaptation set. Given a segment length and the defined start and end times in seconds we can easily calculate the segment position with “time in seconds” divided by “segment length.

For the example above we would get the following start and end segment:

  • the start segment as 962 (1924 / 2) and
  • the end segment as 2944 (5887 / 2)

Please note that the start segment should be rounded down to the next integer and the end segment should be rounded up to the next integer.

With the start segment and end segment numbers we can create the trimmed VoD MPEG-DASH manifest by just setting this numbers in the fMP4 representation:

var manifestDash = bitmovin.Manifest.Dash.Create(new Dash
{
	Name = "MPEG-DASH Trimmed VoD Manifest",
	ManifestName = "stream_vod_trimmed.mpd",
	Outputs = new List<Encoding.Output> { manifestOutput }
});

// adding period and adaptation sets …

bitmovin.Manifest.Dash.Fmp4.Create(manifestDash.Id, period.Id, videoAdaptationSet.Id,
    new Manifest.Fmp4
    {
        Type = SegmentScheme.TEMPLATE,
        EncodingId = encoding.Id,
        MuxingId = videoFMP4Muxing1080p.Id,
        StartSegmentNumber = 962,
        EndSegmentNumber = 2944,
        SegmentPath = "video/1080p_dash"
    });
bitmovin.Manifest.Dash.Fmp4.Create(manifestDash.Id, period.Id, audioAdaptationSet.Id,
    new Manifest.Fmp4
    {
        Type = SegmentScheme.TEMPLATE,
        EncodingId = encoding.Id,
        MuxingId = audioFMP4Muxing.Id,
        StartSegmentNumber = 962,
        EndSegmentNumber = 2944,
        SegmentPath = "audio/128kbps_dash"
    });

For HLS we can also create the trimmed VoD HLS manifest with the start segment and end segment numbers by just setting this numbers in the media info for audio and stream info for video:

var manifestHls = bitmovin.Manifest.Hls.Create(new Hls
{
    Name = "HLS Trimmed VoD Manifest",
    ManifestName = "stream_vod_trimmed.m3u8",
    Outputs = new List<Encoding.Output> {manifestOutput}
});

var mediaInfo = new MediaInfo
{
    GroupId = "audio",
    Name = "English",
    Uri = "audio_vod_trimmed.m3u8",
    Type = MediaType.AUDIO,
    SegmentPath = "audio/128kbps_hls/",
    StreamId = audioStream.Id,
    MuxingId = audioTsMuxing.Id,
    EncodingId = encoding.Id,
    StartSegmentNumber = 962,
    EndSegmentNumber = 2944,
    Language = "en",
    AssocLanguage = "en",
    Autoselect = false,
    IsDefault = false,
    Forced = false
};
bitmovin.Manifest.Hls.AddMediaInfo(manifestHls.Id, mediaInfo);

bitmovin.Manifest.Hls.AddStreamInfo(manifestHls.Id, new StreamInfo
{
    Uri = "video_1080_vod_trimmed.m3u8",
    EncodingId = encoding.Id,
    StreamId = videoStream1080p.Id,
    MuxingId = videoTsMuxing1080p.Id,
    StartSegmentNumber = 962,
    EndSegmentNumber = 2944,
    Audio = "audio",
    SegmentPath = "video/1080p_hls/"
});

Create VoD Manifests During the Live Event

With the Bitmovin API you can already create VoD clips from your live stream while it is still running. That is useful if you already want to share specific scenes before the event is finished. Another common use-case is that you have a linear program and want to extract specific shows as VoD assets. The workflow for creating VoD streams out of your live stream while it is still running is exactly the same as discussed above. Just provide the start segment and end segment number when creating the manifest and you are done.

The fastest way to get started with Live-to-VoD using the Bitmovin API is to request an API key and review our tutorial section for instructions. Our live streaming tutorial will provide you everything you need to get up and running quickly. If you are looking for an enterprise or customized solution, please contact us to arrange a demonstration or meeting to discuss your specific needs.

Simple Share Buttons