VAS_VOD File Processing

Last update:2022-04-13 14:59:37

1 VAS Intro

1.1 Brief Introduction

At present, various types of video on-demand services are available, consist of traditional news, TV dramas and movies, and emerging videos such as entertainment news and variety show provided by integrated video platforms, live recording content, and video uploaded by PGC/UGC. Requirement-based editing and reprocessing are needed for these emerging videos, such as inserting pre-roll, mid-roll and post-roll ads, removing ads or other meaningless content in videos and splicing multiple videos.

Based on these video processing requirements, CDNetworks provides a wide range of video processing features, including VoD Audio/Video Transcoding, VoD Transmuxing, VoD Screenshot and VoD File Processing, to reduce cost spent in audio/video processing for our customers and to realize fast video processing and distribution.

This article mainly introduces VoD File Processing. VoD file processing includes the following features: MP3 Cover Fetch, Video Cropping, Audio/video Cutting and Audio/Video Splicing.

1.2 Applicable Product Line

Media Acceleration

1.3 Application Scenario

This feature is applicable for scenarios such as live video recording and PGC/UGC which requires video/audio content editing. For example,

  • When a customer has the request of MP3 cover fetch;
  • When a customer needs to crop black bars of the video, to improve viewing experience;
  • When a customer has the request of audio/video cutting, including:
    • After live recording, removing the meaningless content which records the broadcaster’s preparation work;
    • Cutting the highlights for video sharing;
    • Removing multiple advertisements of their programs for replay, and this is normally used by broadcasting and television customers.
  • When customer has the request to splice the highlights for dissemination and promotion.

2 VAS Detail

2.1 VAS Description

VoD file processing 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.

VoD File Processing concludes MP3 Cover Fetch, Video Cropping, Audio/Video Cutting and Audio/Video Splicing.
(1) MP3 Cover Fetch
This function is used to acquire the album picture of the specified MP3 file, and the output format of the picture can be specified.
(2) Video Cropping
Most short-form video customers provide the feature of video uploading and sharing. However, since the videos uploaded by UGC users vary in resolution, there may be black borders around the video after resizing even though resolution conversion is performed. For this type of abnormal videos, video cropping can be used to crop the black bars, and thus improve viewing experience.
(3) Audio/Video Cutting
Audio/Video cutting supports cutting and preserving the video with a specified start time and duration, and it also supports cutting multiple segments.
(4) Audio/Video Splicing
Audio/video splicing supports splicing multiple video/audio segments. The audio/video files to be spliced should be stored in the same space (bucket), otherwise they cannot be spliced together.

2.2 Workflow

【New Feature】WAF Rule Template

Figure 1 VoD File Processing Workflow

(1) The customer calls the cloud storage API to upload the file and assigns the file processing instruction;
(2) After receiving the task, the cloud storage assembles the customer instruction and sends it to cloud transcoding;
(3) Cloud transcoding fetches the file from the cloud storage for file processing, and uploads the processed file to the cloud storage;
(4) Cloud storage notifies the customer of the processed file address through API callback;
(5~8) For the customer adopting CDN acceleration service, their users will utilize the video address that the cloud storage sends to customer, to interact with CDN PoPs.

2.3 Instructions

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.

2.4 Interface Description

2.4.1 Request Description

POST /fops
Host:
Authorization:

Table 1 Request Description
Parameter Required Description
Host Yes Management domain name, which is used to perform file operations, such as audio and video processing, and file deleting. It can be obtained from CDNetworks Nova.
Authorization Yes Access token, used to verify the legitimacy of resource management interface requests. It is generated by AK, SK, Path, Body.
Table 2 Access Token Authorization Parameter Description
Parameter Required Description
AK Yes Access key. It could be obtained from CDNetworks Nova when the service application is approved.
SK Yes Security key. It could be obtained from CDNetworks Nova when the service application is approved.
Path Yes Operation type, such as audio/video processing is /fops.
Body Yes Request content. Detailed description is as follows.

AK, SK and host(Management domain) could be obtained from CDNetworks Nova as followed:

【New Feature】WAF Rule Template

Figure 2 AK/SK Management

【New Feature】WAF Rule Template

Figure 3 Domain Management

2.4.2 Parameter Description

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>&notifyURL=<Urlsafe_Base64_Encoded_PersistentNotifyUrl>&force=&separate=

fops parameters need to be filled in as per requirements. Multiple operations can be spliced together as fops parameter to be executed, that means fops= Urlsafe_Base64_Encode (operation 1; operation 2; …).

Table 3 Request Parameter Description

Parameter

Required

Description

bucket

Yes

Space name: name of the space where the original file is located

key

Yes

File name: name of the original file

fops

Yes

Processing parameters list. For parameter meaning, please refer to audio/video file processing Ops parameter format (for example, the parameters of mp3 cover acquisition, video cropping, and audio/video cutting or splicing); support one request for multiple processing operations, and the “;” is used to separate parameters in the list.

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 data notification content 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.

2.4.3 Response Description

If the request succeeds, return the following Json character string:

{ “persistentId”: }

If the request fails, return the following Json character string:

{
“code”: “”,
“message”: “
}

Table 4 Response Parameter Description

Field name

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 <return code>

message

Yes

Prompt message for audio/video processing failure

More detailed fops parameter description for MP3 Cover Fetch, Video Cropping, Audio/video Cutting, Audio/Video Splicing can be found in Chapter 4. Appendix.

3 Notice

VoD file processing can only manipulate video/audio files stored on media cloud storage, so video on-demand and media cloud storage features should be enabled at the same time.

4 Appendix: Fops Parameter Description and Example

4.1 MP3 Cover Fetch

4.1.1 Parameter Description

Apart from filling in the parameters in the following format, fill the Urlsafe_Base64_Encoded values in the fops parameter:

/
|saveas/<encode(bucket:filekey)>

Table 5 MP3 Cover Acquisition Parameters

Parameter

Required

Description

<op>

Yes

getapic (operation type–fetch MP3 album picture)

<format>

Yes

Output picture format, such as jpg and png

|saveas/<bucket:filekey>

No

Save the picture as a designated file. Fill in the Urlsafe_Base64_Encoded value of “Space: File name” in the parameter.

4.1.2 Usage Example

Acquire the cover of the test.mp3 under the vod-wcs-test001 space with the jpg format, save it in vod-wcs-test001, and name it as asfengmian.jpg.
(1) Step 1: Obtain AK and SK from CDNetworks Nova.
(2) Step 2: The path of MP3 cover acquisition is /fops.
(3) Step 3: The request body is:

Before encryption:

bucket=Urlsafe_Base64_Encode(vod-wcs-test001)&key=Urlsafe_Base64_Encode(test.mp3)&fops=Urlsafe_Base64_Encode(getapic/jpg|saveas/Urlsafe_Base64_Encode(vod-wcs-test001:fengmian.jpg))&force=1&separate=1

After encryption:

bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdC5tcDM=&fops=Z2V0YXBpYy9qcGd8c2F2ZWFzL2RtOWtMWGRqY3kxMFpYTjBNREF4T2lCbVpXNW5iV2xoYmk1cWNHYz0=&force=1&separate=1

(4) Step 4: Utilize AK, SK, path and Body to generate the access token Authorization.
(5) Step 5: Obtain the management domain name from CDNetworks Nova, and mgrDomain represents the management domain name in this example.
(6) Step 6: Execute the command.

curl -v -X POST -d"bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdC5tcDM=&fops=Z2V0YXBpYy9qcGd8c2F2ZWFzL2RtOWtMWGRqY3kxMFpYTjBNREF4T2lCbVpXNW5iV2xoYmk1cWNHYz0=&force=1&separate=1" -H “Authorization:mgrAuhorization_A:mgrAuthorization_B” --url “http://mgrDomain/fops”

