Last update:2023-03-13 17:04:13
Most short video users provide video uploading functions and support video sharing. However, many UGC users upload videos with different resolutions. Even through resolution conversion, the video may have black bars around it after scaling. For this kind of abnormal video, you can use Video Cropping to cut out the black bars and improve the viewing experience.
For example, if the resolution of the uploaded video is 1920 * 1920, and the resolution of the target video is 1920 * 1080, system will scale it to 1080 * 1080 first, and then fill the black bars on the video left and right sides to match 1920 * 1080, that is to say, there are black bars existed on the left and right sides of the watched video. In this case, Video Cropping can be used to cut out the black bars to make it more beautiful.
Media Acceleration
This feature is applicable for scenarios such as live video recording and PGC/UGC which requires video/audio content processing. For example, When a customer needs to crop black bars of the video, to improve viewing experience.
Supports common video/audio encapsulation formats and encoding formats, such as:
(1) Video formats: MP4, fMP4, FLV, M3U8, TS, MKV, MOV, WMV, AVI, VP8, VP9, RealVideo, Windows Media Video, etc.;
(2) Audio formats: AAC, AC-3, MP1, MP2, MP3, PCM, RealAudio, Windows Media Audio (WMA), OGG, etc.;
(3) Encoding Formats: H.265, H.264, H.263, MPEG, etc.
When uploading video/audio files, customers can configure the VoD file processing parameters at the same time without calling the API separately. If the customer has not enabled the VoD file processing feature, the file processing parameters will be invalid even though they have been uploaded by the API.
The VoD file processing feature can be used together with the VoD Video/Audio Transcoding and VoD Transmuxing, that is, these features can be realized through a single API command concatenation.
Request parameters are organized in the following format and submitted as request content:
bucket=<Urlsafe_Base64_Encoded_Bucket>&key=<Urlsafe_Base64_Encoded_Key>&fops=<Urlsafe_Base64_Encoded_Fops>¬ifyURL=<Urlsafe_Base64_Encoded_PersistentNotifyUrl>&force=
&separate=
Table 1 Request Parameter Description
Parameter | Required | Description |
---|---|---|
bucket | Yes | Bucket name: name of the bucket where the original file is located |
key | Yes | File name: name of the original file |
fops | Yes | Video cropping parameters list. support one request for multiple processing operations, and the “;” is used to separate parameters in the list. For example, fops=Urlsafe_Base64_Encode(Operation 1;Operation2;……) |
notifyURL | No | URL that receives the processing result notification. The notification should include the detailed content information after processing, such as the video bitrate and duration. Please refer to Notification Description. |
force | No | Whether to enforce data processing. Allow to set the following values: 0: If the specified data processing result exists, return the status of “file exists” without processing the file, avoiding resource waste caused by repeated processing. 1: Enforce data processing and overwrite the existing file The default value is 0. |
separate | No | Whether to notify the processing result separately. Support setting the following values: 0: Notify notifyURL when all transcoding instructions are executed 1: Notify notifyURL each time a single transcoding instruction is executed The default value is 0. |
Apart from filling in the parameters in the following format, fill the URL-Safe Base64 Encoding values in the fops parameter:
<op>/<Format>
/gravity/<gravity>
/vcrop/<vcrop>
|saveas/<Urlsafe_Base64_Encode(bucket:filekey)>
Table 2 Video Cropping Parameters
Parameter | Required | Description |
---|---|---|
<op> | Yes | avthumb (operation type-audio/video processing) |
<format> | Yes | Target output format, such as m4a and flv. |
/gravity/ |
Yes | Please refer to Table 3 Video Offset Parameters. It only affects the cropping offset parameters. The default is TOP_LEFT. |
/vcrop/ |
No | Please refer to Table 4 Video Cropping Operation Parameters. The default is not crop. |
|saveas/<bucket:filekey> | No | Save as a designated file after processing. Fill in the URL-Safe Base64 Encoding value of “Bucket: File name” in the parameter. |
Table 3 Video Offset Parameters
Parameter | Description |
---|---|
TOP_LEFT | The top left corner is the coordinate origin, the x axis is from left to right, and the y axis is from top to bottom. It is the default value. |
TOP_CENTER | The top center is the coordinate origin, the x axis is from left to right, and the y axis is from top to bottom. |
TOP_RIGHT | The top right corner is the coordinate origin, the x axis is from right to left, and the y axis is from top to bottom. |
CENTER_LEFT | The center of the left edge is the coordinate origin, the x axis is from left to right, and the y axis is from top to bottom. |
CENTER | The center is the coordinate origin, the x axis is from left to right, and the y axis is from top to bottom. |
CENTER_RIGHT | The center of the right edge is the coordinate origin, the x axis is from right to left, and the y axis is from top to bottom. |
BOTTOM_LEFT | The bottom left corner is the coordinate origin, the x axis is from left to right, and the y axis is from bottom to top. |
BOTTOM_CENTER | The center of the bottom edge is the coordinate origin, the x axis is from left to right, and the y axis is from bottom to top. |
BOTTOM_RIGHT | The bottom right corner is the coordinate origin, the x axis is from right to left, and the y axis is from bottom to top. |
Table 4 Video Cropping Operation Parameters
Parameter | Description |
---|---|
<Width>x | Specify the target video width, and the height remains the same. The value range is 0-10000. |
!{vcropSize}a<dx>a<dy> | Based on the offset anchor, offset dx pixels to the right, and offset dy pixels to the bottom. |
x<Height> | Specify the target video height, and the width remains the same. The value range is 0-10000. |
<Width>x<Height> | Specify the target video width and height. The value range is 0-10000. |
If the request succeeds, return the following Json character string:
{ "persistentId": <persistentId> }
If the request fails, return the following Json character string:
{
"code": "<code string>",
"message": "<ErrMsg string>"
}
Table 5 Response Parameter Description
Parameter | Required | Description |
---|---|---|
persistentId | Yes | Upload the process ID that preprocesses or triggers persistent processing |
code | Yes | HTTP request response code. Please refer to HTTP Response Status Code |
message | Yes | Prompt message for processing failure |
Crop the test.mp4 video under the vod-wcs-test001 bucket, and output two videos:
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:mgrAuthorization_A:mgrAuthorization_B" --url "http://mgrDomain/fops"
After encryption:
curl -v -X POST -d"bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdC5tcDQ=&fops=YXZ0aHVtYi9tNGEvZ3Jhdml0eS9UT1BfTEVGVC92Y3JvcC80MDB4MzUyfHNhdmVhcy9kbTlrTFhkamN5MTBaWE4wTURBeE9uUmxjM1JmWm1sc1pTNXROR0VLQ2c9PTthdnRodW1iL2Zsdi9ncmF2aXR5L0NFTlRFUi92Y3JvcC8yMDB4MzUyfHNhdmVhcy9kbTlrTFhkamN5MTBaWE4wTURBeE9uUmxjM1JmWm1sc1pTNW1iSFlLQ2c9PQoK&force=1&separate=1" -H "Authorization:mgrAuthorization_A:mgrAuthorization_B" --url "http://mgrDomain/fops"
Tips: