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.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.
- If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
Action | Access Level | Resource Type (*: required) | Condition Key | Alias | Dependencies |
|---|
mpc:transcodeTask:create | Write | - | - | - | - |
URI
POST /v1/{project_id}/transcodings
Table 1 Path Parameters Parameter | Mandatory | Type | Description |
|---|
project_id | Yes | String | Project ID. For details about how to obtain the project ID, see Obtaining a Project ID. |
Request Parameters
Table 3 Request body parameters 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 list. |
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. If this parameter is specified, the output object name is object/file_name. If this parameter is not specified, the output object name is object/xxx, where xxx is allocated by MPC.
|
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 NOTE: 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 | Multi-snapshot task, which is an array. A maximum of 20 members are supported. |
image_sprites | No | Array of ImageSprite objects | Image sprite parameter, which is an array. A maximum of 20 members are supported. |
priority | No | Integer | Task priority. Possible values: 9: high 6: medium (default)
|
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 |
metadata | No | Array of FileMetaData objects | Metadata setting. By default, only AIGC is supported. |
Table 4 TransIdTemplate Parameter | Mandatory | Type | Description |
|---|
template_id | Yes | Integer | ID of the template used by the output video. |
output | No | ObsObjInfo object | Output path. If this parameter is not set, the output is stored together with the outer transcoded output. Note: For HLS multiple outputs, if the path of each output is different, index.m3u8 is unavailable, and audio and video separation is unavailable. |
output_filename | No | String | Output file name. |
Table 5 AvParameters 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 this parameter is not set, the output is stored together with the outer transcoded output. Note: For HLS multiple outputs, if the path of each output is different, index.m3u8 is unavailable, and audio and video separation is unavailable. |
output_filename | No | String | Output file name. |
Table 6 VideoParameters Parameter | Mandatory | Type | Description |
|---|
output_policy | No | String | Output policy: If output_policy is set to discard in video parameters and transcode in audio parameters, only audio is output. If output_policy is set to transcode in video parameters and to discard in audio parameters, only video is output. If output_policy is set to copy in video parameters, the original video is copied without codec. If output_policy is set to copy in audio parameters, the original audio is copied without codec. output_policy cannot be set to discard in video and audio parameters at the same time. If output_policy is set to transcode in video and video parameters at the same time, video and audio are output.
The options are as follows: |
codec | No | Integer | Video codec. Possible values: 1: VIDEO_CODEC_H264 2: VIDEO_CODEC_H265
|
crf | No | Object | Factor for controlling the constant video bitrate. The value range is [0, 51]. |
max_bitrate | No | Integer | Maximum output bitrate. The value can be 0 or an integer from 40 to 800,000. Unit: kbit/s This field is used when the Constant Rate Factor (CRF) is used. The value is generally set to 1.5 times of the average bitrate of the source file. |
bitrate | No | Integer | Average output bitrate Its value is 0 or an integer ranging from 40 to 50,000. Unit: kbit/s If this parameter is set to 0, the average output bitrate is an adaptive value. |
buf_size | No | Integer | Buffer size. The value can be 0 or an integer from 40 to 800,000. Unit: kbit |
profile | No | Integer | Encoding profile. Possible values: 1: VIDEO_PROFILE_H264_BASE 2: VIDEO_PROFILE_H264_MAIN 3: VIDEO_PROFILE_H264_HIGH 4: VIDEO_PROFILE_H265_MAIN
|
level | No | Integer | Encoding level Options: 0: AUTO 1: VIDEO_LEVEL_1_0 2: VIDEO_LEVEL_1_1 3: VIDEO_LEVEL_1_2 4: VIDEO_LEVEL_1_3 5: VIDEO_LEVEL_2_0 6: VIDEO_LEVEL_2_1 7: VIDEO_LEVEL_2_2 8: VIDEO_LEVEL_3_0 9: VIDEO_LEVEL_3_1 10: VIDEO_LEVEL_3_2 11: VIDEO_LEVEL_4_0 12: VIDEO_LEVEL_4_1 13: VIDEO_LEVEL_4_2 14: VIDEO_LEVEL_5_0 15: VIDEO_LEVEL_5_1
|
preset | No | Integer | Encoding quality. The options include: 1: VIDEO_PRESET_SPEED (fast encoding) 3: VIDEO_PRESET_HIGHQUALITY (high-quality encoding). 4: VIDEO_PRESET_QUALITY (quality encoding). 5: VIDEO_PRESET_BALANCE (balanced encoding)
The default value is 1. |
max_iframes_interval | No | Integer | Maximum I-frame interval. The value ranges from 2 to 10. Default value: 5 Unit: second |
bframes_count | No | Integer | Maximum B-frame interval. Range Unit: frame |
frame_rate | No | Integer | Frame rate. The value is 0 (adaptive) or ranges from 5 to 60. Unit: FPS NOTE: If the configured frame rate is not within the value range, the value is automatically changed to 0. If the configured frame rate is higher than the frame rate of the input file, the value is automatically changed to the frame rate of the input file. |
width | No | Integer | Video width, in pixels H.264: The value is a multiple of 2 from 32 to 4,096. H.265: The value is a multiple of 2 from 320 to 4,096.
|
height | No | Integer | Video height, in pixels H.264: The value is a multiple of 2 from 32 to 2,880. H.265: The value is a multiple of 2 from 240 to 2,880.
|
black_cut | No | Integer | Whether to enable black bar removal. 0: disables black bar removal 1: enables black bar removal and low-complexity algorithms for videos longer than 5 minutes 2: enables black bar removal and high-complexity algorithms for videos no longer than 5 minutes
|
stream_name | No | String | Stream name |
Table 7 Audio Parameter | Mandatory | Type | Description |
|---|
output_policy | No | String | Output policy: If output_policy is set to discard in video parameters and transcode in audio parameters, only audio is output. If output_policy is set to transcode in video parameters and to discard in audio parameters, only video is output. If output_policy is set to copy in video parameters, the original video is copied without codec. If output_policy is set to copy in audio parameters, the original audio is copied without codec. output_policy cannot be set to discard in video and audio parameters at the same time. If output_policy is set to transcode in video and video parameters at the same time, video and audio are output.
The options are as follows: |
codec | No | Integer | Audio codec Possible options are: 1: AAC 2: HEAAC1 3: HEAAC2 4: MP3
|
sample_rate | No | Integer | Audio sampling rate The options are as follows: 1: AUDIO_SAMPLE_AUTO 2: AUDIO_SAMPLE_22050 (22,050 Hz) 3: AUDIO_SAMPLE_32000 (32,000 Hz) 4: AUDIO_SAMPLE_44100 (44,100 Hz) 5: AUDIO_SAMPLE_48000 (48,000 Hz) 6: AUDIO_SAMPLE_96000 (96,000 Hz)
NOTE: When the encoding format is MP3, the audio sampling ratio cannot be 6. |
bitrate | No | Integer | Audio bitrate. The value is 0 or ranges from 8 to 1,000. Unit: kbit/s |
channels | Yes | Integer | Number of audio channels Options: 1: AUDIO_CHANNELS_1 (mono) 2: AUDIO_CHANNELS_2 (stereo) 6: AUDIO_CHANNELS_5_1 (5.1 surround sound)
When the media packaging format is audio (MP3), the number of audio channels cannot be set to 5.1. |
Table 8 Common 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. Value range: [2,10] Unit: second |
dash_interval | No | Integer | DASH segment duration. This parameter is used only when pack_type is set to 2 or 3. Value range: [2,10] Unit: second |
pack_type | Yes | Integer | Container format. The options include: 1: HLS 2: DASH 3: HLS+DASH 4: MP4 5: MP3 6: ADTS 8: MOV 9: FLV 10: AVI
NOTE: If pack_type is set to 5 or 6, do not configure video parameters. If pack_type is set to 9, multi-audio is not supported. If pack_type is set to 10, H.265 encoding is not supported. |
Table 9 AdditionalManifests 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 |
Table 10 WatermarkRequest 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. |
Table 11 ImageWatermark Parameter | Mandatory | Type | Description |
|---|
dx | No | String | Horizontal offset between the start point of the watermark and the vertex of the output video Possible options are: Integer: horizontal offset between the watermark start point and the video vertex, in pixels. Value range: [0, 4096] Decimal: horizontal offset ratio of the watermark start point to the video width. The value range is (0, 1). Up to four decimal places are displayed, for example, 0.9999. If the value contains more than four decimal places, the part behind the fourth decimal place is automatically truncated.
For example, if the output video width is 1920 pixels, dx is set to 0.1, and referpos is set to TopRight, the horizontal offset between the upper right corner of the watermark and the right vertex of the video is 192. |
dy | No | String | Vertical offset between the start point of the watermark and the vertex of the output video Possible options are: Integer: vertical offset between the watermark start point and the video vertex, in pixels. The value range is [0, 4096]. Decimal: vertical offset ratio of the watermark start point to the video height. The value range is (0, 1). Up to four decimal places are displayed, for example, 0.9999. If the value contains more than four decimal places, the part behind the fourth decimal place is automatically truncated.
For example, if the output video height is 1080 pixels, dy is set to 0.1, and referpos is set to TopRight, the vertical offset between the upper right corner of the watermark and the right vertex of the video is 108. |
referpos | No | String | Watermark position. The options include: TopRight: upper right corner TopLeft: upper left corner BottomRight: lower right corner BottomLeft: lower left corner
ClockWise: clockwise AntiClockWise: counterclockwise Random: random placement |
timeline_start | No | String | Watermark start time, which is used together with timeline_duration. Its value is a digit. Unit: second |
timeline_duration | No | String | Watermark duration, which is used together with timeline_start. The value ranges from number to ToEND. ToEND indicates that the watermark lasts until the end of the video. Default value: ToEND |
random_time_min | No | String | Minimum rotation interval, in seconds. Value range: (0,3600000] |
random_time_max | No | String | Maximum rotation interval, in seconds. Value range: (0,3600000] |
image_process | No | String | Image watermarking method. This parameter is valid only when type is set to Image. Options: Original: Only simple scaling is performed. Grayed: Image graying is performed. Transparent: The transparency of the source image is retained. If the source image contains transparent areas, these areas remain transparent after transcoding, allowing the underlying background or image to be displayed. This enables seamless fusion between the image and the background.
|
width | No | String | Watermark image width. The options are as follows: Integer: width of a watermark image, in pixels. The value ranges from 8 to 4,096. Decimal: ratio of the width to the width of the output video. The value range is (0, 1). Up to four decimal places are displayed, for example, 0.9999. If the value contains more than four decimal places, the part behind the fourth decimal place is automatically truncated.
|
height | No | String | Watermark image height. The options are as follows: Integer: height of a watermark image, in pixels. The value ranges from 8 to 4,096. Decimal: ratio of the height to the height of the output video. The value is greater than 0 and less than 1, and can contain up to four decimal places, for example, 0.9999. If the value contains more than four decimal places, the part behind the fourth decimal place is automatically truncated.
|
base | No | String | Video on which a watermark is overlaid Options: input: A watermark is overlaid on the input file. The size of the watermark in the transcoded file is scaled based on the aspect ratio of the video. output: A watermark is overlaid on the transcoded file. The size of the watermark in the transcoded file is not scaled based on the aspect ratio of the video.
|
Table 12 TextWatermark Parameter | Mandatory | Type | Description |
|---|
dx | No | String | Horizontal offset between the start point of the watermark and the vertex of the output video Possible options are: Integer: horizontal offset between the watermark start point and the video vertex, in pixels. Value range: [0, 4096] Decimal: horizontal offset ratio of the watermark start point to the video width. The value range is (0, 1). Up to four decimal places are displayed, for example, 0.9999. If the value contains more than four decimal places, the part behind the fourth decimal place is automatically truncated.
For example, if the output video width is 1920 pixels, dx is set to 0.1, and referpos is set to TopRight, the horizontal offset between the upper right corner of the watermark and the right vertex of the video is 192. |
dy | No | String | Vertical offset between the start point of the watermark and the vertex of the output video Possible options are: Integer: vertical offset between the watermark start point and the video vertex, in pixels. The value range is [0, 4096]. Decimal: vertical offset ratio of the watermark start point to the video height. The value range is (0, 1). Up to four decimal places are displayed, for example, 0.9999. If the value contains more than four decimal places, the part behind the fourth decimal place is automatically truncated.
For example, if the output video height is 1080 pixels, dy is set to 0.1, and referpos is set to TopRight, the vertical offset between the upper right corner of the watermark and the right vertex of the video is 108. |
referpos | No | String | Watermark position. The options include: TopRight: upper right corner TopLeft: upper left corner BottomRight: lower right corner BottomLeft: lower left corner
ClockWise: clockwise AntiClockWise: counterclockwise Random: random placement |
timeline_start | No | String | Watermark start time, which is used together with timeline_duration. Its value is a digit. Unit: second |
timeline_duration | No | String | Watermark duration, which is used together with timeline_start. The value ranges from number to ToEND. ToEND indicates that the watermark lasts until the end of the video. Default value: ToEND |
random_time_min | No | String | Minimum rotation interval, in seconds. Value range: (0,3600000] |
random_time_max | No | String | Maximum rotation interval, in seconds. Value range: (0,3600000] |
font_name | No | String | Font. Only fzyouh is supported. |
font_size | No | Integer | Font size The value ranges from 4 to 120. |
font_color | No | String | Font color. The options are as follows: black, blue, white, green, red, yellow, brown, gold, pink, orange, and purple |
base | No | String | Video on which the watermark is overlaid. Possible values: input: The watermark is overlaid on the input file. After transcoding, the size of the output file is scaled based on the aspect ratio of images. output: The watermark is overlaid on the output file.
Default value: input |
Table 13 Thumbnail 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 |
Table 14 ThumbnailPara Parameter | Mandatory | Type | Description |
|---|
type | No | String | Sampling type Possible options are: Default value: TIME |
amount | No | Integer | If the black pixel ratio is greater than or equal to this threshold, the frame is classified as a black frame. |
threshold | No | Integer | If the pixel value is below this threshold, the pixel is treated as black. |
time | No | Integer | Interval for capturing snapshots. Value range: [1,100]. Default value: 12. Unit: second |
start_time | No | Integer | Start time for the sampling type set to TIME. This parameter is used together with time. Default value: 0 Unit: second NOTE: If the value of start_time exceeds the media file duration, frames are not extracted. |
duration | No | Integer | Capture duration when the sampling type is set to TIME. This parameter is used together with time and start_time, indicating that the first snapshot is captured at the time specified by start_time and snapshots are captured at the interval specified by time until the duration specified by this parameter elapses. Value range: [Number, ToEND]. ToEND indicates that snapshot capturing lasts till the end of the video. Default value: ToEND Unit: second NOTE: 0 indicates that snapshot capturing lasts from start_time to the end of the video. |
dots | No | Array of integers | Array of time points when a snapshot is captured For example, if you enter [1,3,5], the image frames at the first, third, and fifth seconds of the video are captured. |
dots_ms | No | Array of integers | Time point array of snapshot at a specified time in synchronous snapshot mode, in milliseconds. For example, enter [1000] to capture the image frame at the 1000th ms position of the video. Only one time point is allowed. |
output_filename | No | String | Snapshot file name. If only one snapshot is captured (the sampling type is DOTS and only one time point is specified), the output file name is the specified snapshot file name. If multiple snapshots are captured (the sampling type is DOTS and multiple time points are specified or the sampling type is TIME), an output file name contains the specified snapshot file name followed by the time point, for example, output_filename_10.jpg. If you specify the snapshot to be compressed into a TAR package, the output file name is the TAR package name.
|
format | No | Integer | Snapshot file format. The value is: 1: JPG |
width | No | Integer | Image width The options are as follows: Unit: pixel |
height | No | Integer | Image height The options are as follows: Unit: pixel |
max_length | No | Integer | The longest side of a snapshot. The width of the snapshot is scaled proportionally with the longest side and input video pixel. The value ranges from 240 to 3,840. Unit: pixel NOTE: This parameter is used together with width/height. If neither width nor height is 0, the image size is calculated based on width/height. Otherwise, the image size is calculated based on max_length. If this parameter and width/height are not selected, snapshots are output based on the aspect ratio of the source media file. |
Table 15 ImageSprite Parameter | Mandatory | Type | Description |
|---|
params | Yes | ImageSpritePara object | Image sprite parameters. |
output | No | ObsObjInfo object | Output path of the image sprite. If this parameter is left blank, the image sprite is stored together with the transcoded output. |
output_object_name | No | String | Output file name of the image sprite. If it is not specified, the default naming convention is: {inputName}imageSprite{sprite ID}_{number}.{format}. {sprite ID} and {number} starts from 0 and increments sequentially. |
webvtt_object_name | No | String | Output path of the Web VTT file after the image sprite is captured. The value must be a relative path. If it is not specified, the default relative path is {inputName}imageSprite{image sprite ID}.vtt. |
Table 16 ImageSpritePara Parameter | Mandatory | Type | Description |
|---|
sample_type | Yes | String | Sampling type. The options are: PERCENT: by percentage TIME: by time interval
|
sample_interval | Yes | Integer | Sampling interval. When sample_type is set to PERCENT, the sampling interval is specified as a percentage. The value range is (0,100]. When sample_type is set to TIME, the sampling interval is specified as a time in seconds. The value range is (0,360000].
|
row_count | Yes | Integer | Number of rows of sub-images in the image sprite. The number of rows multiplied by the number of columns cannot exceed 100. |
column_count | Yes | Integer | Number of columns of sub-images in the image sprite. The number of rows multiplied by the number of columns cannot exceed 100. |
width | No | Integer | Maximum width (or long side) of sub-images in the image sprite. The value can be 0 or a number within [96, 4096], in pixels. If both width and height are 0, the resolution follows the source. If width is 0 but height is not 0, the width is scaled proportionally. If width is not 0 but height is 0, the height is scaled proportionally. If neither width nor height is 0, the resolution is manually specified.
|
height | No | Integer | Maximum height (or short side) of sub-images in the image sprite. The value can be 0 or a number within [96, 4096], in pixels. If both width and height are 0, the resolution follows the source. If width is 0 but height is not 0, the width is scaled proportionally. If width is not 0 but height is 0, the height is scaled proportionally. If neither width nor height is 0, the resolution is manually specified.
|
resolution_adaptive | No | String | Resolution adaptation. The options are: open: width represents the long side of the video, and height represents the short side of the video. close: width indicates the width of the video, and height indicates the height of the video.
|
fill_type | No | String | Fill mode. When the configured width and height parameters of the video stream do not match the aspect ratio of the source video, transcoding applies a fill method. The options include: stretch: stretches each frame to fill the entire output frame. This may cause the transcoded video to appear distorted (compressed or elongated). black: keeps the aspect ratio of the video unchanged and fills the remaining edges with black. white: keeps the aspect ratio of the video unchanged and fills the remaining edges with white.
|
format | No | String | Image format. The value can be jpg or png. The default value is jpg. |
Table 17 Subtitle 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: 0: No subtitle file is generated. 1: An external subtitle file is inserted into the video stream. 2: A WebVTT subtitle file is generated.
|
Table 19 Encryption Parameter | Mandatory | Type | Description |
|---|
hls_encrypt | No | HlsEncrypt object | Encryption parameters for HLS videos |
Table 20 HlsEncrypt 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 |
Table 21 Crop Parameter | Mandatory | Type | Description |
|---|
duration | No | Integer | Duration of a captured video, starting from 0 seconds. Unit: second |
Table 22 AudioTrack Parameter | Mandatory | Type | Description |
|---|
type | No | Integer | Audio track selection method. Possible values: 0: selected by default 1: selected manually
|
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 |
Table 23 MultiAudio 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. |
Table 24 AudioFile Parameter | Mandatory | Type | Description |
|---|
tracks_info | No | Array of TracksInfo objects | Audio track information |
input | No | ObsObjInfo object | Storage location of an input file |
Table 25 TracksInfo 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. |
Table 26 ObsObjInfo Parameter | Mandatory | Type | Description |
|---|
bucket | Yes | String | OBS bucket name |
location | Yes | String | Region where an OBS bucket is located. It must be the same as the region where MPC is deployed. |
object | Yes | String | OBS object path, which complies with the OSS Object definition. If this parameter is used for an input, an object must be specified. If this parameter is used for an output, only the directory where the output is to be stored needs to be specified.
A subtitle file name that contains special characters (such as [) will cause the transcoding task to fail. |
file_name | No | String | File name, which can contain a maximum of 180 characters. If this parameter is specified, the output object name is object/file_name. If this parameter is not specified, the output object name is object/xxx, where xxx is specified by MPC.
When it is used as an output file name: This parameter is valid for container format conversion. The output file name must be specified. If the output file name needs to be specified during transcoding, use the parameter output_filenames. This parameter is valid for parsing. If a file name is specified during parsing, the parsing parameters are written to the specified file name and the file metadata is obtained by querying JSON data in the API response. This parameter is invalid for snapshot capturing. This parameter is invalid for conversion into animated GIFs. When the output file is in HLS format, a file name containing index, such as index.m3u8, will cause playback failure.
|
Table 27 VideoProcess 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. NOTE: 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. NOTE: 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: 0: Do not rotate. 1: Rotate a video by 90 degrees clockwise. 2: Rotate a video by 180 degrees clockwise. 3: Rotate a video by 270 degrees clockwise.
|
adaptation | No | String | Adaptive resolution. Possible values: SHORT: adaptive width LONG: adaptive height NONE: non-adaptive
|
fill_type | No | String | This parameter is valid only when adaptation is set to NONE. stretch: stretches each frame to fill the entire output frame. black: keeps the aspect ratio of the video unchanged and fill the remaining edges with black. white: keeps the aspect ratio of the video unchanged and fill the remaining edges with white.
|
upsample | No | Integer | Whether to enable upsampling, for example, converting a 480p video source to 720p. The options include: |
hls_segment_type | No | String | HLS segment type. Options: If this parameter is not specified, TS segments are used by default. |
Table 28 AudioProcess Parameter | Mandatory | Type | Description |
|---|
volume | No | String | Adjusts volume. The options are as follows: auto: The volume is automatically adjusted. dynamic: The volume is manually adjusted. You need to set the allowed adjustment range. original: The volume is not adjusted.
|
volume_expr | No | Integer | Volume adjustment amplitude. This parameter is used only when volume is set to dynamic. The value ranges from –15 to 15. Unit: dB |
Response Parameters
Status code: 202
Table 30 Response body parameters Parameter | Type | Description |
|---|
task_id | Integer | Task ID generated after the task is accepted. Transcoding task IDs start at 1. After reaching 2,146,483,647, the sequence resets to 1. Therefore, this ID should not be used as a unique identifier. |
Status code: 403
Table 31 Response body parameters 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. |