【New Feature】WAF Rule Template

Figure 4 MP3 Cover Acquisition Command Execution Process

Finally, query the generated fengmian.jpg in the vod-wcs-test001 space.

【New Feature】WAF Rule Template

Figure 5 MP3 Cover Acquisition Command Execution Result

4.2 Video Cropping

4.2.1 Parameter Description

Apart from filling in the parameters in the following format, fill the Urlsafe_Base64_Encoded values in the fops parameter:

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

Table 6 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/<gravity>

Yes

Please refer to Table 7 Video Offset Parameters. It only affects the cropping offset parameters. The default is TOP_LEFT.

/vcrop/<vcrop>

No

Please refer to Table 8 Video Cropping Operation Parameters. The default is not crop.

|saveas/<bucket:filekey>

No

Save as a designated file after processing. Fill in the Urlsafe_Base64_Encoded value of “Space: File name” in the parameter.

Table 7 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 8 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.

4.2.2 Usage Example

Crop the test.mp4 video under the vod-wcs-test001 space, and output two videos:

  • Crop 400*352 out of the top left corner of the test.mp4 video, save it as m4a format, and name it as test_file.m4a;
  • Crop 200*352 out of the center of the test.mp4 video, save it as flv format, and name it as test_file.flv.
    (1) Step 1: Obtain AK and SK from CDNetworks Nova.
    (2) Step 2: The path of video cropping is /fops.
    (3) Step 3: The request body is:
    Before encryption:

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

After encryption:

bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdC5tcDQ=&fops=YXZ0aHVtYi9tNGEvZ3Jhdml0eS9UT1BfTEVGVC92Y3JvcC80MDB4MzUyfHNhdmVhcy9kbTlrTFhkamN5MTBaWE4wTURBeE9uUmxjM1JmWm1sc1pTNXROR0VLQ2c9PTthdnRodW1iL2Zsdi9ncmF2aXR5L0NFTlRFUi92Y3JvcC8yMDB4MzUyfHNhdmVhcy9kbTlrTFhkamN5MTBaWE4wTURBeE9uUmxjM1JmWm1sc1pTNW1iSFlLQ2c9PQoK&force=1&separate=1

(4) Step 4: Utilize AK, SK, path and Body to generate the access token Authorization.
(5) Step 5: Obtain management domain name from CDNetworks Nova, and mgrDomain represents the management domain name in this example.
(6) Step 6: Execute the command.

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”

【New Feature】WAF Rule Template

Figure 6 Video Cropping Command Execution Process

Finally, query the generated m4a file and flv file in the vod-wcs-test001 space.

【New Feature】WAF Rule Template

Figure 7 Video Cropping Command Execution Result

4.3 Audio/video Cutting

4.3.1 Parameter Description

Apart from filling in parameters in the following format, fill the Urlsafe_Base64_Encoded values in the fops parameter:

/
/ss/
/t/
/multiSeeks/
|saveas/<Urlsafe_Base64_Encode(bucket:filekey)>

Table 9 Audio/video Cutting Parameters

Parameter

Required

Description

<op>

Yes

avthumb (operation type-audio/video processing)

<format>

Yes

Target output format, such as mp4, flv and m3u8.

/ss/<SeekStart>

No

Specify the start time of video cutting, unit: second.

/t/<Duration>

No

Specify the duration of video clip, and video cutting can be realized with the ss together; unit: second.

/multiSeeks/< multiSeeks >

No

Capture multiple audio/video clips; use the punctuation mark “:” to separate the capture start time and capture duration; use “,” to separate different clips; -1 represents the end of the file, and the unit is s. For example, if the clips of 30 - 38s and 120 - 129s are to be removed, that is to preserve the clips of 0 - 30s, 38 - 120s and 129s – end, the multiSeeks will be 0:30,38:120,129: -1.

