更新时间:2024-02-07 14:41:26
Video Cropping removes unwanted black bars or areas from the video frame, adjusting the focus to a specific region. This process can be used in conjunction with other media processing operations within a single API call.
Structure your fops
in the request body as follows:
<op>/<Format>
/gravity/<value>
/vcrop/<value>
|saveas/<Urlsafe_Base64_Encode(bucket:filekey)>
Video Cropping Parameters
Parameter | Required | Description |
---|---|---|
op | Yes | Operation type. For video cropping, set the operation type to avthumb . |
format | Yes | Target format for output, such as flv, mp4, m3u8, etc. |
gravity | No | This parameter determines the starting position and direction for video cropping. For instance, defining it as TOP_LEFT would mean the cropping begins from the upper left corner, moving from left to right and top to bottom. For details on specific parameters, please refer to the Gravity Parameters section. |
vcrop | No | This parameter defines the dimensions of the video cropping area, as determined by the width and height settings. For an in-depth understanding of this parameter, please refer to the Vcrop Parameters section. |
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) . |
Gravity Parameters
Parameter | Description |
---|---|
TOP_LEFT | The cropping begins from the upper left corner of the frame, extending from left to right and top to bottom. This is also the default value of gravity . |
TOP_CENTER | The cropping begins from the center of the top edge of the frame, extending from left to right and top to bottom. |
TOP_RIGHT | The cropping begins from the upper right corner of the frame, extending from right to left and top to bottom. |
CENTER_LEFT | The cropping begins from the center of the left edge of the frame, extending from left to right and top to bottom. |
CENTER | The cropping begins from the exact center of the frame, moving from left to right and top to bottom. |
CENTER_RIGHT | The cropping begins from the center of the right edge of the frame, extending from right to left and top to bottom. |
BOTTOM_LEFT | The cropping begins from the bottom left corner of the frame, extending from left to right and bottom to top. |
BOTTOM_CENTER | The cropping begins from the center of the bottom edge of the frame, extending from left to right and bottom to top. |
BOTTOM_RIGHT | The cropping begins from the bottom right corner of the frame, extending from right to left and bottom to top. |
Vcrop Parameters
Parameter | Description |
---|---|
\<Width>x | Defines only the width of the output video, maintaining the same height as that of the source video. The value can range from 0 to 10,000. |
!{vcropSize}a\<dx>a\<dy> | The cropping will be adjusted to the right by dx pixels and shifted downward by dy pixels from the initial starting point. |
x\<Height> | Defines only the height of the output video, maintaining the same width as that of the source video. The value can range from 0 to 10,000. |
\<Width>x\<Height> | Defines both the width and height of the output video, ranging from 0 to 10,000. |
This example demonstrates the process of extracting sections from the test.mp4
video in bucket vod-wcs-test001
. This process results in two separate output videos:
The initial cropping starts from the top-left corner of the test.mp4
video, generating an output video with dimensions of 400x352
. This video is saved in the m4a format under the name test_file.m4a
.
The subsequent cropping begins from the center of the test.mp4
video, producing an output video with dimensions of 200x352
. This video is saved in the flv format, titled test_file.flv
.
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/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 format:
-curl -v -X POST
-d "bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdC5tcDQ=&fops=YXZ0aHVtYi9tNGEvZ3Jhdml0eS9UT1BfTEVGVC92Y3JvcC80MDB4MzUyfHNhdmVhcy9kbTlrTFhkamN5MTBaWE4wTURBeE9uUmxjM1JmWm1sc1pTNXROR0VLQ2c9PTthdnRodW1iL2Zsdi9ncmF2aXR5L0NFTlRFUi92Y3JvcC8yMDB4MzUyfHNhdmVhcy9kbTlrTFhkamN5MTBaWE4wTURBeE9uUmxjM1JmWm1sc1pTNW1iSFlLQ2c9PQoK&force=1&separate=1"
-H "Authorization:AccessKey:EncodeSign"
--url "http://mgrDomain/fops""