All Products
Search
Document Center

ApsaraVideo VOD:Adaptive bitrate streaming

Last Updated:Oct 22, 2024

ApsaraVideo VOD provides the adaptive bitrate streaming feature that allows you to transcode a video into video streams at different bitrates and packages these video streams into a single file. This way, media players can switch to the most appropriate video stream based on the network bandwidth. This topic describes how to use the adaptive bitrate streaming feature.

What is adaptive bitrate streaming?

The adaptive bitrate streaming feature allows you to transcode a video into video streams at different bitrates and packages these video streams into a file that contains the bitrate and resolution information of each video stream. This way, media players can switch automatically to the most appropriate video stream based on the network bandwidth. Compared with single bitrate streaming, adaptive bitrate streaming can improve the playback performance.

Note

The most widely used adaptive bitrate streaming protocols are HTTP Live Streaming (HLS) and Dynamic Adaptive Streaming over HTTP (DASH). ApsaraVideo VOD supports only HLS adaptive bitrate streaming.

Sample effects

image

How to use the adaptive bitrate streaming feature

Transcode media files by using the ApsaraVideo VOD console

Step 1: Create an adaptive bitrate streaming transcoding template group

You must create an adaptive bitrate streaming transcoding template group to submit transcoding tasks.

For more information, see Create an adaptive bitrate streaming transcoding template group.

Step 2: (Optional) Create a workflow and associate the workflow with the transcoding template group

You can add media processing tasks such as transcoding, review, snapshot capture tasks to a workflow based on a specific order. This way, you can use the workflow to process media files in the specified order.

Create a workflow, add a Transcode node, and specify the adaptive bitrate streaming transcoding template group that you created in Step 1. For more information, see Manage workflows.

Step 3: Start transcoding

Transcode media files by using the adaptive bitrate streaming transcoding template group or workflow in the preceding steps. You can trigger transcoding for uploaded files or during uploads.

Automatically trigger transcoding during uploads

  1. Log on to the ApsaraVideo VOD console.

  2. In the left-side navigation pane, choose Media Files > Audio/Video. Then, click Upload.

  3. On the Add Media page that appears, click Add Media. In the dialog box that appears, specify the parameters such as Upload Method and Bucket, select Use Transcoding Template Group or Use Workflow from the drop-down list, and specify the transcoding template group or workflow.

    For more information about supported video formats and parameter descriptions, see Upload media files by using the ApsaraVideo VOD console.多码率转码1

  4. Select the media files that you want to upload and click Upload.

Start transcoding for uploaded videos

In most cases, this operation is used to re-transcode existing videos, encrypt existing videos in HLS encryption mode, or override watermark parameters.

  1. Log on to the ApsaraVideo VOD console.

  2. In the left-side navigation pane, choose Media Files > Audio/Video.

  3. On the Video and Audio page, find the media file that you want to transcode and click Media Processing in the Actions column.

  4. In the dialog box that appears, select Use Transcoding Template Group or Use Workflow and specify the transcoding template group or workflow that you want to use.多码率转码2

  5. Click OK.

Step 4: View the transcoding results

After a media file is transcoded, you can use one of the following methods to view the transcoding results, such as the transcoding status and the playback URL of the video. You can obtain the playback URL and use ApsaraVideo Player or a third-party player to play the transcoded video.

Important

If you do not configure an accelerated domain name in ApsaraVideo VOD, you are charged for outbound traffic when you play or download a video based on the URL. For more information, see Billing of basic services.

Method 1: By using the ApsaraVideo VOD console

  1. Log on to the ApsaraVideo VOD console.

  2. In the left-side navigation pane, choose Media Files > Audio/Video.

  3. On the Video and Audio page, view the transcoding status of the media file.

    Normal indicates that the media file is transcoded. For more information about other transcoding statuses, see Status: the status of a video.

  4. Find the transcoded media file that you want to manage and click Manage in the Actions column. On the page that appears, view the playback URL on the Video URL tab.

    After a media file is transcoded, an adaptive bitrate stream, multiple streams in fixed bitrates, and playback URLs are generated.

    多码率转码3.png

Method 2: By event notifications

ApsaraVideo VOD supports HTTP callbacks and MNS callbacks. After you configure event notifications, ApsaraVideo VOD sends you a notification based on the callback method that you specified when media files are processed. For example, ApsaraVideo VOD notifies you when media files are uploaded or transcoded. You can obtain information such as the transcoding status and playback URL of the video from the callbacks. For more information, see Overview.

