Content Templates

The role of content templates in ew-vod2cbm

Contents templates are used in ew-vod2cbm to specify the output segmentation and tracks of a channel, but also serve as measures to check if asset entries in a schedule are compatible with the channel. They are further used to generate the manifest and playlist media data properties as well as the media init segments. Therefore, bitrate, resolution, frame rate, video parameter sets, number audio channels are included in the template. The assets do not need to have exactly the same parameter values, but are allowed to vary as described later.

The generally preferred way of creating content templates, is to use ew-content-template-tool, described below.

JSON Schema for Content Template

The JSON schema of the content template contains core parameters of the content_info.json schema, and some additional parameters for bitrate matching.

It can contain variants of video, audio, and subtitles as signaled in the media_type field. The variant array can contain multiple variants of each type. The table below the schema shows the required parameters for each media type.

{
    "type": "object",
    "properties": {
        "version": {
            "type": "string"
        },
        "constant_gop_duration_ms": {
            "type": "integer"
        },
        "variants": {
            "type": "array",
            "items": [
                {
                    "type": "object",
                    "properties": {
                        "media_type": {
                            "type": "string"
                        },
                        "subtype": {
                            "type": "string"
                        },
                        "name": {
                            "type": "string"
                        },
                        "bitrate": {
                            "type": "integer"
                        },
                        "width": {
                            "type": "integer"
                        },
                        "height": {
                            "type": "integer"
                        },
                        "sample_aspect_ratio": {
                            "type": "string"
                        },
                        "picture_aspect_ratio": {
                            "type": "string"
                        },
                        "scan_type": {
                            "type": "string"
                        },
                        "sps": {
                            "type": "string"
                        },
                        "pps": {
                            "type": "string"
                        },
                        "codec": {
                            "type": "string"
                        },
                        "frame_rate_fraction": {
                            "type": "array",
                            "items": [
                                {
                                    "type": "integer"
                                },
                                {
                                    "type": "integer"
                                }
                            ]
                        },
                        "num_channels": {
                            "type": "integer"
                        },
                        "samplerate": {
                            "type": "integer"
                        },
                        "decoder_config": {
                            "type": "string"
                        },
                        "lang": {
                            "type": "string"
                        },
                        "max_bitrate": {
                            "type": "integer"
                        },
                        "min_bitrate": {
                            "type": "integer"
                        }
                    },
                    "required": [
                        "media_type",
                        "name",
                        "bitrate",
                        "codec"
                    ]
                }
            ]
        }
    }
}

Depending on the media type, there are required fields for a variant. The table below lists all the required fields depending on media type.

Media typeRequired fields
Videomedia_type
subtype
name
bitrate
width
height
sample_aspect_ratio
picture_aspect_ratio
scan_type
sps
pps
codec
frame_rate_fraction
Audiomedia_type
subtype
name
bitrate
codec
num_channels
samplerate
decoder_config
lang
Subtitlesmedia_type
name
bitrate
lang
codec

The fields max_bitrate and min_bitrate are optional for all media types.

Example content template

{
    "version": "1.0",
    "constant_gop_duration_ms": 1920,
    "variants": [
        {
            "media_type": "video",
            "subtype": "h264",
            "name": "V1000",
            "bitrate": 1000000,
            "width": 640,
            "height": 360,
            "sample_aspect_ratio": "1:1",
            "picture_aspect_ratio": "16:9",
            "scan_type": "progressive",
            "sps": "6764001eacb201405ff2a0",
            "pps": "68ebccb22c",
            "codec": "avc1.64001E",
            "frame_rate_fraction": [
                25,
                1
            ],
            "max_bitrate": 1500000,
            "min_bitrate": 900000
        },
        {
            "media_type": "video",
            "subtype": "h264",
            "name": "V1500",
            "bitrate": 1500000,
            "width": 768,
            "height": 432,
            "sample_aspect_ratio": "1:1",
            "picture_aspect_ratio": "16:9",
            "scan_type": "progressive",
            "sps": "6764001eacb201806f20",
            "pps": "68ebccb22c",
            "codec": "avc1.64001E",
            "frame_rate_fraction": [
                25,
                1
            ],
            "max_bitrate": 1600000,
            "min_bitrate": 1400000
        },
        {
            "media_type": "audio",
            "subtype": "aac",
            "name": "A128",
            "bitrate": 128000,
            "codec": "mp4a.40.2",
            "num_channels": 2,
            "samplerate": 48000,
            "decoder_config": "1190",
            "lang": "eng"
        },
        {
            "media_type": "subtitles",
            "name": "eng_1",
            "bitrate": 1000,
            "lang": "eng",
            "codec": "wvtt"
        }
    ]
}

Creating a Content Template: ew-content-template-tool

A content template does not need to created by hand. It can be created from an ingested asset with:

$ ew-content-template-tool

Usage: bin/ew-content-template-tool [OPTIONS] <content info path> <content_template_path> ...
Options:
-gop-dur-ms int
        GOP Duration for template
-version
        Get version and build date

For example:

$ ew-content-template-tool  -gop-dur-ms 1920 content_info.json content_template.json

Note: The tool makes no verification that the media files actually fulfill the specified GOP duration.

Verifying Assets Before Scheduling: ew-verify-asset

Before attempting to schedule an asset, it can be verified that it matches a specific content template, with:

$ ew-verify-asset

Usage: ew-verify-asset [options]

-i, --input string      Asset path
-t, --template string   Content template file for the asset(s)

For example:

$ ew-verify-content -i media/matrix-revolutions/ -t content-templates/template_4sGOP_hevc.json

This tool will verify that the asset with regards to video-tracks, codecs etc. Missing subtitle tracks, and (secondary) audio tracks are allowed, and yield warnings.

Non-constant GOP lengths are detected, and rejected, for assets ingested with ew-vodingest. Such irregularities are not detected for assets ingested with the older ew-recorder.