Note: multiSeeks cannot be used together with ss and t.

|saveas/<bucket:filekey>

No

Save as a designated file after processing. Fill in the Urlsafe_Base64_Encoded value of “Space:File name” in the parameter.

4.3.2 Usage Example

Example 1
Cut the test.mp4 video under the vod-wcs-test001 space from 125s, the cut duration is 100s. That means preserve the 125 - 225s content of the source video, and store it as the m4a format.

Cut a 100s long clip out of the video named test.mp4 in the vod-wcs-test001 space from 125s, that is to preserve the clip of 125 - 225s in the source video, and save the clip in the m4a format.
(1) Step 1: Obtain AK and SK from CDNetworks Nova.
(2) Step 2: The path of audio/video cutting is /fops.
(3) Step 3: The request content Body is:
Before encryption:

bucket=Urlsafe_Base64_Encode(vod-wcs-test001)&key=Urlsafe_Base64_Encode(test.mp4)&fops=Urlsafe_Base64_Encode(avthumb/m4a/ss/125/t/100)&force=1&separate=1

After encryption:

bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdC5tcDQ=&fops=YXZ0aHVtYi9tNGEvc3MvMTI1L3QvMTAw&force=1&separate=1

(4) Step 4: Utilize AK, SK, path and Body to generate the access token Authorization.
(5) Step 5: Obtain management domain name from CDNetworks Nova, and mgrDomain represents the management domain name in this example.
(6) Step 6: Execute the command.

curl -v -X POST -d"bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdC5tcDQ=&fops=YXZ0aHVtYi9tNGEvc3MvMTI1L3QvMTAw&force=1&separate=1" -H “Authorization:mgrAuthorization_A:mgrAuthorization_B” --url “http://mgrDomain/fops”

【New Feature】WAF Rule Template

Figure 8 Video Cutting Command Execution Process

Finally, query the generated m4a file in the vod-wcs-test001 space.

【New Feature】WAF Rule Template

Figure 9 Video Cutting Command Execution Result

Example 2
Remove the clips of 30 – 38s and 81 – end in the video named test.mp4 in the vod-wcs-test001 space, that is to preserve the clips of 0 -30s and 38 – 81s in the source video. Save it as the flv format, and name it as test_file.flv.
(1) Step 1: Obtain AK and SK from CDNetworks Nova.
(2) Step 2: The path of audio/video cutting is /fops.
(3) Step 3: The request content Body is:
Before encryption:

bucket=Urlsafe_Base64_Encode(vod-wcs-test001)&key=Urlsafe_Base64_Encode(test.mp4)&fops=Urlsafe_Base64_Encode(avthumb/flv/multiSeeks/0:30,38:43|saveas/Urlsafe_Base64_Encode(vod-wcs-test001:test_file.flv))&force=1&separate=1

After encryption:

bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdC5tcDQ=&fops=YXZ0aHVtYi9mbHYvbXVsdGlTZWVrcy8wOjMwLDM4OjQzfHNhdmVhcy9kbTlrTFhkamN5MTBaWE4wTURBeE9uUmxjM1JmWm1sc1pTNW1iSFk9&force=1&separate=1
(4) Step 4: Utilize AK, SK, path and Body to generate the access token Authorization.
(5) Step 5: Obtain management domain name from CDNetworks Nova, and mgrDomain represents the management domain name in this example.
(6) Step 6: Execute the command.
curl -v -X POST -d"bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdC5tcDQ=&fops=YXZ0aHVtYi9mbHYvbXVsdGlTZWVrcy8wOjMwLDM4OjQzfHNhdmVhcy9kbTlrTFhkamN5MTBaWE4wTURBeE9uUmxjM1JmWm1sc1pTNW1iSFk9&force=1&separate=1" -H “Authorization:mgrAuthorization_A:mgrAuthorization_B” --url “http://mgrDomain/fops”

【New Feature】WAF Rule Template

