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

Torch Object Storage

Copy page
Download PDF
video to GIF
VideoAnimation
Copy page
Download PDF
VideoAnimation
Description​
This api converts video files to animations and stores them in the specified bucket.​
Notes​
  • Audio-to-animation conversion only supports asynchronous processing (x-tos-async-process method).​
  • Video container formats: MP4/TS/MKV.​
  • Video encoding formats: H264/H265/VP8/VP9/AV1.​
  • Video resolution limits: [128, 4096].​
  • Video size limits: video length no longer than 15 minutes.​
Request syntax​
​
// Convert the video file example.mkv to a GIF.​
POST /example.mkv?x-tos-async-process HTTP/1.1​
Host: bucketname.tos-cn-beijing.volces.com​
Date: Fri, 28 Oct 2024 06:40:10 GMT​
Authorization: TOS qn6q**************:77Dv****************​
​
x-tos-async-process=video/animation,f_gif,w_100,h_100,inter_1000&x-tos-save-object=YWJjLnBuZw==&x-tos-save-bucket=YXJjdGlj​
​
Request parameters and headers​
For common request headers, see Common parameters.​
​
Field name​
Location​
Type​
Required​
Example value​
Description​
x-tos-async-process​
Query​
String​
Yes​
-​
Special identifier for video-to-GIF requests.​
​
Request body elements​
​
Field name​
Type​
Required​
Example value​
Description​
ss​
Integer​
No​
0​
Start time for video-to-GIF conversion, in milliseconds. Values:​
  • 0 (default): start from the beginning.​
  • Greater than 0: start from ss milliseconds.​
f​
String​
Yes​
gif​
Output animation format, value: gif.​
num​
Integer​
No​
100​
Number of GIF frames, default is unlimited (frames are extracted until the video ends).​
warning​
If the video is shorter than expected, the actual number of extracted frames will be less than the set parameter value.​
inter​
Integer​
No​
1​
Frame extraction interval for GIFs, in milliseconds. By default, all video frames are extracted.​
warning​
When this value is less than the source video's frame interval (the inverse of the frame rate), frames are extracted according to the source video's frame interval.​
fps​
Integer​
No​
30​
Animation frame rate, default is inter inverse. Value range is [0, 240].​
tip​
This parameter controls the playback speed of the animation. When set to the default value, it matches the source video playback speed. A value greater than the default speeds up playback; a value less than the default slows it down.​
w​
Integer​
No​
1024​
Output gif width in px, range [32, 4096].​
tip​
If set to 0, scale automatically according to source video resolution ratio.​
h​
Integer​
No​
1024​
Output GIF height in px, range [32,4096].​
tip​
If set to 0, it will auto-calculate based on the source video's resolution ratio.​
scaletype​
String​
No​
crop​
Scaling mode. The options are as follows:​
  • crop: scale and crop.​
  • stretch (default): stretch to fill.​
  • fill: scale and keep black borders.​
  • fit: scale without black borders, maintain aspect ratio.​
​
Response headers​
The response contains common headers. For more information, see Common parameters.​
Response body elements​
​
Field name​
Type​
Example value​
Description​
status​
String​
OK​
Status code.​
​
Sample request​
​
POST /example.mkv?x-tos-async-process HTTP/1.1​
Host: bucketname.tos-cn-beijing.volces.com​
Date: Fri, 28 Oct 2024 06:40:10 GMT​
Authorization: TOS qn6q**************:77Dv****************​
​
x-tos-async-process=video/animation,f_gif,w_100,h_100,inter_1000&x-tos-save-object=YWJjLnBuZw==&x-tos-save-bucket=YXJjdGlj​
​
Sample response​
​
HTTP/1.1 200 OK​
x-tos-id-2: f91b0c03a01300c1-a444ed0 ​
x-tos-request-id: f91b0c03a01300c1-a444ed0 ​
Date: Fri, 30 Jul 2021 06:45:39 GMT​
server: TosServer​
Content-Length: 0​
{​
"status": "OK"​
} ​
​
​
Last updated: 2026.04.09 15:27:10