You need to enable JavaScript to run this app.
Torch Object Storage

Torch Object Storage

Copy page
Download PDF
Video transcoding
PutVideoConvertTemplate
Copy page
Download PDF
PutVideoConvertTemplate
Description​
This interface creates audio and video transcoding templates.​
Notes​
  • Each rule body must not exceed 20KB, and up to 100 custom templates can be configured.​
  • When using a sub-account, grant the current bucket PutDataProcessTemplate permission.​
Request syntax​
​
PUT /?process_template&tag=Transcode HTTP/1.1​
Host: {BucketName}.tos-cn-beijing.volces.com​
Date: Fri, 30 Jul 2021 08:05:36 +0000​
Content-Type: application/json​
Content-Length: <length>​
Authorization: authorization string​
​
{​
"Tag": "Transcode", // fixed identifier​
"Name": "my-template",​
"TranscodeConfig": {​
"TimeInterval": {​
"Start": 0,​
"Duration": 10000,​
},​
"Container": {​
"Format": "mp4"​
},​
"Video": {​
"Codec": "h264",​
"Width": 480,​
"Height": 480,​
"Crf": 1,​
"PixFmt": "yuv420p"​
"BitRate": 3000000,​
"Fps": 24,​
"Remove": false​
},​
"Audio": {​
"Codec": "aac",​
"BitRate": 128000,​
"SampleFormat": "fltp",​
"Channels": 2,​
"Remove": false​
},​
"Options": {​
"AIGCMetadata": {​
"Label": "1",​
"ContentProducer": "test_producer",​
"ProduceID": "12345",​
"ContentPropagator": "test_propagator",​
"PropagateID": "12345",​
"ReservedCode1": "ewogICAgIm****UiLAp9",​
"ReservedCode2": "ewogICAg*****UyIiwKfQ"​
}​
}​
}​
}​
​
Request parameters and headers ​
​
Name​
Type​
Required​
Example value​
Description​
process_template​
String​
Yes​
-​
Video transcoding template identifier.​
Tag​
String​
Yes​
Transcode​
Task type, Only Transcode is valid in audio and video transcoding scenarios.​
​
Request body elements​
​
Name​
Type​
Required​
Example value​
Description​
Name​
String​
Yes​
​
name​
Custom template name:​
  • Only supports a-z, A-Z, 0-9, _, -, and .; length cannot exceed 64 characters. Must start and end with a-z, A-Z, or 0-9.​
  • Multiple rules cannot be duplicated.​
TranscodeConfig​
Container​
Yes​
-​
Audio and video transcoding template details.​
Transcode​
Container​
Yes​
-​
Audio and video transcoding template details.​
Parent node: TranscodeConfig.​
TimeInterval​
Container​
No​
-​
Specify the transcoding duration.​
Parent node: Transcode.​
Start​
Integer​
No​
0​
Start time in milliseconds, default is 0.​
Parent node: TimeInterval.​
Duration​
Integer​
No​
10000​
Duration in milliseconds, default 0 means video length.​
Parent node: TimeInterval.​
Container​
Container​
Yes​
-​
Specify the transcoding container format.​
Parent node: Transcode.​
Format​
String​
​
Yes​
​
mp4​
Video file container formats, with the following values:​
  • mp4.​
  • ts.​
  • hls.​
  • mp3.​
  • aac.​
  • flac.​
  • m4a.​
  • oga.​
  • wav.​
  • ac3.​
  • opus.​
Parent node: Container.​
ClipConfig​
Container​
Not supported​
-​
Fragment configuration specifying hls transcoding fragment duration.​
Parent node: Container.​
Duration​
Integer​
No​
5000​
The fragment duration for hls transcoding, in milliseconds. The default value is 5000. Valid range is (0, 3600000).​
Parent node: ClipConfig.​
Video​
Container​
Yes​
-​
Video encoding parameters.​
Parent node: Transcode.​
Codec​
String​
No​
H.264​
Video codec format, with the following values:​
  • h264.​
  • h265.​
Parent node: Video.​
Width​
Integer​
No​
4096​
Video width in px, must be even, range [128, 4096].​
Parent node: Video.​
tip​
If only Width is set and Height is not set, the video height will be calculated based on the original aspect ratio.​
Height​
Integer​
No​
1024​
Video height in px, must be even, range [128, 4096].​
Parent node: Video.​
tip​
If only Height is set and Width is not, the video width will be calculated based on the original aspect ratio.​
Crf​
Integer​
No​
25​
Bitrate control factor for video files, with a value range of (0, 51].​
  • default 0 means not set.​
  • If Crf is set, the Bitrate setting becomes invalid.​
  • If Bitrate is empty, the encoder default value is used.​
Parent node: Video.​
PixFmt​
String​
No​
yuv420p​
Video pixel format.​
Parent node: Video.​
BitRate​
Integer​
No​
0​
Video output file bitrate in bps, range [10000, 50000000]. Default 0 means unset.​
Parent node: Video.​
Fps​
Integer​
No​
0​
Video frame rate, in fps, value range (0, 60], default 0 means unset.​
Parent node: Video.​
Remove​
Bool​
No​
false​
Whether to remove the source video stream; values are true or false.​
Parent node: Video.​
Audio​
Container​
No​
-​
Specify audio stream parameters.​
Parent node: Transcode.​
Codec​
String​
No​
aac​
​
Audio stream encoding formats, values are as follows:​
  • mp3.​
  • aac.​
  • flac.​
  • Vorbis.​
  • ac3.​
  • opus.​
  • pcm_s16le.​