Figure 10 Video Cutting Command Execution Process

Finally, query the generated flv file in the vod-wcs-test001 space.

【New Feature】WAF Rule Template

Figure 11 Video Cutting Command Execution Result

4.4 Audio/Video Splicing

4.4.1 Parameter Description

Apart from filling in parameters in the following format, fill the Urlsafe_Base64_Encoded values in the fops parameter:

/
/mode/
/concatorder/
/moovToFront/
//
|saveas/<Urlsafe_Base64_Encode(bucket:filekey)>

Table 10 Audio/video Splicing Parameters

Parameter

Required

Description

<op>

Yes

avconcat (operation type-audio/video splicing)

<format>

Yes

Target output format, such as mp4, flv and m3u8.

/mode/<mode>

Yes

Splicing mode, including mode 1 and mode 2:

Mode 1: the files to be spliced share the same video encoding scheme; adopt this mode for audio splicing;

Mode 2: applicable to situations when the files to be spliced have different video encoding schemes.

/concatorder/<concatorder>

No

Order of the files to be spliced. Use “-” as the separator, such as 2-1-4-3.

/moovToFront/<moovToFront>

No

Input the meta information of mp4 files to the head. The default value is 0, which means do not adjust the position of meta information; and 1 is to adjust, that is, if the meta information is at the end, move it to the head.

/<encodeUrlN>/

Yes

Specify the files to be spliced. The format is <filekey>, which is <file name>. It requires URL-safe base64 encoding, and use “/” to separate multiple files.

|saveas/<bucket:filekey>

No

Save as a designated file after processing. Fill in the Urlsafe_Base64_Encoded value of “Space:File name” in the parameter.

4.4.2 Usage Example

Splice the test_1.mp4 video and test_2.mp4 video in the vod-wcs-test001 space, and the output video is test_merge.mp4.
(1) Step 1: Obtain AK and SK from CDNetworks Nova.
(2) Step 2: The path of audio/video splicing is /fops.
(3) Step 3: The request content Body is:

Before encryption:

bucket=Urlsafe_Base64_Encode(vod-wcs-test001)&key=Urlsafe_Base64_Encode (test_1.mp4)&fops=Urlsafe_Base64_Encode(avconcat/mp4/mode/1/Urlsafe_Base64_Encode (test_2.mp4)|saveas/Urlsafe_Base64_Encode (vod-wcs-test001:test_merge.mp4))&force=1&separate=1

After encryption:

bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdF8xLm1wNA==&fops=YXZjb25jYXQvbXA0L21vZGUvMS9kR1Z6ZEY4eUxtMXdOQT09fHNhdmVhcy9kbTlrTFhkamN5MTBaWE4wTURBeE9uUmxjM1JmYldWeVoyVXViWEEw&force=1&separate=1
(4) Step 4: Utilize AK, SK, path and Body to generate the access token Authorization.
(5) Step 5: Obtain management domain name from CDNetworks Nova, and mgrDomain represents the management domain name in this example.
(6) Step 6: Execute the command.
curl -v -X POST -d"bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdF8xLm1wNA==&fops=YXZjb25jYXQvbXA0L21vZGUvMS9kR1Z6ZEY4eUxtMXdOQT09fHNhdmVhcy9kbTlrTFhkamN5MTBaWE4wTURBeE9uUmxjM1JmYldWeVoyVXViWEEw&force=1&separate=1" -H “Authorization:mgrAuthorization_A:mgrAuthorization_B” --url "http://mgrDomain/fops”

【New Feature】WAF Rule Template

Figure 12 Video Splicing Command Execution Process

Finally, query the generated test_merge.mp4 file in the vod-wcs-test001 space.

【New Feature】WAF Rule Template

Figure 13 Video Splicing Command Execution Result

Is the content of this document helpful to you?
Yes
No
Submitted successfully! Thank you very much for your feedback, we will continue to strive to do better!