Overview
Basic Concepts
Quick Start
Domain Management
Origin Settings
Media Processing
Before You Start
How to Use
Transcoding
Transmuxing
Video Encryption
Intelligent Transcoding
Editing
Video/Audio Splicing
Video/Audio Trimming
Video Cropping
Screenshot
Add Subtitles
Add Watermarks
Appendix
Cache Settings
Cache Purge and Prefetch
HTTP/HTTPS Settings
Access Control
Advanced Settings
Logs and Reports
Tutorials
Content Protection

Video/Audio Trimming

Last update:2025-03-21 15:25:08

The trimming operation lets you specify a start point and duration to extract only the relevant portion of your media file.

Parameters

Parameter Required Description
op Yes Operation type. Use avthumb for all media processing operations.
format Yes Target output format (mp3, mp4, m3u8, etc.).
ss No Starting point for trimming, in seconds. For example, 120 starts trimming from the 120-second mark.
t No Duration of the trimmed output, in seconds. When used with ss, defines the segment to extract. Example: ss=120, t=180 extracts a 180-second clip starting from the 120-second mark.
saveas No Specifies the output location and filename as a URL-safe Base64-encoded string using the format Urlsafe_Base64_Encode(bucket:savedfilename).

Request Syntax

Structure your fops parameter in the request body as follows:

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

Example: Trim a Video Segment

This example demonstrates trimming a 100-second segment from a video, starting at the 125-second mark.

Source details:

  • Source bucket: vod-wcs-test001
  • Source file: test.mp4
  • Start point: 125 seconds
  • Duration: 100 seconds
  • Output format: MOV
  • Output filename: output.mov

Request Format (Pseudocode)

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

curl -v -X POST 
-d "bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdC5tcDQ=&fops=YXZ0aHVtYi9tb3Yvc3MvMTI1L3QvMTAwfHNhdmVhcy9kbTlrTFhkamN5MTBaWE4wTURBeE9tOTFkSEIxZEM1dGIzWT0=&force=1&separate=1"
-H "Authorization:AccessKey:EncodeSign" 
--url "http://mgrDomain/fops"
Is the content of this document helpful to you?
Yes
I have suggestion
Submitted successfully! Thank you very much for your feedback, we will continue to strive to do better!