How to modify default manifests?

The Bitmovin encoding API essentially offers to create the manifests in two different way :

Manually:
This option offers a great deal of flexibility, however, it essentially requires to add each rendition and tracks (audio, subtitles etc.) manually, which multiplies the amount of API calls.

Using the default Manifest API
This option allows the manifest creation from a very limited set of calls to the API. The default Manifest generator essentially parses the different tracks from the encoding job and adds them to the manifest.

To have more flexibility with this option, you could possibly delete or add tracks from the default manifest. It can be helpful in order to make minor changes such as the language of your audio tracks.

In order for this process to work, you have to create (not start) the manifest before starting the encoding job, wait for the encoding job to be completed, modify the manifest as needed and finally start the manifest creation.

Example : change the name and language of the audio tracks.

The below example can be ran by the Bitmovin Java SDK.
You can use one of our code examples as a basis to get started and then use the instructions shared in this post to modify the manifest.

1/ Create the manifest

        HlsManifestDefault hlsManifestDefault  = new HlsManifestDefault();
        hlsManifestDefault.setEncodingId(encoding.getId());
        EncodingOutput encodingOutput = new EncodingOutput();
        encodingOutput.setOutputId(gcsOutput.getId());
        encodingOutput.setOutputPath("encoding_test/testDefaultManifest-Wed_Mar_29_12:16:26_MDT_2023/");
        hlsManifestDefault.setOutputs(Arrays.asList(encodingOutput));
        hlsManifestDefault.setManifestName("manifest.m3u8");
        hlsManifestDefault = bitmovinApi.encoding.manifests.hls.defaultapi.create(hlsManifestDefault);

2/ Start the encoding job and wait for it to be finished

        bitmovinApi.encoding.encodings.start(encoding.getId());
        waitForEncodingToFinish(encoding.getId());

3/ Modify the Default manifest
From there, you can add or delete tracks. In the following example, 2 audio tracks have been created, however, the manifest generator cannot “guess” which language the tracks are supposed to be and will therefore use “en” as default.

In order to change the audio tracks language, let’s store the 2 existing ones (MediaInfo) into variables, delete them from the Manifest on the bitmovin API, change the name of the tracks and then add them again to the manifest.

        AudioMediaInfo audioMediaInfo = bitmovinApi.encoding.manifests.hls.media.audio.list(hlsManifestDefault.getId()).getItems().get(0);
        AudioMediaInfo audioMediaInfo2 = bitmovinApi.encoding.manifests.hls.media.audio.list(hlsManifestDefault.getId()).getItems().get(1);

        bitmovinApi.encoding.manifests.hls.media.audio.delete(hlsManifestDefault.getId(), bitmovinApi.encoding.manifests.hls.media.audio.list(hlsManifestDefault.getId()).getItems().get(0).getId());
        bitmovinApi.encoding.manifests.hls.media.audio.delete(hlsManifestDefault.getId(), bitmovinApi.encoding.manifests.hls.media.audio.list(hlsManifestDefault.getId()).getItems().get(0).getId());

        audioMediaInfo.setLanguage("sp");
        audioMediaInfo2.setLanguage("de");
        audioMediaInfo.setName("sp");
        audioMediaInfo2.setName("de");
        bitmovinApi.encoding.manifests.hls.media.audio.create(hlsManifestDefault.getId(), audioMediaInfo);
        bitmovinApi.encoding.manifests.hls.media.audio.create(hlsManifestDefault.getId(), audioMediaInfo2);

4/ Once this is done, the very last step is to start the manifest generation and monitor it

        bitmovinApi.encoding.manifests.hls.start(hlsManifestDefault.getId());
        SoftAssertions softAssertions = new SoftAssertions();
        waitForHlsManifestToFinish(hlsManifestDefault.getId(), softAssertions);
        softAssertions.assertAll();

Feel free to share your experience or ask questions here.

1 Like