[object Object] Icon

Encoding
Learn how to create, start, manage and modify Encodings

[object Object] Icon

Player
Learn how to create, start, manage and modify Players

[object Object] Icon

Analytics
Learn how to create, start, manage and modify Analyticss

Docs Home
User shortcuts for search
Focus by pressing f
Hide results by pressing Esc
Navigate via   keys

Fri Dec 07 2018

How to create a Per-Title Encoding

OverviewLink Icon

A regular encoding simply follows the rules you defined in its stream-, codec-, and muxing configurations. A Per-Title Encoding does a lot more. It not only uses the given configuration, but evaluates it and its output results and adjust its parameters (width, height, bitrate) based on the given input file specifications and characteristics to optimize your bitrate ladder to achieve high quality content while reducing the required bandwidth to deliver it. You can see this illustrated in the graphic below.

image

While you can leave the decisions entirely to the Per-Title Encoding, you can also provide it with some ground rules that have to be met regardless its own results. Yuo might need to do this to accommodate requirements from your clients or content providers that specific resolutions have to be present, or to use different encryption keys for specific renditions, and so on.

Configuring a Per Title EncodingLink Icon

So far, when you create an Encoding, you add a Stream set to their STANDARD mode (enabled by default), for every output rendition you want to create out of your input file. Each Stream is linked to an Codec Configuration that defines which codec, resolution, bitrate, etc. has to be used for this rendition. Then you create Muxings to define which outputs (fMP4 (DASH), MP4, TS,...) have to be created out of theses Streams.

When you create an Per Title Encoding the workflow and configuration is a little bit different as it depends on your requirements or use-case.

A Simple SetupLink Icon

The most simple use-case is where you let our encoding service decide everything to achieve the best possible outcome with regards to bandwidth savings and quality improvements.

Instead of adding multiple Streams to your Encoding, you add just one which mode is set to PER_TITLE_TEMPLATE and has as an plain Codec configuration linked to it. This Stream, its Codec Configuration, as well as all Muxings that are using it, will be used as a template by the Per-Title encoding, to create a Per-Title profile.

Our Per-Title Algorithm will then add additional Streams to this per title profile based on the Per-Title Template, which it considers to be most beneficial for your encoding in terms of bandwidth and quality. These Streams will have set their mode to PER_TITLE_RESULT, as they got added automatically by the Per-Title Algorithm.

Example (Java)Link Icon

An HTTPS Input and AWS S3 Output will be used in this example. The full example states their creation and configuration as well.

Create an Encoding

As always the first step is to create an encoding in our API, which holds all the streams and muxings that are used to configure the encoding of your input file. In order to be able to use the Per Title Encoding you have to use the encoder version v1.53.0 or higher.

1Encoding encoding = new Encoding();
2encoding.setName("Java Example - Per-Title");
3encoding.setCloudRegion(CloudRegion.AUTO);
4encoding = bitmovinApi.encoding.create(encoding);

Add a Stream with Codec Configuration to the Encoding

As for regular encodings you do have to provide the Stream with the information about which video stream of your input file has to be used for the encoding.

1InputStream videoInputStream = new InputStream();
2videoInputStream.setSelectionMode(StreamSelectionMode.AUTO);
3videoInputStream.setInputPath(INPUT_PATH);
4videoInputStream.setInputId(s3Input.getId());
5
6InputStream audioInputStream = new InputStream();
7audioInputStream.setSelectionMode(StreamSelectionMode.AUTO);
8audioInputStream.setInputPath(INPUT_PATH);
9audioInputStream.setInputId(s3Input.getId());

The next step is to create a single “Stream” which is configured to use a plain H264 Codec configuration, that is configured with its required options only, which is the “profile” option, and the “mode” of the Stream set to “PER_TITLE_TEMPLATE”. These steps are encapsulated in the "createAudioStream" and "createVideoStream" method used in the full example.

1Stream audioStream = createAudioStream(encoding, audioInputStream);
2Stream videoStream = createVideoStream(encoding, videoInputStream);

Add Muxings to the Encoding

Having finished the configuration which video stream of the input file shall be used for the per title encoding, the configuration of the desired output formats is needed (fMP4, TS, MP4, …). As done for the Codec configuration, only the required options will be set of the muxing.

The example is creating fMP4 content, so its required parameters are:

  • Segment length
  • Streams to be used by the muxing
  • Outputs to be used, and a path where to store the content

When creating content for an adaptive streaming format like MPEG-DASH, you typically store the segments of each rendition in a separate folder, where its name typically states the bitrate and/or resolution as well as an unique identifier to make it clearly identifiable.

As you yet don’t know the bitrate or resolution that is going to be used by the Per Title Encoding, you can use the following placeholders to specify your output path:

  • {uuid} - e.g. 3f759845-75d7-4df0-91b6-53aef29b91dd
  • {bitrate} in bps
  • {width} in px
  • {height} in px

These steps are encapsulated in the "createMp4Muxing" method used in the full example.

1createMp4Muxing(encoding, s3Output, videoStream, audioStream);

Start the Per Title Encoding

The configuration of the Per Title Encoding is now complete, therefore its start Encoding API call and the according Per Title Configuration can be prepared. Right now, Per Title Encodings support H.264 only, however other codecs like HEVC, VP9 and AV1 will be supported soon as well.

While the Per Title Configuration allows you to customize the Per Title Algorithm, all its settings are optional. However in order start one, the Per Title configuration as to be present in the “start Encoding” API request.

The Per Title Configuration can be added to the StartEncodingRequest configuration. There you can configure the “EncodingMode” which can be set to “STANDARD”, “TWO_PASS” or “THREE_PASS”. In order achieve the best possible quality “THREE_PASS” is used in this example.

These steps are encapsulated in the "startEncoding" method used in the full example.

1startEncoding(encoding);

That’s it! The Per Title Encoding will be started now, the Per Title Algorithm add additional Streams to achieve high quality and bandwidth savings, and transfers them to your Output accordingly.

Per-Title Configuration OptionsLink Icon

If the fully automated way doesn't suite you completely, as you need to fullfil certain requirements, e.g. the range available to select a proper bitrate, or how small/big the steps between each representation has to be, you can customize the per title algorithm configuration for each codec you are using as well.

Get StartedLink Icon

Knowing the theory, its time to do it by yourself. The best way to start is running the complete "Per Title" example that are available for our API clients already:

API ClientExampleRepository
Bitmovin-JavaLINKLINK
Bitmovin-PythonLINKLINK
Bitmovin-JavascriptLINKLINK
Bitmovin-GoLINKLINK
Bitmovin-C#LINKLINK
Bitmovin-RubyLINKLINK
Bitmovin-PHPLINKLINK

Give us feedback