You can transcode media with ApsaraVideo Media Processing (MPS) by submitting transcoding jobs in the console or by calling an API operation. This topic describes how to create a standard transcoding job in MPS.
Before you begin
Complete the following preparations. You can skip this section if you have already done so.
-
Activate a pipeline. For standard transcoding jobs, use a standard pipeline.
Upload the video to be processed to OSS.
If you want to create a job, directly upload the video to OSS. For more information, see Upload a video.
If you want to create a workflow and automatically trigger the workflow, you must add media buckets and create a workflow before you upload the video. After you specify the input and output media buckets and upload a media file to the input media bucket, MPS receives a message about the upload and triggers the associated workflow. After the workflow is complete, the processed media file is uploaded to the output media bucket. For more information, see Add media buckets.
-
Configure transcoding templates.
-
Use watermark templates to simplify adding watermarks to your videos. For more information, see Watermark templates.
Optional. Enable the notification feature. If you want MPS to send notifications on jobs and workflows to MNS topics or queues, configure an MNS queue or topic as required. For more information, see Set up notifications.
Submit jobs in the console
Single job
-
Log on to the ApsaraVideo Media Processing console.
-
In the top navigation bar, select a region. For example, select China (Hangzhou).
-
In the left-side navigation pane, choose Job Management.
-
On the Encode tab, click Create Task.
-
Configure the parameters.
Parameter
Description
Input File URL
Click Select. In the Bucket drop-down list, select a bucket. Folders in the selected bucket appear under Path. Select an input file from a folder.
Note-
If no buckets are available in the drop-down list, go to the OSS console to create a bucket in the current region. For more information, see Add media buckets.
-
If no files are available under Path after you select a bucket, go to the OSS console and upload files to that bucket in the current region.
-
If you are prompted that OSS is not activated, go to the OSS console to activate the service.
-
If a role error or a permission-denied message appears, go to the Resource Access Management (RAM) console and grant the required OSS permissions to the current RAM user. You can grant full OSS permissions by attaching the AliyunOSSFullAccess policy or create a custom policy as needed. For more information, see Create a RAM user and grant permissions.
Encoding Pipeline
Select a pipeline from the drop-down list.
Note-
If no pipelines are available in the drop-down list, activate a pipeline first. For more information, see Create a pipeline.
-
Transcoding pipeline concurrency is not guaranteed and depends on available resources. The default concurrency is 200.
Output File Name
Enter a name for the output file. You must add a file extension for all file types except M3U8. For example, enter
example_video01.mp4.Output Path
Click Select. In the Bucket drop-down list, select a bucket. The folders in the bucket are displayed under Path. Select a folder as the output path.
Note-
If the output path is the same as the input path but the files have different names, the source file is not overwritten. If the files share the same name, your OSS configuration determines if the source file is overwritten. To prevent files from being overwritten, see Prevent objects with the same name from being overwritten (Java SDK V1). If you enable this setting, the job fails to write the output file to OSS if it has the same name as the source file. We recommend that you use a different name for the output file.
-
For other common issues, see the description for Input File URL.
-
-
Click Next.
-
Configure Encoding Template.
Parameter
Description
Template Type
Select the type of transcoding template. For information about preset templates, see Preset template details. To create a custom transcoding template, see Transcoding templates.
Output Format
Select an output format from the drop-down list. The default value is mp4.
Template
Select a template from the list. The default value is MP4-4K.
(Optional) Watermark Template
Turn on the switch.
-
From the Watermark Template drop-down list, select a watermark template that you created. If no watermark templates are in the list, create one first.
-
Click Select next to Watermark Image. In the Bucket drop-down list, select a bucket. The folders in the bucket are displayed under Path. Select an image file from a folder.
NoteSupported watermark files include PNG images, animated PNG images, and MOV animations.
(Optional) Clip Output
Turn on the switch. Set the start time and duration to define the clip.
-
In the Start From field, select the start time in HH:MM:SS format.
NoteThe start time must be less than the total duration of the video. Otherwise, the transcoding job fails.
-
In the Clip Length field, select the duration in HH:MM:SS format.
NoteIf the specified clip duration extends beyond the end of the video, the clip runs to the end of the source video.
(Optional) Rotate Angle
Enter a clockwise rotation angle. The value must be within the range of [0, 360].
-
-
Click Submit to create and submit the transcoding job.
After the job is submitted, you can view its execution status, configuration details, input path, and output path in the job list on this tab.
NoteIf a transcoding job fails and you cannot view the failure details, check your network connection and resubmit the job once the connection is stable.
Workflow
-
Log on to the ApsaraVideo Media Processing console.
-
In the top navigation bar, select a region.
-
In the left-side navigation pane, choose Workflow > Workflow Orchestration.
-
Click Create Workflow.
-
Configure the workflow parameters as required.
-
Workflow Name: Enter a name for the workflow.
-
Configuration Plan: Select a configuration plan from the drop-down list.
NoteApsaraVideo Media Processing provides preset workflows for common use cases. You can select and edit a preset workflow, or create a custom workflow.
-
-
Edit the workflow topology.
-
Click the plus icon (+) next to the relevant node and select the Encode node from the drop-down list.
-
Click the pencil icon next to the Encode node to open the Basic Settings page.
-
Configure the transcoding parameters.
Parameter
Description
Name
Enter a name for this node.
Encoding Template
Click Select. In the dialog box that appears, configure the Encoding Template.
-
Select a Template Type.
-
Select an Output Format.
-
Select a Template.
-
Click OK.
NoteFor information about preset templates, see Preset template details. To create a custom template, see Transcoding templates.
Output Path
Click Select. In the Bucket drop-down list, select a bucket. The folders in the bucket are displayed under Path. Select a location as the output path.
Note-
If the output path is the same as the input path:
-
If the files have different names, the source file is not overwritten.
-
If the files share the same name, your OSS configuration determines if the source file is overwritten. To prevent files from being overwritten, see Prevent objects with the same name from being overwritten (Java SDK V1). If you enable this setting, the job fails to write the output file to OSS if it has the same name as the source file. We recommend that you use a different name for the output file.
-
-
To prevent output files from being overwritten on subsequent workflow runs, you can use a combination of the following built-in variables:
-
{RunId}: The execution ID of the media workflow. -
{ObjectPrefix}: The path of the source file, excluding bucket information. -
{FileName}: The name of the source file, including the extension. The extension of the output file is determined by the selected transcoding template. -
{ExtName}: The extension of the source file.
-
(Optional) Watermark
Turn on the switch.
-
Select a template name from the Watermark Template drop-down list.
NoteIf no watermark templates are in the drop-down list, create one first.
-
Click Select next to Watermark Image to add the watermark image path.
NoteSupported watermark files include PNG images, animated PNG images, and MOV animations.
(Optional) Encryption
Turn on the switch.
For Encryption Method, select Alibaba Cloud Private Encryption or HLS Standard Encryption. For more information, see Video encryption.
(Optional) Clip
Turn on the switch.
-
For Clip Method, select Video Clip or Video Ending Clip.
-
In the Start From field, select the start time.
-
In the Length field, select the duration.
Note-
The start time must be less than the total duration of the video. Otherwise, the transcoding job fails.
-
If the specified clip duration extends beyond the end of the video, the clip runs to the end of the source video.
-
(Optional) Add Credits
Turn on the switch. Next to File Path, click Select and choose the path of the credits video file.
(Optional) Rotate Angle
Enter a clockwise rotation angle. The value must be within the range of [0, 360].
-
-
Click OK to finish configuring the Encode node.
-
-
Click Save to create the workflow.
Submit jobs via API
If creating jobs or workflows in the console does not meet your needs, you can call the SubmitJobs operation to programmatically submit transcoding jobs and configure parameters based on your business logic.
-
Call the SubmitJobs operation to submit a transcoding job.
For more information, see Submit a transcoding job. During the creation process, you must configure the transcoding information as follows:
-
PipelineId: Use the ID of a standard pipeline. -
TemplateId: Select a transcoding template based on your needs. If the preset templates do not meet your requirements, you can create a custom template. For more information, see Add a custom transcoding template. -
(Optional) If you require encryption, configure the
Encryptionparameter in theOutputobject.NoteEncrypted output must be in M3U8 format. The API supports Base64 and KMS encryption methods. For more information, see Parameter details.
-
-
Receive callback notifications.
When a transcoding job completes, if you have configured event notifications for the pipeline, a message is sent to the specified queue or topic in Simple Message Queue (formerly MNS). For more information, see Receive notifications.
-
Query the job result.
-
Call the Query transcoding jobs operation to query the job result and get the output file URL.
-
Call the List transcoding jobs operation to query multiple transcoding jobs based on pipeline ID, job status, and creation time range.
-