The following content describes the events related to transcoding:

Transcode media files by using the ApsaraVideo VOD API

Usage notes

For more information about how to call API operations to transcode media files, see List of operations by function. We recommend that you use the command-line tool OpenAPI Explorer developed by Alibaba Cloud for debugging. This frees you from signature calculations. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Step 1: Create an adaptive bitrate streaming transcoding template group

You must create an adaptive bitrate streaming transcoding template group to submit transcoding tasks.

  1. Call the AddTranscodeTemplateGroup operation to create a transcoding template group and specify TranscodeTemplate to configure the video packaging template.

    The following content describes specific packaging template parameters. For more information, see TranscodeTemplate: the configurations of a transcoding template.

    View the packaging template parameters

    Video packaging parameters

    API parameter

    Parameter in the console

    Description

    PackageType

    Packaging Type

    The packaging type. The output files can be in the HLS or DASH format. Valid values: HLSPackage and DASHPackage.

    Note

    You can set this parameter only to HLSPackage.

    BandWidth

    Bandwidth Threshold

    The bandwidth threshold, based on which media players switch between video streams at different bitrates. Unit: bit/s.

    Note

    This parameter takes effect only for video packaging templates.

Step 2: (Optional) Create a workflow and associate the workflow with the transcoding template group

You can add media processing tasks such as transcoding, review, snapshot capture tasks to a workflow based on a specific order. This way, you can use the workflow to process media files in the specified order.

You can create workflows only by using the ApsaraVideo VOD console. For more information, see Workflows.

Step 3: Start transcoding

Transcode media files by using the adaptive bitrate streaming transcoding template group or workflow in the preceding steps. You can trigger transcoding for uploaded files or during uploads.

Automatically trigger transcoding during uploads

Note

You can call the CreateUploadVideo operation only to obtain the upload URLs and credentials for media files and create media assets in ApsaraVideo VOD. You cannot call this operation to upload media files. You must implement the logic for the entire upload process. For more information about how to upload media files by calling API operations, see Upload media files by calling API operations.

  1. When you call the CreateUploadVideo or UploadMediaByURL operation, you can specify the ID of the transcoding template group for the TemplateGroupId parameter or the ID of the workflow that contains the Transcode node for the WorkflowId parameter. After the audio and video files are uploaded, the system automatically transcodes the files based on the specified transcoding template group or workflow.

Start transcoding for uploaded videos

In most cases, this operation is used to re-transcode existing videos, encrypt existing videos in HLS encryption mode, or override watermark parameters.

  1. Call the SubmitTranscodeJobs operation and specify the ID of the transcoding template group for the TemplateGroupId parameter, or call the SubmitWorkflowJob operation and specify the ID of the workflow that contains the Transcode node for the WorkflowId parameter. Then, the system automatically transcodes the audio and video files based on the specified transcoding template group or workflow after you submit a transcoding job.

Step 4: View the transcoding results

After a media file is transcoded, you can use one of the following methods to view the transcoding results, such as the transcoding status and the playback URL of the video. You can obtain the playback URL and use ApsaraVideo Player or a third-party player to play the transcoded video.

Important

If you do not configure an accelerated domain name in ApsaraVideo VOD, you are charged for outbound traffic when you play or download a video based on the URL. For more information, see Billing of basic services.

Method 1: By calling API operations

Obtain the TranscodeTaskId from the response to the SubmitTranscodeJobs operation. Then, call the GetTranscodeTask to query information such as the transcoding status and playback URL of the video.

Method 2: By event notifications

ApsaraVideo VOD supports HTTP callbacks and MNS callbacks. After you configure event notifications, ApsaraVideo VOD sends you a notification based on the callback method that you specified when media files are processed. For example, ApsaraVideo VOD notifies you when media files are uploaded or transcoded. You can obtain information such as the transcoding status and playback URL of the video from the callbacks. For more information, see Overview.

The following content describes the events related to transcoding:

What to do next

After you configure the adaptive bitrate streaming feature and transcode video streams, the player automatically plays the video stream in the most appropriate definition based on the network condition. You can also manually switch video streams in different definitions and subtitles.

The following topics describe how to configure the adaptive bitrate streaming feature: