ApsaraVideo Media Processing (MPS) provides three modes to trigger workflows that meet different requirements for the input path and trigger automation. This topic introduces the three workflow trigger modes by describing their respective scenarios and requirements.
Comparison of trigger modes
Trigger mode | Scenario |
Automatic trigger | A file needs to be processed by using the preset workflow immediately after the file is uploaded to the specified path. |
Manual trigger for files under a verified path |
|
Manual trigger for files under different paths | Files stored in different paths need to be processed by using the same workflow. |
Mode 1: Automatic trigger
Create a workflow and set the trigger mode to automatic trigger. By default, when you create a workflow, its trigger mode is automatic trigger. For more information about how to create a workflow, see Create a workflow.
Add a file. The following requirements must be met:
The file is not generated by MPS or Intelligent Media Services (IMS). For more information, see the "Files are not generated by MPS or IMS" section of this topic.
The file path complies with the path matching rules. For more information, see the "Path matching rules" section of this topic.
The file name complies with the file name extension matching rules. For more information, see the "File name extension matching rules" section of this topic.
The file is uploaded by calling one of the following API operations of OSS.
Operation
Description
PutObject
Uploads an object.
PostObject
Uploads an object to a specific bucket by using an HTML form.
CopyObject
Copies an object within a bucket or across buckets in the same region.
CompleteMultipartUpload
Combines the uploaded parts into an object after all parts of the object are uploaded.
PutSymlink
Creates a symbolic link for an object, which allows you to access the object by using the symbolic link.
Mode 2: Manual trigger for files under a verified path
Create a workflow. Before you add files, you must change the trigger mode of the workflow to manual trigger by calling the UpdateMediaWorkflowTriggerMode operation. For more information about how to create a workflow, see Create a workflow.
Add a file. The following requirements must be met:
The file path complies with the path matching rules. For more information, see the "Path matching rules" section of this topic.
The file name complies with the file name extension matching rules. For more information, see the "File name extension matching rules" section of this topic.
The file is uploaded by calling an API operation of OSS of your choice.
After you add a file, call the AddMedia operation to specify the file to be processed and the ID of the workflow to be triggered based on your business requirements.
Mode 3: Manual trigger for files under different paths
Create a workflow. Before you add files, you must change the trigger mode of the workflow to manual trigger by calling the UpdateMediaWorkflowTriggerMode operation. For more information about how to create a workflow, see Create a workflow.
Add a file. The following requirements must be met:
The file is stored in the region in which MPS is activated.
The file is uploaded by calling an API operation of OSS of your choice.
After you add a file, call the AddMedia operation to specify the file to be processed and the ID of the workflow to be triggered based on your business requirements. In addition, set the InputUnbind parameter to false, which specifies that MPS does not check the file against the path matching rules or file name extension matching rules.
File matching rules
Files are not generated by MPS or IMS
If the input path of a workflow is the same as the output path of an MPS or IMS job, files generated by the MPS or IMS job cannot trigger the workflow. This prevents a workflow from being cyclically triggered due to improper settings of input and output paths. Example:
The output path of Workflow A and the input path of Workflow B are both http://bucket.oss-cn-hangzhou.aliyuncs.com/A/.
If the input file http://bucket.oss-cn-hangzhou.aliyuncs.com/A/example.flv is generated by Workflow A, Workflow B cannot be triggered.
If the input file http://bucket.oss-cn-hangzhou.aliyuncs.com/A/example.flv is directly uploaded to the path http://bucket.oss-cn-hangzhou.aliyuncs.com/A/, Workflow B can be triggered.
Path matching rules
If the path of an input file is under the input path that you specified for the Input node of a workflow, the input file can trigger the workflow. Otherwise, the input file cannot trigger the workflow. Example:
The input path of a workflow cannot be the prefix of the input path of another workflow. Otherwise, both workflows are triggered if a file is uploaded to the latter path. For example, the input path of Workflow A is test and the input path of Workflow B is test1. If a file is uploaded to the test1 folder, both workflows are triggered.
If the input path that you specified for the Input node of a workflow ends with a forward slash (/), such as http://bucket.oss-cn-hangzhou.aliyuncs.com/A/
, the matching results of multiple input files are described in the following table.
Path of an input file | Matched |
http://bucket.oss-cn-hangzhou.aliyuncs.com/A/example.flv | Yes |
http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/example.flv | Yes |
http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/example.flv | Yes |
http://bucket.oss-cn-hangzhou.aliyuncs.com/A1/example.flv | No |
http://bucket.oss-cn-hangzhou.aliyuncs.com/A_video01.mp4 | No |
http://bucket.oss-cn-beijing.aliyuncs.com/A/example.flv | No |
http://bucket.oss-cn-hangzhou.aliyuncs.com/example.flv | No |
http://bucket.oss-cn-hangzhou.aliyuncs.com/D/example.flv | No |
If the input path that you specified for the Input node of a workflow does not end with a forward slash (/), such as http://bucket.oss-cn-hangzhou.aliyuncs.com/A
, the matching results of multiple input files are described in the following table.
Path of an input file | Matched |
http://bucket.oss-cn-hangzhou.aliyuncs.com/A/example.flv | Yes |
http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/example.flv | Yes |
http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/example.flv | Yes |
http://bucket.oss-cn-hangzhou.aliyuncs.com/A1/example.flv | Yes |
http://bucket.oss-cn-hangzhou.aliyuncs.com/A_video01.mp4 | Yes |
http://bucket.oss-cn-beijing.aliyuncs.com/A/example.flv | No |
http://bucket.oss-cn-hangzhou.aliyuncs.com/example.flv | No |
http://bucket.oss-cn-hangzhou.aliyuncs.com/D/example.flv | No |
File name extension matching rules
The following table describes the supported file name extensions. If the file name extension of an input file is in the table, the input file can trigger a workflow. Otherwise, the input file cannot trigger a workflow. Example:
The input file is http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/test1.flv
. The file name extension is .flv, which complies with the matching rules.
The check is based on the last file name extension. For example, if the input file is http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/test1.flv.mp4
, the file name extension is. mp4, which complies with the matching rules.
Type | File name extension |
Video file | .3gp, .asf, .avi, .dat, .dv, .flv, .f4v, .gif, .m2t, .m3u8, .m4v, .mj2, .mjpeg, .mkv, .mov, .mp4, .mpe, .mpg, .mpeg, .mts, ogg, .qt, .rm, .rmvb, .swf, .vob, .wmv, .webm, .mxf, and .quicktime |
Audio file | .s48, .aac, .ac3, .acm, .amr, .ape, .caf, .flac, .m4a, .mp3, .ra, .wav, .wma, and .aiff |