Packaging

Last update:2024-01-09 15:20:41

Packaging empowers you to transform the container format of your audio and video files, without altering the resolution or bitrate. This essential process ensures the integrity of your media content while adapting it to diverse delivery requirements. At CDNetworks, we accommodate a wide range of video and audio formats and codecs, including the following:

  • Video formats: MP4, FLV, HLS, DASH, TS, MKV, MOV, WMV, AVI, VP8, VP9, RealVideo, Windows Media Video, etc.
  • Audio formats: AAC, AC-3, MP1, MP2, MP3, PCM, RealAudio, Windows Media Audio (WMA), OGG, etc.

For HLS and DASH formats, we offer the advantageous feature of segment sharing within manifests. This means that the .mpd (DASH manifest) and .m3u8 (HLS manifest) files can potentially share identical segments, resulting in significant storage optimization on your Object Storage.
Packaging can be executed while uploading the video to Object Storage, on existing videos within Object Storage, or simultaneously with other media processing operations.

How to Use

Structure your fops in the request body as follows:

<op>/<Format>
    /vn/<value>
    /an/<value>
    /segtime/<value>
    /fastStartSeg/<value>
    /dash_hls_playlist/<value>
    /segtype/<value>
|saveas/<Urlsafe_Base64_Encode(bucket:savedfilename)>

Video Transcoding Fops Parameters

Parameter Required Description
op Yes Operation type. For packaging, set the operation type to avthumb.
format Yes Target format for output, supports mp4, flv, m3u8, mpd, etc.
an No Whether to remove the audio track and retain video content only. Set to 0 to keep it, or 1 to remove it. The default setting is 0.
vn No Whether to remove the video content and retain audio track only. Set to 0 to keep it, or 1 to remove it. The default setting is 0.
segtime No This parameter is used to define the duration of each segments in HLS and DASH, with an integer value ranging from 1-120 seconds. If the parameter is left unset, the system defaults will apply as follows:
- For inputs in formats other than m3u8/mpd, the default segment duration is 10 seconds.
- For m3u8/mpd formatted inputs where no transcoding parameters are set, only the manifest will be produced and segments are left unchanged.
- For m3u8/mpd formatted inputs where transcoding parameters have been set, the segment duration will be calculated dynamically by the system.
fastStartSeg No This parameter is exclusively applicable to HLS, and it establishes the duration of the initial M segments as N seconds, denoted in the MxNs format.
For instance, ‘5x3s’ signifies that the first five segments each last 3 seconds.
segtype No This parameter is exclusively applicable to DASHand it determines the output formats of DASH segments, whether in mp4 or m4s(default).
dash_hls_playlist No Generate HLS playlist (.m3u8 file) from your existing DASH content, while intelligently leveraging shared segments to optimize storage utilization.
- Set dash_hls_playlist=1 to produce both MPD and M3U8 files for comprehensive compatibility.
- Set dash_hls_playlist=0(default) to generates only the MPD file for focused DASH delivery.
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).

Request Example

Example Request 1: Converting an FLV Video to MP4

The following example demonstrates how to package a video named test.flv into an MP4 video. The ouput video will be named test.mp4 and will be saved in the same vod-wcs-test001 bucket.
Pseudocode format for the request:

curl -v -X POST 
–d "bucket=Urlsafe_Base64_Encode(vod-wcs-test001)&key=Urlsafe_Base64_Encode(test.flv)&fops=Urlsafe_Base64_Encode(avthumb/mp4|saveas/Urlsafe_Base64_Encode(vod-wcs-test001:test.mp4))&force=1&separate=1"
–H "Authorization:AccessKey:EncodeSign" 
--url "http://mgrDomain/fops"

Actual request format:

curl -v -X POST 
-d "bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdC5mbHY=&fops=YXZ0aHVtYi9tcDR8c2F2ZWFzL2RtOWtMWGRqY3kxMFpYTjBNREF4T25SbGMzUXViWEEw&force=1&separate=1"
-H "Authorization:AccessKey:EncodeSign" 
--url "http://mgrDomain/fops"

Example Request 2: Converting an MP4 Video to HLS

This example shows how to package a test.mp4 video from the vod-wcs-test001 bucket into HLS format. The output video segments are 15 seconds each and the HLS manifest will be named test.m3u8 and saved in the same vod-wcs-test001 bucket.
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/m3u8/segtime/15|saveas/Urlsafe_Base64_Encode(vod-wcs-test001:test.m3u8))&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=YXZ0aHVtYi9tM3U4L3NlZ3RpbWUvMTV8c2F2ZWFzL2RtOWtMWGRqY3kxMFpYTjBNREF4T25SbGMzUXViVE4xT0E9PQ==&force=1&separate=1"
-H "Authorization:Authorization:AccessKey:EncodeSign" 
--url "http://mgrDomain/fops"

Example Request 3: Converting an MP4 Video to DASH

This example shows how to package a test.mp4 video from the vod-wcs-test001 bucket into DASH format. The output video segments are 10 seconds each and the DASH manifest will be named test.mpd and saved in the same vod-wcs-test001 bucket.
Pseudocode format for the request:

curl -v -X POST 
–d "bucket=Urlsafe_Base64_Encode(vod-wcs-test001)&key=Urlsafe_Base64_Encode(test.mpd)&fops=Urlsafe_Base64_Encode(avthumb/mpd|saveas/Urlsafe_Base64_Encode(vod-wcs-test001:test.mpd))&force=1&separate=1"
–H "Authorization:AccessKey:EncodeSign" 
--url "http://mgrDomain/fops"

Actual request format:

curl -v -X POST 
-d "bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdC5tcGQ=&fops=YXZ0aHVtYi9tcGR8c2F2ZWFzL2RtOWtMWGRqY3kxMFpYTjBNREF4T25SbGMzUXViWEJr&force=1&separate=1"
-H "Authorization:Authorization:AccessKey:EncodeSign" 
--url "http://mgrDomain/fops"
Is the content of this document helpful to you?
Yes
I have suggestion
Submitted successfully! Thank you very much for your feedback, we will continue to strive to do better!