To produce videos with multiple bitrates, audio tracks, subtitles, or formats, or to orchestrate a sequence of tasks, create a workflow and configure task nodes such as transcoding, analysis, snapshot, packaging, review, video fingerprint extraction, and intelligent thumbnail.
Background
A Workflow is a pre-orchestrated series of tasks. After you upload a file to a specified OSS Bucket, jobs trigger automatically or manually and execute in a sequence defined by preset steps and conditions. You can add nodes such as Transcoding, Analyze, Snapshots, Pack, Content Moderation, Video DNA, and Intelligent Thumbnail to a Workflow. By combining these nodes, you can handle various scenarios, such as multi-resolution transcoding, multi-language subtitle packaging, and HLS Standard Encryption.
To understand the end-to-end Workflow process, see Get started with a Workflow. This topic describes how to create a Workflow in the ApsaraVideo Media Processing (MPS) console.
Prerequisites
-
Set an input bucket and an output bucket. For more information, see Add media buckets.
-
Enable the corresponding MPS queue based on the task type. For more information, see Create an MPS queue.
-
Optional: Create a template. If preset transcoding templates do not meet your needs, you can create a custom transcoding template. For more information, see Transcoding templates.
Procedure
-
When you create a Workflow, its status is automatically set to Active and its trigger mode to Auto. This means that when a file matching the trigger rules is uploaded to the Input Path of the Input node (via OSS or the console), the Workflow triggers automatically. For more information about trigger rules, see File matching rules for a Workflow.
-
Workflows also support manual triggering for new files (recommended for M3U8 files from live recordings) and manual triggering for existing files. For more information, see Next steps in this topic.
-
Log on to the MPS console.
-
In the upper-left corner of the top navigation bar, select a region.
-
In the left-side navigation pane, choose Workflow > Workflow Orchestration.
-
Click Create Workflow.
-
Configure the Workflow parameters.
-
Workflow Name: Enter a name for the Workflow.
-
Configuration Plan: Select a configuration plan from the drop-down list. The following table describes the available plans.
NoteApsaraVideo Media Processing provides a variety of preset Workflows for common use cases. You can select a preset Workflow as a starting point or create a custom one from scratch.
Parameter
Description
Custom
Starts with no preset information, allowing you to create a Workflow from scratch.
M3U8
Takes a single snapshot for the cover and converts the video to the M3U8 format.
Preset Intelligent Template-based Workflow
Takes a single snapshot for the cover, intelligently analyzes the video before transcoding it, and then takes a snapshot of the transcoded standard-definition video.
Multi-bitrate and Multi-Format Workflow
Takes a single snapshot for the cover and generates videos in multiple formats and bitrates.
Multi-bitrate FLV Workflow
Takes a single snapshot for the cover and generates multi-bitrate videos in FLV format.
Multi-bitrate M3U8 Workflow
Takes a single snapshot for the cover and generates multi-bitrate videos in M3U8 format.
Multi-bitrate MP4 Workflow
Takes a single snapshot for the cover and generates multi-bitrate videos in MP4 format.
-
-
Edit the workflow topology. Add and configure nodes as needed. For a description of each node, see Node descriptions.
-
Click Save to create the Workflow.
Nodes
You can add the following nodes when you create a Workflow in the console:
The following table lists all available Workflow nodes in MPS. When you add a node, the console displays only the nodes that are supported in the current region. For more information about the features supported in each region, see Service regions.
|
Parameter |
Description |
|
Input (Required) |
Sets the input path and configures message notifications. |
|
Analyze |
Intelligently analyzes the input file and recommends a suitable preset template. |
|
Transcoding |
Transcodes a video file into a different format or resolution. |
|
Snapshots |
Captures a frame at a specified time point to use as a video cover or to generate a sprite. |
|
Pack |
Packages video streams with multiple subtitles, audio tracks, and bitrates into a master playlist file. |
|
Content Moderation |
Intelligently identifies objectionable content (such as pornography, terrorism, and political references) in a video's audio, text, and frames. This reduces manual review costs and minimizes compliance risks. |
|
Video DNA |
Uniquely identifies a video by extracting and comparing fingerprint features of its images and audio. This helps solve problems such as finding duplicate videos, tracing the source of video clips, and identifying original content. |
|
Publish (Required) |
Sets the publishing mode to either manual or automatic. |
Input node
-
Click the pen icon next to the Input node to open the Input Settings page.
-
Set the input parameters.
Parameter
Description
Input Path
Click Select. In the Bucket drop-down list, select a bucket. The Path section shows the folders that are created in the bucket. Select a folder as the input path.
Encoding Pipeline
Select an MPS queue from the drop-down list.
(Optional) Notifications
Enable message notifications, and then select an MNS queue or MNS topic and specify its corresponding instance.
NoteAfter you configure message notifications, messages are sent to the specified MNS topic or MNS queue when tasks in the Workflow start and complete. For more information, see Set up notifications.
-
Click OK to save the settings for the Input node.
Analyze node
You can add an Analyze node by clicking the plus icon (+) next to the Input, Content Moderation, Video DNA, or Intelligent Thumbnail node.
-
Click the plus icon (+) next to the relevant node and select Analyze from the drop-down list.
-
Click the pen icon next to the Analyze node to open the Analyze Configuration page.
-
Select a resolution from the Conditional Encoding drop-down list.
-
Click OK to save the settings for the Analyze node.
Encode node
You can add an Transcoding node by clicking the plus icon (+) next to the Input, Content Moderation, or Video DNA node.
-
Click the plus icon (+) next to the relevant node and select Transcoding from the drop-down list.
-
Click the pen icon next to the Transcoding node to open the Basic Settings page.
-
Configure the encoding settings.
Parameter
Description
Name
Enter a name for this node.
Encoding Template
Click Select to configure Encoding Template in the pop-up window.
-
Select a Template type.
-
Select an Output Format.
-
Select a Template.
-
Click OK.
NoteFor more information about preset templates, see Preset template details. To create a custom template, see transcoding templates.
Output Path
Click Select. From the Bucket drop-down list, select a bucket. The Path section shows the folders that are created in the bucket. Select a folder as the output path.
Note-
If the output path is the same as the input path:
-
If the files have different names, the output file does not overwrite the source file.
-
If the output file has the same name as the source file, it may be overwritten, depending on your OSS settings. For information about how to prevent overwriting, see Prevent objects with the same name from being overwritten (Java SDK V1). If overwriting is disabled in OSS, the job fails if a file with the same name already exists. We recommend that you do not set the output filename to be the same as the source filename.
-
-
To prevent output files from being overwritten when a Workflow runs multiple times, you can combine the following built-in UC variables:
-
{RunId}: The execution ID of the Workflow.
-
{ObjectPrefix}: The source file path that does not include the bucket information.
-
{FileName}: The source file name including the extension. The suffix is updated based on the format of the transcoding template.
-
{ExtName}: The extension of the source file.
-
(Optional) Watermark
Enable this option to add watermarks.
-
Select a template name from the Watermark Templates drop-down list.
NoteIf no watermark templates are available in the drop-down list, create a watermark template.
-
Next to Watermark Image, click Select to specify the path of the watermark image.
NoteImage watermarks support PNG images, animated PNGs, and MOV-format animations.
(Optional) Encryption
Enable this option to apply encryption.
For Encryption Method, select Alibaba Cloud Private Encryption or HLS Standard Encryption. For more information about video encryption, see Video Encryption.
(Optional) Clip
Enable this option to clip the video.
-
For Clip Method, select Video Clip or Video Ending Clip.
-
In the Start From input box, enter a start time.
-
In the Length input box, enter a duration.
Note-
The start time must be less than the total video duration. Otherwise, transcoding fails.
-
If the clip duration exceeds the available video length, the clip extends to the end of the source video.
-
(Optional) Add Credits
Enable this option. Next to File Path, click Select to specify the path of the ending video.
(Optional) Rotate Angle
Enter a clockwise rotation angle. The value must be in the range of [0, 360].
-
-
Click OK to save the settings for the Transcoding node.
Snapshot node
You can add a Snapshots node by clicking the plus icon (+) next to the Input, Transcoding, Content Moderation, Video DNA, or Intelligent Thumbnail node.
-
Click the plus icon (+) next to the relevant node and select Snapshots from the drop-down list.
-
Click the pen icon next to the Snapshots node to open the Snapshot Configuration page.
-
Set the snapshot parameters.
Parameter
Required
Description
Snapshot Mode
Yes
-
Single: Captures a single frame at a specific time.
-
Multiple: Captures frames at a set interval.
-
Average: Captures a specified number of frames, evenly spaced throughout the video.
Snapshot interval (seconds)
Required for 'Multiple' mode
Enter the interval between snapshots in seconds.
Snapshots
Required for 'Average' mode
Enter the number of snapshots.
Note-
If this parameter is not set, snapshots are taken at the specified interval until the end of the video.
-
If the number of snapshots is greater than 1, snapshots are taken at the specified interval until the specified number of images is reached.
-
If only the number of snapshots is set, snapshots are taken at an interval of Total Duration / Number of Snapshots.
Name
Yes
Enter a name for this node.
Output Path
Yes
Click Select. From the Bucket drop-down list, select a bucket. The Path section shows the folders that are created in the bucket. Select a folder as the output path.
Note-
Single snapshot path format:
http://bucket.oss-cn-hangzhou.aliyuncs.com/path/{RunId}/{SnapshotTime}.jpg. -
Multiple or Average snapshot path format: Requires the {Count} placeholder. The path must end with
/{RunId}/{SnapshotTime}/{Count}.jpg.
Start Time
No
Select the time from the drop-down lists for hour, minute, and second.
Width x Height
No
Enter the width and height values in their respective input boxes.
Note-
If you leave both width and height blank, the snapshot resolution matches the source video.
-
If you set only the width or height, the other dimension is scaled automatically to maintain the original aspect ratio.
Generate WebVTT Index File
Optional for Multiple and Average modes
Enable this option to generate a WebVTT index file.
Set as Thumbnail
No
Enable this to set the captured image as the cover for the media asset in the library. If multiple snapshots are taken, the first snapshot is set as the cover by default.
Keyframe
No
Enable this to ensure snapshots are taken only on keyframes. If a specified time point is not a keyframe, the nearest one is used instead.
Black Screen Detection
Optional for Multiple and Average modes
Enable this to detect and skip black frames at the start of the video. If a non-black frame is detected within the first five seconds, MPS captures the first non-black frame.
-
Pack node
You can add this node only by clicking the plus icon (+) next to the Input node.
-
Click the plus icon (+) next to the Input node and select Pack from the drop-down list.
After the node is added, the Pack node contains three sub-nodes: Pack Config, Video Extraction, and Package and Generate. The entire Workflow sequence is Input → Pack Config → Video Extraction → Package and Generate → Publish.
The configuration initially includes three child nodes: Pack, Extract Video, and package generation. To package the multimedia stream, add more child nodes as described below.
-
To create a stream with multiple bitrates: Click the plus icon (+) next to the Pack node and select Extract Video from the drop-down list.
-
To create a stream with multiple audio tracks: Click the plus icon (+) next to the Pack node and select Audio Group from the drop-down list. Then, click the plus icon (+) next to the Audio Group node and select Extract Audio from the drop-down list.
-
To create a stream with multiple subtitles: Click the plus icon (+) next to the Pack node and select Subtitle Group from the drop-down list. Then, click the plus icon (+) next to the Subtitle Group node and select Extract Subtitle from the drop-down list.
Click the edit icon to the right of Pack to enter the configuration page. The configuration descriptions for each child node are as follows.
-
Packaging configuration
Parameter
Description
Packing name
Enter a name for this node.
Packing Type
The default value is HLS.
Output Buckets
This field is automatically populated after you specify an output path.
Output Path
Click Select. From the bucket drop-down list, select a bucket. Existing folders in the selected bucket appear under Path. Select a folder as the output path.
-
Video extraction
Parameter
Description
Name
Enter a name for this node.
Encoding Template
Click Select to choose a transcoding template.
NoteFor information about preset transcoding templates, see Preset template details. To create a custom transcoding template, see Transcoding templates.
Resource path
We recommend using the default value, but you can change it as needed.
NoteIf the output path of the packaging configuration node is a/b/c.m3u8 and the resource path of the video extraction node is d/e/f.m3u8, the extracted file is stored at a/b/d/e/f.m3u8.
(Optional) Watermark
Enable this option to add a watermark.
-
From the Watermark Templates drop-down list, select a template. To create a watermark template, see Watermark templates.
-
Click Select next to Watermark Image to select the watermark image file.
NoteSupported image watermark formats include PNG, animated PNG, and animated MOV.
(Optional) Encryption
Enable this option to encrypt the video. For Encryption Method, select Alibaba Cloud Private Encryption or HLS Standard Encryption. For more information, see video encryption.
(Optional) Clip
Enable this option to clip the video.
-
For Clip Method, select Video Clip or Video Ending Clip.
-
In the Start From field, enter the start time.
-
In the Length field, enter the duration.
Note-
The clip start time must be less than the total duration of the video. Otherwise, transcoding fails.
-
If the specified clip duration is longer than the remaining video, the clip runs from the start time to the end of the source video.
-
(Optional) Add Credits
Enable this option to add a video ending. Click Select next to File Path to select the video ending file.
(Optional) Rotate Angle
Valid values are from 0 to 360.
-
-
Package generation
Parameter
Description
Bandwidth
Set a suitable bandwidth for video playback.
Audio Group
Link an existing audio group to this video stream.
Subtitle Group
Link an existing subtitle group to this video stream.
-
Audio group and audio extraction
Child node
Parameter
Description
Audio group
Name
Enter a name for this audio group.
Audio extraction
Name
Enter a name for this node.
Transcoding template
Click Select to select a Encoding Template.
NoteFor information about preset transcoding templates, see Preset template details. To create a custom transcoding template, see Transcoding templates.
Resource path
We recommend using the default value, but you can change it as needed.
NoteIf the output path of the packaging configuration node is a/b/c.m3u8 and the resource path of the audio extraction node is d/e/f.m3u8, the extracted file is stored at a/b/d/e/f.m3u8.
Audio track name
Enter a name for the audio track.
Extract audio tracks
Enter the track number to extract from the input file.
Audio track language
Select a language from the drop-down list.
-
Subtitle group and subtitle extraction
Child node
Parameter
Description
Subtitle group
Name
Enter a name for this subtitle group.
Subtitle extraction
Name
Enter a name for this node.
Subtitle upload URI
Click Select. From the bucket drop-down list, select a bucket. Under Path, select the input subtitle file. Supported formats: STL, TTML, and VTT.
Resource path
We recommend using the default value, but you can change it as needed.
NoteIf the output path of the packaging configuration node is a/b/c.m3u8 and the resource path of the subtitle extraction node is d/e/f.m3u8, the extracted file is stored at a/b/d/e/f.m3u8.
Subtitle name
Enter a name for the subtitle.
Subtitle language
Select a language from the drop-down list.
Click OK to finish configuring each node.
Content moderation node
The Content Moderation node is available only in the China (Beijing), China (Shanghai), and Singapore regions. To add a Content Moderation node, click the plus icon on the Input or Transcoding node.
-
Click the plus icon next to the relevant node and select Content Moderation from the drop-down list.
-
Click the pencil icon on the Content Moderation node to open the Content Moderation Configuration page.
-
Configure the content moderation parameters.
Parameter
Description
Moderation Pipeline
Select an MPS queue from the drop-down list.
NoteIf no MPS queue is available in the Moderation Pipeline drop-down list, you must create a dedicated MPS queue. For instructions, see Create an MPS queue.
Output Path
Click Select. In the Bucket drop-down list, select a Bucket. Existing folders in the Bucket appear under Path. Select a folder as the output path.
Note-
If the output path is the same as the source path:
-
If the output and source files have different names, the source file will not be overwritten.
-
If the files have the same name, your OSS settings determine if the source file is overwritten. To prevent file overwrites, see Prevent objects from being overwritten by objects that have the same names (OSS SDK for Java V1). If you configure this setting, writing the transcoded file to OSS fails if it shares a name with the source file. We recommend that you do not use the same name for the output file and the source file.
-
-
To prevent output files from being overwritten when a media workflow runs multiple times, you can use a combination of the following built-in system variables:
-
{RunId}: The execution ID of the media workflow.
-
{ObjectPrefix}: The path of the source file, excluding the Bucket information.
-
{FileName}: The name of the source file, including its extension. This extension is automatically changed in the output file to match the format specified in the transcoding template.
-
{ExtName}: The extension of the source file.
-
Workflow Termination
Specifies whether to terminate the workflow based on the content moderation result. The options are:
-
Do not terminate the workflow
-
Terminate the workflow if the result is "Manual Review" or "Block"
-
Terminate the workflow if the result is "Block"
-
-
Click OK to save the Content Moderation node's configuration.
Video DNA node
The Video DNA node is available only in the China (Beijing), China (Hangzhou), China (Shanghai), and Singapore regions. To add a Video DNA node, click the plus icon on the Input or Transcoding node.
-
Click the plus icon (+) to the right of the relevant node and select Video DNA from the drop-down list.
-
Click the pen icon to the right of the Video DNA node to open the Video DNA configuration page.
-
Configure the Video DNA parameters.
Parameter
Description
Video DNA Pipeline
Select an MPS queue from the drop-down list.
NoteIf the Video DNA Pipeline drop-down list is empty, you must first create a dedicated MPS queue for Video DNA. For instructions, see Create an MPS queue.
Inbound Rule for DNA Library
-
Save Non-duplicated Content Only: Saves the Video DNA of unique videos to the library.
-
Do Not Save Any Media Content: Compares videos but does not save their Video DNA.
Workflow Termination
Specifies whether to terminate the workflow based on the processing result:
-
Do not terminate the workflow
-
Terminate the workflow if the video is a duplicate
-
-
Click OK to finish configuring the Video DNA node.
Smart thumbnail node
The Intelligent Thumbnail node is available only in the China (Beijing), China (Shanghai), and Singapore regions. To add an Intelligent Thumbnail node, click the plus icon on an Input or Transcoding node.
-
Click the plus icon (+) to the right of the relevant node and select the Intelligent Thumbnail node from the drop-down list.
-
To configure the Intelligent Thumbnail node, click the pen icon to open the Intelligent Thumbnail configuration page.
-
Configure the Intelligent Thumbnail node.
Parameter
Description
Name
Enter a name for this node.
Intelligent Thumbnail Pipeline
Select an MPS queue from the drop-down list.
NoteIf no MPS queues are available in the Intelligent Thumbnail Pipeline drop-down list, you must first create one. For instructions, see create an MPS queue.
Output Path
Click Select. From the Bucket drop-down list, select a bucket. The folders within the selected bucket are displayed under Path. Select a folder to use as the output path.
Note-
If the output path is the same as the input path:
-
If the files have different names, the output file does not overwrite the original file.
-
If the files have the same name, whether the original file is overwritten depends on your OSS settings. To prevent files from being overwritten, see Prevent objects from being overwritten by objects that have the same names (Java SDK V1). If you disable overwriting, the transcoding task fails when writing the output file to OSS. We recommend that you use different names for the original and output files.
-
-
To prevent output files from being overwritten when a workflow runs multiple times, you can use a combination of the following system variables in the output path:
-
{RunId}: The workflow execution ID.
-
{ObjectPrefix}: The path of the original file, excluding the bucket information.
-
{FileName}: The name of the original file, including its extension. The extension of the output file is determined by the format of the transcoding template.
-
{ExtName}: The extension of the original file.
-
(Optional) Set Thumbnail
Turn on the switch to use the generated image as the thumbnail for the media file.
-
-
Click OK to save the Intelligent Thumbnail node configuration.
Publishing node
-
To open the publish settings page, click the pen icon next to the Publish node.
-
Configure the publishing parameters.
Parameter
Description
Publish Type
Specifies how media is published after the workflow completes.
-
Manual: The media remains unpublished when the workflow completes successfully. You must publish it manually. For instructions, see Manage Media.
-
Auto: Automatically publishes the media when the workflow completes successfully.
NoteThe publishing state affects the access permissions for the output files.
-
Not Published: video, audio, and snapshot files have private access permissions.
-
Published: The video, audio, and snapshot files inherit the access permissions from the bucket where they are stored.
-
-
-
Click OK to save the Publish node settings.
Next steps
For M3U8 files from live recordings, repeatedly updating the file in OSS using the PutObject operation during the recording can trigger the workflow multiple times. To prevent redundant executions, set the workflow to manual mode. After the M3U8 file is finalized, call the AddMedia API to trigger the workflow. Alternatively, if you use an automatic trigger, wait until the live recording is complete before uploading the M3U8 file to OSS in a single operation.
-
By default, a new workflow is Active and set to automatic trigger. This means that regardless of the upload method (such as via OSS or the MPS console), the workflow runs automatically whenever a matching file is uploaded to the Input node's Input Path. For information about how to upload files, see Upload a video. For details on trigger rules, see Workflow triggering rules for files.
-
To manually trigger a workflow for new files:
-
Call the UpdateMediaWorkflowTriggerMode API and set the TriggerMode parameter to NotInAuto to modify an existing workflow so that it is not automatically triggered. Or, call the AddMediaWorkflow API and set the TriggerMode parameter to NotInAuto to create a new workflow that is not automatically triggered.
-
To trigger the workflow, call the AddMedia API to submit a new media job.
-
-
To trigger a workflow for existing files, call the AddMedia API to submit a new media job.
-
To edit or disable a workflow, see Edit and disable a workflow.