Parent node: Audio.​
tip​
Different container formats support different audio codec formats. See Audio codec format support in different containers for details.​
BitRate​
Integer​
No​
128000​
Audio bitrate, in bits per second (bps), range: 1000~10000000. Use the original audio bitrate if set to 0. Some containers do not support specifying bitrate.​
Parent node: Audio.​
tip​
The number of channels supported varies by format. For details, see audio container parameter support.​
SampleFormat​
String​
No​
fltp​
Audio sampling format, with varying value ranges across different containers. The options are as follows:​
  • fltp.​
  • s16.​
  • s16p.​
  • s32.​
  • s32p.​
Parent node: Audio.​
SampleRate​
Integer​
No​
48000​
Audio sample rate, with different ranges depending on the container.​
Parent node: Audio.​
tip​
The supported sampling rates vary by format. For details, see Support for sampling rates in different audio containers.​
Channels​
Integer​
No​
2​
Number of audio channels, default consistent with the specified source audio. Range: 1 – 8, varies by container.​
Parent node: Audio.​
tip​
The supported number of channels varies by format. For details, see support for parameters in different audio containers.​
Remove​
Bool​
Not supported​
false​
Whether to delete the source audio stream, value true or false​
Parent node: Audio.​
Options​
Container​
No​
-​
Optional parameters for specified transcoding.​
Parent node: Transcode.​
AIGCMetadata​
Container​
No​
-​
Video AIGC metadata, see below AIGCMetaddata.​
Parent node: Options.​
Label​
String​
Yes​
1​
Generate composite tag elements used to identify target videos as AI-generated, potentially AI-generated, or suspected AI-generated content.​
Parent node: AIGCMetadata.​
ContentProducer​
String​
Yes​
tes_producer​
Generate the element for the synthesis service provider, containing the name or code of the video synthesis service provider.​
Parent node: AIGCMetadata.​
ProduceID​
String​
Yes​
123456​
The content creation identifier element uniquely identifies the content provided by the video generation synthesis service provider.​
Parent node: AIGCMetadata.​
ContentPropagator​
String​
No​
test_propagator​
The content distribution service provider element contains the name or code of the video distribution service provider.​
Parent node: AIGCMetadata.​
PropagateID​
String​
No​
123456​
Content distribution identification element, containing the unique ID assigned to the video by the video distribution service provider.​
Parent node: AIGCMetadata.​
ReservedCode1​
String​
No​
ewogICAgIm****UiLAp9​
Reserved field 1, used for users to independently implement security protection and safeguard content and identification integrity. Must be passed in after base64 encoding.​
Parent node: AIGCMetadata.​
ReservedCode2​
String​
No​
ewogICAg*****UyIiwKfQ​
Reserved field 2, containing user-initiated security protection information to safeguard content and identity integrity. Must be passed in after base64 encoding.​
Parent node: AIGCMetadata.​
​
Response headers​
The response contains common headers. For more information, see Common parameters.​
Response body elements​
​
Name​
Type​
Example value​
Description​
template_id​
String​
393161343761366633396119012ee2450b08​
Create the unique ID for the audio transcoding template.​
​
Sample request​
​
PUT /?process_template&tag=Transcode HTTP/1.1​
Host: {BucketName}.tos-cn-beijing.volces.com​
Date: Fri, 30 Jul 2021 08:05:36 +0000​
Content-Type: application/json​
Content-Length: <length>​
Authorization: authorization string​
​
{​
"Tag": "Transcode", // fixed identifier​
"Name": "my-template",​
"TranscodeConfig": {​
"TimeInterval": {​
"Start": 0,​
"Duration": 10000,​
},​
"Container": {​
"Format": "mp4"​
},​
"Video": {​
"Codec": "h264",​
"Width": 480,​
"Height": 480,​
"Crf": 1,​
"PixFmt": "yuv420p"​
"BitRate": 3000000,​
"Fps": 24,​
"Remove": false​
},​
"Audio": {​
"Codec": "aac",​
"BitRate": 128000,​
"SampleFormat": "fltp",​
"Channels": 2,​
"Remove": false​
},​
"Options": {​
"AIGCMetadata": {​
"Label": "1",​
"ContentProducer": "test_producer",​
"ProduceID": "12345",​
"ContentPropagator": "test_propagator",​
"PropagateID": "12345",​
"ReservedCode1": "ewogICAgIm****UiLAp9",​
"ReservedCode2": "ewogICAg*****UyIiwKfQ"​
}​
}​
}​
}​
​
Sample response​
​
HTTP/1.1 200 OK​
Date: Fri, 30 Jul 2021 13:53:55 GMT​
Content-Type: text/plain​
Content-Length: <length>​
Server: TosServer​
x-tos-id-2: 1e89f203jld00006-a444fd0​
x-tos-request-id: 1e89f203b2d00006-a444ed0​
​
393161343761366633396119012ee2450b08​
​
Last updated: 2026.04.09 15:27:10