Configure video or caption packaging templates

Updated at:

ApsaraVideo VOD provides video packaging templates and caption packaging templates. You can use these templates to generate adaptive bitrate streaming files that allow you to switch between different resolutions and captions in different languages. An adaptive bitrate stream file contains the bitrate, resolution, and other information for each audio and video stream. The player automatically selects the best stream for playback based on the current network bandwidth.

Notes

  • Video packaging templates do not support HLS encryption. To use HLS encryption, you must use a regular transcoding template. For more information about the differences between video packaging templates and regular transcoding templates, see Configure adaptive bitrate streaming for ApsaraVideo VOD.

  • In the ApsaraVideo VOD console, you can create up to 20 transcoding template groups. Each group can contain up to 10 video packaging templates and one caption packaging template.

  • Caption files must be stored in the same region as the video source file. Caption files can be stored only in the system bucket that ApsaraVideo VOD allocates.

  • Caption packaging templates cannot be created or used alone. They must be used with video packaging templates.

  • Caption packaging templates support only VTT caption files.

  • Transcoding is a paid service. For more information, see Pricing.

Procedure

  1. Create a transcoding template group for adaptive bitrate streaming.

    Note

    If you only need a video packaging template, you are not required to create a regular one. To avoid unnecessary transcoding fees, you can delete any unneeded regular transcoding templates.

    1. Log on to the ApsaraVideo VOD console. In the left-side navigation pane, choose Configuration Management > Media Processing > Transcoding Template Groups.

    2. On the Transcoding Template Groups tab, click Create Transcoding Template Group.

    3. Specify a name for the template group.

    4. In the Audio and Video Packaging Template section, click Add Template and configure the video packaging template.

      • In the Basic Information section, Encapsulation Format is fixed to HLS. The parameters in the Video Packaging Parameters section are described as follows:

        • Packaging Type: This parameter is fixed to HLS packaging.

        • Bandwidth Threshold: Specifies the bandwidth that the player uses to determine which stream to play based on the current network conditions. Unit: bps. We recommend that you use the recommended settings.

      • The Basic Information, Video Parameters, Audio Parameters, and Advanced Parameters sections are configured the same way as a regular transcoding template. For more information, see Transcoding templates.

      • If needed, click Add Template to create multiple video packaging templates with different bitrates, resolutions, and definitions.

    5. In the Subtitle Packaging Template section, click Add Template. Then, click Add in the subtitle packaging list to configure a subtitle packaging template.

      If needed, click Add to add multiple subtitles in different languages. Only one subtitle file is supported for each language.

      The following table describes the parameters for the subtitle template.

      Parameter

      Description

      Packaging Type

      ApsaraVideo VOD supports only HLS packaging. Therefore, this parameter is fixed to HLS packaging.

      Language

      The language of the subtitles. Examples: cn (Chinese), ja (Japanese), and en-US (English).

      Subtitle Stream Name

      The name of the subtitle track that is displayed in the player. The name can contain only Chinese characters, letters, digits, hyphens (-), and underscores (_).

      Example: test

      Subtitle Storage URL

      The complete OSS URL of the subtitle file. The subtitle file must be in the ApsaraVideo VOD system bucket. CDN domain names and HTTPS URLs are not supported.

      You can call the CreateUploadAttachedMedia operation to upload a subtitle file to the system bucket.

      Example: http://example-bucket-**.oss-cn-shanghai.aliyuncs.com/subtitles/4dba87c2-a787-42cd-8328-2369aeb8**-cn.vtt

      Actions

      You can Delete a subtitle track.

    6. After you create the video packaging template and subtitle packaging template, click Save.

  2. Initiate adaptive bitrate transcoding.

    1. In the ApsaraVideo VOD console, choose Media Files > Audio/Video.

    2. On the Audio/Video page, find the video you want to process and click Processing in the Actions column.

    3. Set Use Transcoding Template Group to Use Transcoding Template Group. Select the transcoding template group that you created in the previous step and click OK to start the media processing job.

  3. View the result.

    • View the packaged streams (two transcoded streams and one adaptive stream)

      In the ApsaraVideo VOD console, choose Media Files > Audio/Video. Find the processed video, click Manage, and then click the Video URL tab.

      The Video URL tab displays four entries: Original File (MP4, 1920×1080, 293.17 MB), HD (M3U8, private encryption, 1280×720, 48.24 MB), Fluent (M3U8, 640×360, 14.55 MB), and Adaptive (M3U8).

    • View the playback result (play the adaptive stream)

      On the Basic Configuration tab of ApsaraVideo Player, enter the adaptive stream URL from the Video URL tab, and then click the Preview tab to view the playback.

      On the right side of the video player, expand the Subtitles panel. After you select the test subtitle track, the corresponding English subtitles appear at the bottom of the video screen.