Transcoding is an essential part of media processing. This topic provides an overview of media transcoding and the transcoding methods supported by Alibaba Cloud. This topic also describes how to configure a transcoding template and start transcoding.
Overview
What is transcoding?
Video transcoding is a process of converting a compressed and encoded video stream to another video stream to adapt to different network bandwidths, terminal processing capabilities, and user requirements. Transcoding is a process in which decoding and encoding are performed. Streams before and after transcoding may use the same or different video codecs.
The following figure shows the point at which video transcoding is performed in a video production workflow.
Features
Scenarios
Transcoding methods
Before you begin
Activate ApsaraVideo VOD. For more information, see Activate ApsaraVideo VOD.
Authorize ApsaraVideo VOD to access OSS. To grant ApsaraVideo VOD permissions to access OSS, go to the Cloud Resource Access Authorization page.
Authorize the RAM user to manage media assets stored in ApsaraVideo VOD and OSS. For more information, see Create and grant permissions to a RAM user and Overview.
Take note of the supported transcoding methods described in this topic and transcoding limits described in Limits.
Usage notes
You are charged for the transcoding feature. For more information, see Billing of basic services.
You are charged for each transcoding job. A new video file is generated after a transcoding job is complete. To improve storage utilization and prevent additional charges, we recommend that you create transcoding template groups and transcoding jobs based on your business requirements.
Transcode media files by using the ApsaraVideo VOD console
Step 1: (optional) Create a transcoding template group
If the built-in transcoding template groups such as the No Transcoding and TranscodeTemplateGroup template groups cannot meet your transcoding requirements, you can create a custom transcoding template group and specify parameters such as the container format and resolution based on your business requirements.
Log on to the ApsaraVideo VOD console.
In the left-side navigation pane, choose Configuration Management > Media Processing > Transcoding Template Groups.
On the Transcoding Template Groups page, click Create Transcoding Template Group.
Follow the procedure described in Configure normal transcoding template groups to create a normal transcoding template group.
Follow the procedure described in Narrowband HD™ 1.0 to create a Narrowband HD™ 1.0 transcoding template group.
Follow the procedure described in Configure video packaging templates to create a video packaging template group.
Step 2: Start transcoding
You can trigger transcoding jobs when you upload and process media files. You can specify a transcoding template group when you create a transcoding job. Alternatively, you can add a transcoding template group to a workflow and use the workflow to transcode media files. For more information about how to create a workflow that includes a transcoding template group, see Manage workflows.
Automatically trigger transcoding during uploads
Log on to the ApsaraVideo VOD console.
In the left-side navigation pane, choose Media Files > Audio/Video. Then, click Upload.
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.
Select the media files that you want to upload and click Upload.
After the media files are uploaded, the files are automatically transcoded based on the transcoding template group or workflow that you specified.
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.
Log on to the ApsaraVideo VOD console.
In the left-side navigation pane, choose Media Files > Audio/Video.
On the Video and Audio page, find the media file that you want to transcode and click Media Processing in the Actions column.
In the dialog box that appears, specify Use Transcoding Template Group or Use Workflow and specify the transcoding template group or workflow that you want to use.
Click OK.
The media file is transcoded by using the transcoding template group or workflow that you specified.
Step 3: 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.
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
Log on to the ApsaraVideo VOD console.
In the left-side navigation pane, choose Media Files > Audio/Video.
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 the Status: the status of a video section of the Basic data types topic.
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, streams in different definitions and playback URLs are generated.
Method 2: By event notifications
ApsaraVideo VOD supports HTTP callbacks and MNS callbacks. After you configure event notifications, ApsaraVideo VOD sends you a notification when media files are processed based on the callback method that you specified. For example, ApsaraVideo VOD notifies you when media files are uploaded or transcoded. For more information, see Overview.
The transcoding-related events include StreamTranscodeComplete and TranscodeComplete. You can obtain information such as the transcoding status and playback URL of the video from the callbacks.
Transcode media files by using the ApsaraVideo VOD API or SDK
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.
For more information about how to use SDKs, see Usage notes.
Step 1: (Optional) Create a transcoding template group
If the built-in transcoding template groups such as the No Transcoding and TranscodeTemplateGroup template groups cannot meet your transcoding requirements, you can create a custom transcoding template group and specify parameters such as the container format and resolution based on your business requirements. If you set TemplateGroupId
to VOD_NO_TRANSCODE
, the No Transcoding template group is used.
Call the AddTranscodeTemplateGroup operation to create a transcoding template group. Set
Definition
inTranscodeTemplate
to configure normal transcoding or Narrowband HD™ transcoding.
Step 2: Start transcoding
You can trigger transcoding jobs when you upload and process media files. You can specify a transcoding template group when you create a transcoding job. Alternatively, you can add a transcoding template group to a workflow and use the workflow to transcode media files. For more information about how to create a workflow that includes a transcoding template group, see Manage workflows.
Automatically trigger transcoding during uploads
You can call the CreateUploadVideo operation only to obtain upload URLs and credentials and create media assets. To upload media files, you must implement the upload logic. For more information about how to upload media files by calling API operations, see Upload media files by calling the ApsaraVideo VOD API.
Configure
TemplateGroupId
orWorkflowId
when you call the CreateUploadVideo operation to obtain an upload URL and a credential or the UploadMediaByURL operation to upload media files. After media files are uploaded, ApsaraVideo VOD transcodes the media files based on the transcoding template group or workflow that includes a transcoding template that you specified.
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.
Configure
TemplateGroupId
orWorkflowId
when you call the SubmitTranscodeJobs operation to submit a transcoding job or the SubmitWorkflowJob operation to submit a workflow. After you submit a transcoding job, ApsaraVideo VOD transcodes the media files based on the transcoding template group or workflow that includes a transcoding template that you specified.
Step 3: 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.
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 when media files are processed based on the callback method that you specified. For example, ApsaraVideo VOD notifies you when media files are uploaded or transcoded. For more information, see Overview.
The transcoding-related events include StreamTranscodeComplete and TranscodeComplete. You can obtain information such as the transcoding status and playback URL of the video from the callbacks.