Product Introduction
Product Features
Intelligent Scheduling
New Protocol Support
Back-to-Origin Control
Security Protection
Content Management
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
Quick Start
Domain Management
Origin Settings
Cache Settings
Cache Purge and Prefetch
HTTP/HTTPS Settings
Access Control
Advanced Settings
Logs and Reports
Tutorials

Video Cropping

Last update:2025-03-21 15:32:59

Video cropping allows you to remove unwanted areas from a video frame, focusing on a specific region of interest. This operation can be combined with other media processing tasks in a single API call.

Request Syntax

Structure your fops parameter in the request body as follows:

<op>/<format>
    /gravity/<value>
    /vcrop/<value>
    |saveas/<Urlsafe_Base64_Encode(bucket:filekey)>

Required Parameters

Parameter Description
op Operation type. Must be set to avthumb for video cropping.
format Output format (e.g., flv, mp4, m3u8).

Optional Parameters

Parameter Description
gravity Determines the starting position and direction for cropping. Default: TOP_LEFT.
vcrop Defines the dimensions of the cropping area using width and height.
saveas Specifies output location and filename as a URL-safe Base64-encoded string: Urlsafe_Base64_Encode(bucket:savedfilename).

Gravity Reference

The gravity parameter specifies where cropping begins:

Value Description
TOP_LEFT Starts from upper left corner (default)
TOP_CENTER Starts from center of top edge
TOP_RIGHT Starts from upper right corner
CENTER_LEFT Starts from center of left edge
CENTER Starts from exact center of frame
CENTER_RIGHT Starts from center of right edge
BOTTOM_LEFT Starts from bottom left corner
BOTTOM_CENTER Starts from center of bottom edge
BOTTOM_RIGHT Starts from bottom right corner

Vcrop Reference

The vcrop parameter controls the cropping dimensions:

Format Description
<Width>x Sets only the width, keeping original height. Range: 0-10,000.
x<Height> Sets only the height, keeping original width. Range: 0-10,000.
<Width>x<Height> Sets both width and height. Range: 0-10,000 for each dimension.
{vcropSize}a<dx>a<dy> Adjusts crop position by moving right dx pixels and down dy pixels from starting point.

Example

This example crops a video in two different ways, creating two separate output files:

  1. Crop from the top-left corner to create a 400x352 pixel video in m4a format
  2. Crop from the center to create a 200x352 pixel video in flv format

Request Template

curl -v -X POST 
-d "bucket=Urlsafe_Base64_Encode(vod-wcs-test001)&key=Urlsafe_Base64_Encode(test.mp4)&fops=Urlsafe_Base64_Encode(avthumb/m4a/gravity/TOP_LEFT/vcrop/400x352|saveas/Urlsafe_Base64_Encode(vod-wcs-test001:test_file.m4a);avthumb/flv/gravity/CENTER/vcrop/200x352|saveas/Urlsafe_Base64_Encode(vod-wcs-test001:test_file.flv))&force=1&separate=1" 
-H "Authorization:AccessKey:EncodeSign" 
--url "http://mgrDomain/fops"

Actual Request

curl -v -X POST 
-d "bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdC5tcDQ=&fops=YXZ0aHVtYi9tNGEvZ3Jhdml0eS9UT1BfTEVGVC92Y3JvcC80MDB4MzUyfHNhdmVhcy9kbTlrTFhkamN5MTBaWE4wTURBeE9uUmxjM1JmWm1sc1pTNXROR0VLQ2c9PTthdnRodW1iL2Zsdi9ncmF2aXR5L0NFTlRFUi92Y3JvcC8yMDB4MzUyfHNhdmVhcy9kbTlrTFhkamN5MTBaWE4wTURBeE9uUmxjM1JmWm1sc1pTNW1iSFlLQ2c9PQoK&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!