Creating a Transcoding Task
Function
This API is used to create a transcoding task to transcode media files, and add watermarks and capture snapshots during transcoding. A transcoding template must be configured before video transcoding.
Ensure that an input media file is stored in an OBS bucket in the same region as MPC and the permission for accessing the OBS bucket has been granted to MPC.
Calling Method
For details, see Calling APIs.
URI
POST /v1/{project_id}/transcodings
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Project ID. For details about how to obtain the project ID, see Obtaining a Project ID. (tag:hc,hk) Project ID. For details about how to obtain the project ID, see [Obtaining a Project ID]. (tag:hcso,g42,cmcc) |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
No |
String |
User token The token can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token. |
Authorization |
No |
String |
Authentication information. This parameter is mandatory when AK/SK-based authentication is used. |
X-Project_Id |
No |
String |
Project ID. This parameter is mandatory when AK/SK-based authentication is used. It is same as the project ID in path parameters. |
X-Sdk-Date |
No |
String |
Time when the request is sent. This parameter is mandatory when AK/SK-based authentication is used. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
input |
No |
ObsObjInfo object |
Storage location of an input file. This parameter is mandatory in scenarios where audio is not added. |
output |
Yes |
ObsObjInfo object |
Storage location of an output file |
trans_template_id |
No |
Array of integers |
Transcoding template ID. If the av_parameter parameter is not contained, this parameter must be carried and its value is an array. Each transcoding output corresponds to a transcoding template ID. A maximum of nine template IDs are supported. Only the following parameters in transcoding templates can be changed: Video bitrate, height, and width |
trans_template_list |
No |
Array of TransIdTemplate objects |
Transcoding template array |
av_parameters |
No |
Array of AvParameters objects |
Transcoding parameter If both trans_template_id and this parameter are specified, this parameter is preferentially used for transcoding. If trans_template_id is not specified, this parameter is mandatory. |
additional_manifests |
No |
Array of AdditionalManifests objects |
Customized parameter for the primary index. |
output_filenames |
No |
Array of strings |
Name of an output file. Each transcoded file has a name that corresponds to the sequence of the transcoding template ID array. |
user_data |
No |
String |
Custom user data. You can call a query API or send a notification to transfer this field to users. |
watermarks |
No |
Array of WatermarkRequest objects |
Array of image watermarks. Up to 10 watermarks are supported. |
thumbnail |
No |
Thumbnail object |
Snapshot information Snapshots are generated only when the transcoding template specified by trans_template_id or the output resolution specified by av_parameters is 1920 x 1080, 1280 x 720, 854 x 480, or 480 x 270. |
thumbnails |
No |
Array of Thumbnail objects |
Multiple screenshot task, array, supports up to 20 members. |
priority |
No |
Integer |
Task priority. Possible values: |
subtitle |
No |
Subtitle object |
Subtitle parameters |
encryption |
No |
Encryption object |
Encryption parameters |
crop |
No |
Crop object |
Number of seconds cropped from a video for which transcoding is performed on. |
audio_track |
No |
AudioTrack object |
Audio track parameters |
multi_audio |
No |
MultiAudio object |
Multi-language and multi-channel audio parameters |
video_process |
No |
VideoProcess object |
Video processing parameters |
audio_process |
No |
AudioProcess object |
Audio processing parameters |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
template_id |
Yes |
Integer |
Output video template ID |
output |
No |
ObsObjInfo object |
Output path, if not filled, will be combined with the outer layer transcoding output. Explanation: When multiple HLS outputs are used, if the output paths are different, index.m3u8 will not be available, and audio and video separation will not be available. |
output_filename |
No |
String |
Output file name |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
video |
No |
VideoParameters object |
Video parameters |
audio |
No |
Audio object |
Audio parameters |
common |
Yes |
Common object |
Common parameters |
output |
No |
ObsObjInfo object |
Output path, if not filled, will be combined with the outer layer transcoding output. Explanation: When multiple HLS outputs are used, if the output paths are different, index.m3u8 will not be available, and audio and video separation will not be available. |
output_filename |
No |
String |
Output file name |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
PVC |
No |
Boolean |
Whether to enable low-bitrate HD The options are as follows: (The value 0 indicates that the function is disabled. Other positive integers and negative values indicate true.) |
hls_interval |
No |
Integer |
HLS segment duration. This parameter is used only when pack_type is set to 1 or 3. The value ranges from 2 to 10. Unit: second |
dash_interval |
No |
Integer |
DASH segment duration. This parameter is used only when pack_type is set to 2 or 3. The value ranges from 2 to 10. Unit: second |
pack_type |
Yes |
Integer |
Packaging type Possible options are: If pack_type is set to 5 or 6, do not configure video parameters. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
manifest_name_modifier |
No |
String |
Customized index file name extension |
selected_outputs |
No |
Array of strings |
Name of the selected stream |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
input |
No |
ObsObjInfo object |
Storage location of an input file. This parameter is mandatory if an image watermark is used. |
template_id |
No |
String |
ID of a watermark template. You can call an API to create a watermark template. |
text_context |
No |
String |
Base64-coded text watermark. This parameter must be configured when type is set to Text. For example, if the text watermark to be added is "Test Text Watermark", the value of content is 5rWL6K+V5paH5a2X5rC05Y2w. |
image_watermark |
No |
ImageWatermark object |
Watermark parameters used for overwriting the parameters with the same names in the watermark template |
text_watermark |
No |
TextWatermark object |
Text watermark configurations. If text_context is set, this field cannot be left blank. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
tar |
No |
Integer |
Whether to compress captured snapshots to a TAR package. Possible values: |
out |
No |
ObsObjInfo object |
Storage location of snapshots. If this parameter is not set, snapshots are stored in the same location as the output file. |
params |
Yes |
ThumbnailPara object |
Snapshot parameters |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
input |
No |
ObsObjInfo object |
Storage location of an SRT file |
inputs |
No |
Array of MulInputFileInfo objects |
Storage location of SRT files |
subtitle_type |
No |
Integer |
Subtitle file type. Possible values: |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
language |
No |
String |
Subtitle language tag. The ISO 639-2 encoding format (https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes) is recommended. |
input |
No |
ObsObjInfo object |
Storage location of a subtitle file |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
hls_encrypt |
No |
HlsEncrypt object |
Encryption parameters for HLS videos |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
key |
Yes |
String |
Base64-encoded content encryption key |
url |
Yes |
String |
The key carries the service address, and can be decrypted to play HLS segments. |
iv |
No |
String |
Initial vector, which is a random number in base64Binary format |
algorithm |
No |
String |
Encryption algorithm. Possible values: Default value: AES-128-CTR |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
duration |
No |
Integer |
Duration of a captured video, starting from 0 seconds. Unit: second |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
type |
No |
Integer |
Audio track selection method. Possible values: |
left |
No |
Integer |
ID of the audio track where the left audio channel is |
right |
No |
Integer |
ID of the audio track where the right audio channel is |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
tracks_info |
No |
Array of TracksInfo objects |
Audio track information |
audio_files |
No |
Array of AudioFile objects |
Parameters about a single audio file |
default_language |
No |
String |
Default language tag. The ISO 639-2 encoding format (https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes) is recommended. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
tracks_info |
No |
Array of TracksInfo objects |
Audio track information |
input |
No |
ObsObjInfo object |
Storage location of an input file |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
channel_layout |
No |
String |
Audio channel layout of the audio track |
language |
No |
String |
Audio language tag. The ISO 639-2 encoding format (https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes) is recommended. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
hls_init_count |
No |
Integer |
Number of HLS start segments The value ranges from 0 to 10 and defaults to 0. This parameter is used together with hls_init_interval to specify the duration of the first hls_init_count HLS segments. The value 0 indicates that there are no HLS start segments. |
hls_init_interval |
No |
Integer |
Duration of the first hls_init_count HLS segments The value ranges from 2 to 10 and defaults to 5. This parameter is valid only when the value of hls_init_count is not 0. |
hls_storage_type |
No |
String |
HLS media streams storage |
rotate |
No |
Integer |
Clockwise rotation angle of a video. Possible values: |
adaptation |
No |
String |
Adaptive resolution. Possible values: |
fill_type |
No |
String |
When adaptation is set to NONE:
|
upsample |
No |
Integer |
Whether to enable upsampling, for example, converting a 480p video to a 720p one. Possible values: |
hls_segment_type |
No |
String |
HLS segment type. Options: If this parameter is not specified, TS segments are used by default. |
Response Parameters
Status code: 202
Parameter |
Type |
Description |
---|---|---|
task_id |
Integer |
Task ID generated after the task is accepted. |
Status code: 403
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code |
error_msg |
String |
Error description |
Example Requests
Creates a video transcoding task.
POST https://{endpoint}/v1/{project_id}/transcodings { "input" : { "bucket" : "example-bucket", "location" : "region01", "object" : "example-path/input.mp4" }, "output" : { "bucket" : "example-bucket", "location" : "region01", "object" : "example-path/output" }, "trans_template_id" : [ 1002, 1003, 1004, 1005 ], "priority" : "9", "subtitle" : { "subtitle_type" : 1, "input" : { "bucket" : "example-bucket", "location" : "region01", "object" : "example-subtitle.srt" } }, "encryption" : { "hls_encrypt" : { "iv" : "******", "key" : "******", "url" : "http://{your-keyserver}", "algorithm" : "AES-128-CBC" } }, "thumbnail" : { "out" : { "bucket" : "example-bucket", "location" : "region01", "object" : "example/path" }, "tar" : 1, "params" : { "time" : 2, "format" : 1, "max_length" : 480 } } }
Example Responses
Status code: 202
Transcoding task created successfully.
{ "task_id" : 100211 }
Status code: 403
Failed to create a transcoding task.
{ "error_code" : "MPC.10202", "error_msg" : "Invalid request parameter" }
Status Codes
Status Code |
Description |
---|---|
202 |
Transcoding task created successfully. |
403 |
Failed to create a transcoding task. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot