Skip to content

Preparing Content for livesim2

Torbjörn Einarson edited this page Oct 7, 2024 · 2 revisions

Input profile

At startup, livesim2 tries to scan and import all DASH VoD assets it finds under vodroot.

These VoD assets need to have MPDs in isoff-live profile with individual files for the init segment and each media segment.

If a VoD asset is not accepted, there should be log lines about it. See the Trouble-shooting section for more info.

MPD Restrictions

Currently, livesim2 can import VoD assets with MPDs using either

  • SegmentTemplate with $Number$
  • SegmentTemplate with SegmentTimeline with $Time$

There is a further restriction that the SegmentTemplate must be on the AdaptationSet level, and not inside a Representation. The SegmentTemplate should ideally use the $RepresentationID$ pattern like

    <AdaptationSet id="0" contentType="video" mimeType="video/mp4" width="640" height="360" frameRate="30/1" segmentAlignment="true" par="16:9">
      <SegmentTemplate timescale="15360" initialization="V300/init.mp4" media="V300/$Time$.m4s" startNumber="1">
          <SegmentTimeline>
            <S t="0" d="122880" r="8"/>
          </SegmentTimeline>
      </SegmentTemplate>
      <Representation id="V300" bandwidth="308820" codecs="avc1.64001e"  sar="1:1"/>
    </AdaptationSet>

The attributes contentType and mimeType should be inside the AdaptationSet, but will be transferred from Representation-level if only present there. In the latter case, it is required that there are no conflicting values between representations.

There may be more than one MPD per asset. It is important that they are all consistent. All requests for live content uses one of the provided VoD MPDs as starting point in the URL.

Segment duration

The video segments should have a fixed duration for all segments, while audio may have any duration. Livesim2 will, if necessary, resegment the audio segments so that they start at the same time or right after the video segments. If possible, it is preferable that all video and audio segments have exactly the same duration like 1.92s for 50fps video and 48kHz AAC audio. Subtitle segments are not resegmented and should have exactly the same duration as the video segments.

Edit lists

CMAF allows for edit lists that shift all timestamps by a fixed amount. Livesim2 does not yet have support for this, but there is an issue for supporting a shift of audio timestamps. A reason for this is to support the audio test streams from CTA-WAVE.

Sidx boxes

There should be no sidx boxes in the segments, since they are not updated.

Encryption

Encryption on the fly

Livesim2 supports DASH-IF ECCP (Enchanced ClearKey Content Protection) including on-the-fly encryption of video and audio. The encryption can be in either "cenc" or "cbcs" format. At startup, init segments with encryption boxes are generated.

Pre-encrypted content

Pre-encrypted content is to a big extent not tested, but in Issue 23 a Widevine-encrypted VoD video sequence was successfully made into a live stream using liesim2.

There are couple of points that may require more study and changes to the code

  1. Unknown MPD elements like less frequent ContentProtection headers may be dropped by the MPD parser
  2. Audio resegmentation if the audio segment durations do not match video perfectly. This resegmentation does not handle encryption boxes properly.

Pre-encrypted content is detected at the initial content parsing, and no encrypted init segments are generated.

It should be noted that some packagers, like shaka-packager, by default leaves the first segment(s) of unencrypted, even when encrypting the asset. This is for faster startup of the VoD asset, but is not good for looping the content.

Shaka-packager settings

To avoid a non-encrypted start and sidx boxes in the segments, the following two shaka-packager options should be used:

  --clear_lead 0 --nogenerate_sidx_in_media_segments

Trouble-shooting

The first step is to verify that the asset could be read properly. For this, one can look at the initial log output as the vodroot tree of assets is scanned and parsed as part of the startup.

Warnings like:

{"time":"2024-10-02T08:17:05.726916+02:00","level":"WARN","msg":"Asset loading problem. Skipping","asset":"enc/live.mpd","err":"no SegmentTemplate in adaptation set"}
{"time":"2024-10-02T08:17:05.726967+02:00","level":"WARN","msg":"Asset consolidation problem. Skipping","error":"setReferenceRep: no video or audio representation found"}

indicate that an asset has not been loaded. In this case, it gives an indication that the SegmentTemplate is not found in the AdaptationSet.

All assets that have been loaded should be visible in the listings available from the server at /assets and /vod. For an example, look at the public livesim2 deployment.