Video/Audio Trimming

更新时间:2024-01-09 15:20:44

Trimming enables you to shorten a video or audio file by removing unwanted parts, thereby making the media more concise. This process can be used in conjunction with other media processing operations within a single API call.

How to Use

Structure your fops in the request body as follows:

<op>/<Format>
    /ss/<value>
    /t/<value>
    |saveas/<Urlsafe_Base64_Encode(bucket:filekey)>

Video/Audio Trimming Parameters

Parameter Required Description
op Yes Operation type. For media video/audio processing, set the operation type to avthumb.
format Yes Target format for output, such as mp3, mp4, m3u8, etc.
ss No The starting point, in seconds, for trimming the video or audio. For instance, a value of 120 signifies that the video or audio will be trimmed starting from the 120th second.
t No The length of the trimmed output, calculated in seconds. It can be coupled with the parameter ss to establish the starting and ending points of the trim. For instance, ss=120, t=180 implies that a clip of 180 seconds will be extracted, starting from the 120th second of the video.
saveas No This parameter defines the output location and filename as a URL-safe Base64-encoded string with the pseudocode Urlsafe_Base64_Encode(bucket:savedfilename).

Request Example

This example demonstrates how to trim a 100-second segment from a video named test.mp4 found in the specified bucket vod-wcs-test001. The trimming process begins at the 100th second and finishes at the 225th second of the video. The trimmed segment will be saved in MOV format under the name output.mov.
Pseudocode format for the request:

curl -v -X POST 
–d "bucket=Urlsafe_Base64_Encode(vod-wcs-test001)&key=Urlsafe_Base64_Encode(test.mp4)&fops=Urlsafe_Base64_Encode(avthumb/m4a/ss/125/t/100)|saveas/Urlsafe_Base64_Encode (vod-wcs-test001:output.mov))&force=1&separate=1" 
–H "Authorization:AccessKey:EncodeSign" 
--url "http://mgrDomain/fops""

Actual request format:

-curl -v -X POST 
-d "bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdC5tcDQ=&fops=YXZ0aHVtYi9tb3Yvc3MvMTI1L3QvMTAwfHNhdmVhcy9kbTlrTFhkamN5MTBaWE4wTURBeE9tOTFkSEIxZEM1dGIzWT0=&force=1&separate=1"
-H "Authorization:AccessKey:EncodeSign" 
--url "http://mgrDomain/fops""
本篇文档内容对您是否有帮助?
有帮助
我要反馈
提交成功!非常感谢您的反馈,我们会继续努力做到更好!