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.
Structure your fops
parameter in the request body as follows:
<op>/<format>
/gravity/<value>
/vcrop/<value>
|saveas/<Urlsafe_Base64_Encode(bucket:filekey)>
Parameter | Description |
---|---|
op |
Operation type. Must be set to avthumb for video cropping. |
format |
Output format (e.g., flv, mp4, m3u8). |
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) . |
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 |
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. |
This example crops a video in two different ways, creating two separate output files:
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"
curl -v -X POST
-d "bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdC5tcDQ=&fops=YXZ0aHVtYi9tNGEvZ3Jhdml0eS9UT1BfTEVGVC92Y3JvcC80MDB4MzUyfHNhdmVhcy9kbTlrTFhkamN5MTBaWE4wTURBeE9uUmxjM1JmWm1sc1pTNXROR0VLQ2c9PTthdnRodW1iL2Zsdi9ncmF2aXR5L0NFTlRFUi92Y3JvcC8yMDB4MzUyfHNhdmVhcy9kbTlrTFhkamN5MTBaWE4wTURBeE9uUmxjM1JmWm1sc1pTNW1iSFlLQ2c9PQoK&force=1&separate=1"
-H "Authorization:AccessKey:EncodeSign"
--url "http://mgrDomain/fops"