Audio and Video Processing Interface
Basic concepts
When users in the multimedia cloud industry use BOS as a backend storage source server, they often have different usage scenarios combined with upper-level application logic. With the continuous evolution of user experience at the application layer, the real-time requirements for data processing, handling and access in multimedia cloud services are becoming increasingly high. Users hope to provide a more simplified way of use.
Baidu AI Cloud Object Storage (BOS) provides an innovative multimedia cloud processing API that supports uploading MP4-format files. The system automatically converts them to HLS format, enabling playback through M3U8-style players. This fully aligns with the "UGC upload - automatic processing - playback" workflow, simplifying previously complex video operations and processing logic, and accelerating application performance.
Multimedia cloud processing commands
Multimedia cloud files are much larger than image files, and their processing time is longer, usually at the second level. Therefore, BOS multimedia cloud processing commands adopt a write-time processing scheme that differs from the BOS Image Processing API. That is, the original multimedia cloud files are processed on demand when written to BOS, rather than being processed based on parameters defined when users read them.
The BOS multimedia cloud processing API is defined as follows:
- Format conversion parameter
| Parameter name | Abbreviation | Types | Value | Command description | Required or not |
|---|---|---|---|---|---|
| format | f | string | [hls] | Convert the video to a specified format | Yes |
| time | t | int | [6,600] | Segment duration, defaulting to 10 s | No |
- Persistent storage parameter
| Parameter name | Abbreviation | Types | Value | Command description | Required or not |
|---|---|---|---|---|---|
| object | o | string | - | The object name encoded with base64 is limited by the length of the object, which is no more than 1,024 characters (here is the name of the m3u8 file after transcoding, such as xxx.m3u8) | Yes |
Request method
In the BOS POST API, parameters can be configured in the headers to achieve the transcapsulation and storage of multimedia cloud files uploaded via POST.
1POST /video.mp4 HTTP/1.1
2Content-Length:ContentLength
3Content-Type: ContentType
4x-bce-process=video/format,f_hls
Note: For the authentication generation method for this API, refer to the PostObjectAPI.
Request example
Example of transcapsulation and storage
Convert the video.MP4 file into HLS format and save the output in video/demo.m3u8, following the directory structure defined by the BOS specifications.
1POST /video.mp4 HTTP/1.1
2Content-Length:ContentLength
3Content-Type: ContentType
4x-bce-process=video/format,f_hls|system/save,o_dmlkZW8vZGVtby5tM3U4
If you need to specify the segment duration for transcoding, you can add the t_* in the parameter to set the segment length. For example, to specify each segment as 20 s, the parameter is t_20.
Here is an example of a header:
x-bce-process=video/format,f_hls,t_20|system/save,o_dmlkZW8vZGVtby5tM3U4
Note: The result of video/demo.m3u8 after base64 encoding is dmlkZW8vZGVtby5tM3U4.
Rules and limitations
Supported specifications:
- Supported original audio/video size: Below 100 MB
- Supported original audio/video format:
MP4 - Supported target audio/video format:
HLS - Currently supported regions: Beijing, Baoding, Suzhou and Guangzhou
- Currently, it is only supported in BOS’s
HTTP POSTupload API
Currently, BOS multimedia cloud processing only supports conversion from .MP4 files to .HLS files. More types of support, file code conversion and other capabilities will be gradually supported by BOS in the future.
If you need more extensive processing capabilities in the short term and your application can tolerate relatively longer processing delays, please refer to Baidu AI Cloud’s Multimedia Cloud Transcoding (MCT) and Baidu AI Cloud Video On Demand (VOD) , Example:
- To obtain media information of multimedia cloud files in BOS, refer to the Media Information Acquisition API.
