Last update:2025-05-26 18:21:23
The Video Transcoding feature converts video files stored in your Object Storage from their original format into various target formats. This service enables flexible adjustments to video bitrate, resolution, and encoding methods. This ensures your video content is compatible for playback across diverse devices, providing an optimal viewing experience for all users.
The CDNetworks Video Transcoding service supports the following file formats and encoding standards:
| Category | Supported Items |
|---|---|
| Video Formats | MP4, FLV, HLS (m3u8), DASH (mpd), TS, MKV, MOV, WMV, AVI, VP8, VP9, RealVideo, Windows Media Video |
| Audio Formats | AAC, AC-3, MP1, MP2, MP3, PCM, RealAudio, Windows Media Audio (WMA), OGG |
| Encoding Formats | H.266 (VVC), H.265 (HEVC), H.264 (AVC), H.263, MPEG |
You can use video transcoding in the following scenarios:
Video transcoding operations are defined by setting the fops (file operations) parameter in the request. The fops parameter consists of a series of commands and sub-parameters, concatenated and separated by a forward slash (/).
The general structure is:
<op>/<Format_value>[/param1/<value1>/param2/<value2>...]|saveas/<Urlsafe_Base64_Encoded_Save_Path>
For example, a more detailed structure showing some common parameters would look like this:
<op>/<Format>
/r/<value>
/ab/<value>
/vb/<value>
/vcodec/<value>
/acodec/<value>
/s/<value>
/autoscale/<value>
/autofill/<value>
/GOPInterval/<value>
/rotate/<value>
/an/<value>
/vn/<value>
/moovToFront/<value>
/sar/<value>
/preset/<value>
|saveas/<Urlsafe_Base64_Encode(bucket:savedfilename)>
Key Points:
op: Operation type. For video transcoding, this is fixed as avthumb.Format: The target output video format (e.g., mp4, flv).|saveas/...: This part is mandatory. It specifies the storage location (bucket) and filename for the transcoded file, using URL-safe Base64 encoding.The table below lists the supported parameters for video transcoding and their descriptions:
| Parameter | Required | Description |
|---|---|---|
op |
Yes | Operation type. For video transcoding, set this to avthumb. |
format |
Yes | The target output format. Supported formats include mp4, flv, m3u8 (HLS), mpd (DASH), etc. |
r |
No | Video frame rate, in frames per second (fps). Common values include 24, 25, 30.Note: Dynamic frame rate capture is not supported. |
ab |
No | Audio bitrate, in bits per second (bit/s). Common values: 64k, 128k, 192k, 256k, 320k. (e.g., 128k for 128 kbps). |
vb |
No | Video bitrate, in bits per second (bit/s). Supports dynamic bitrate. Common values: 128k, 1.25m, 5m. (e.g., 128k for 128 kbps, 1.25m for 1.25 Mbps). |
vbRatio |
No | Video bitrate expressed as a coefficient. The output video bitrate is determined by multiplying the input video bitrate by this coefficient. The value range is (0, 15], and decimal values are supported. Note: If the value is 0 or greater than 15, an error will be returned. If the video bitrate calculated using vbRatio exceeds 50 Mbps, it is considered an abnormal situation, and this parameter will not take effect. If both vbRatio and vb are configured, vbRatio takes precedence. |
vcodec |
No | Specifies the video encoding scheme. If not specified, the system attempts to preserve the original encoding scheme. Options include: • libx264 - H.264• libvpx - VP8 and VP9 (Google codecs)• libxvid - MPEG-4• libws265 - H.265• vvc - H.266 |
acodec |
No | Specifies the audio encoding scheme. If not specified, the system attempts to preserve the original encoding scheme. Supports MP3, AAC, OGG, etc. |
s |
No | Specifies the output video resolution, in the format widthxheight (e.g., 1920x1080), or using a preset value.Width x Height Mode: Sets the exact width and height. If you provide both width and height, the transcoder will use these exact values. Note: If the aspect ratio of the set resolution differs from the original video’s aspect ratio, the image may appear stretched or compressed (unless used with autoscale or autofill).Width or Height Mode: If you provide only one dimension (e.g., 1280x or x720), the transcoder automatically calculates the other dimension while maintaining the original aspect ratio. For example, for a 1920x1080 video, if 1280x is specified, the output resolution will be 1280x720. |
autoscale |
No | Used with the s parameter to control aspect ratio handling:• 0 (default): Strictly processes according to the resolution dimensions specified by the s parameter, even if this results in image stretching.• 1: Scales the video while maintaining the original aspect ratio to fit within the dimensions specified by the s parameter. The output video will not exceed the width and height specified by s. |
autofill |
No | Used with the s parameter to control video output dimensions and padding:• 1: If the target aspect ratio differs from the source video, the source video is scaled to fit the dimensions specified by the s parameter while maintaining its aspect ratio. Black bars (letterboxing or pillarboxing) are added to fill any empty areas, ensuring the output matches the final resolution set by s. |
GOPInterval |
No | Sets the time interval between keyframes (I-frames), in milliseconds (ms). Note: This parameter conflicts with the g parameter (which defines the number of frames between keyframes); they cannot be used together. |
rotate |
No | Specifies the clockwise rotation angle. Options are 90, 180, 270, or auto (automatically detects and corrects rotation based on video metadata). By default, no rotation is applied. |
an |
No | Disables audio stream: • 0 (default): Retains the audio stream.• 1: Removes the audio stream; the output video will not contain audio. |
vn |
No | Disables video stream: • 0 (default): Retains the video stream.• 1: Removes the video stream; the output file will only contain the audio stream (if one exists). |
moovToFront |
No | Controls the position of the moov atom (metadata) in MP4 files:• 0 (default): Keeps metadata at the end of the file.• 1: Moves metadata to the beginning of the file. This typically speeds up video streaming startup, as the player can access initialization information more quickly. |
sar |
No | Sample Aspect Ratio. Sets a specific pixel aspect ratio (e.g., 1:1, 1:2). This parameter affects the final displayed aspect ratio and usually takes precedence over the aspect ratio implied by the s (resolution) parameter. For example, if the resolution is 720x720 and SAR is 1:2, pixels will be stretched vertically during display, resulting in an effective display resolution (or perceived resolution) of 720x1440. |
/crf/<value> |
No | Constant Rate Factor (CRF). This is a quality-control mode where the output bitrate dynamically adjusts based on scene complexity—lower for simple scenes, higher for complex scenes—to maintain a constant visual quality. The value typically ranges from 0 to 51 (for H.264/H.265). A lower value means better quality and a larger file; a higher value means lower quality and a smaller file. A recommended range is [18, 28]. |
level |
No | Sets the H.264/H.265 encoding Level. The Level defines a set of decoder constraints (e.g., maximum resolution, frame rate, bitrate). Example values range from 10 (Level 1.0) to 51 (Level 5.1). This parameter is effective only when the video codec is libx264. |
pix_fmt |
No | Sets the pixel format, e.g., yuv420p, yuv422p, or yuv444p. yuv420p (YUV 4:2:0) is the most common format for web video streaming, offering good compatibility and compression. |
vprofile |
No | Sets the video encoding Profile, such as baseline, main, high, high10, high422, high444 (primarily for H.264/H.265). The Profile defines the set of encoding tools used, affecting compression efficiency and compatibility. |
maxrate |
No | Maximum bitrate limit for dynamic bitrate, in kbit/s (e.g., 1000k) or Mbit/s (e.g., 8M; ‘M’ must be uppercase).Note: If you use this parameter, you must also specify the bufsize parameter. |
bufsize |
No | Encoder buffer size, used with maxrate, in kbit/s (e.g., 1000k) or Mbit/s (e.g., 8M; ‘M’ must be uppercase). It defines the buffer size required by the decoder to verify the video stream. |
seiKeep |
No | Determines whether to preserve SEI (Supplemental Enhancement Information) during transcoding. • 0 (default): SEI is not preserved.• 1: SEI is preserved.Notably, when only remuxing (i.e., changing the container format without re-encoding), SEI information is preserved by default. |
preset |
No | (Primarily for HLS) Specifies the name of a preset. A preset is a pre-configured group of optimized transcoding parameters. Using a preset name applies this group of parameters. You can also add specific parameters in your request to override individual settings within the preset. See “HLS Presets” below for details. |
saveas |
Yes | Defines the storage location (bucket) and filename for the transcoded file. This uses URL-safe Base64 encoding, in the format: Urlsafe_Base64_Encode(bucket:savedfilename). |
Notes:
To simplify HLS (m3u8) transcoding configuration, a series of presets are available. Each preset represents an optimized combination of parameters.
| Type | Preset Name | Description |
|---|---|---|
| Audio | audio_32k |
Audio bitrate: 32 kbps |
| Audio | audio_48k |
Audio bitrate: 48 kbps |
| Audio | audio_64k |
Audio bitrate: 64 kbps |
| Video | video_16x9_150k |
Bitrate: 150 kbps, Aspect Ratio: 16:9, Resolution: approx. 400x224 |
| Video | video_16x9_240k |
Bitrate: 240 kbps, Aspect Ratio: 16:9, Resolution: approx. 400x224 |
| Video | video_16x9_440k |
Bitrate: 440 kbps, Aspect Ratio: 16:9, Resolution: approx. 400x224 |
| Video | video_16x9_640k |
Bitrate: 640 kbps, Aspect Ratio: 16:9, Resolution: approx. 400x224 |
| Video | video_4x3_150k |
Bitrate: 150 kbps, Aspect Ratio: 4:3, Resolution: approx. 400x300 |
| Video | video_4x3_240k |
Bitrate: 240 kbps, Aspect Ratio: 4:3, Resolution: approx. 400x300 |
| Video | video_4x3_440k |
Bitrate: 440 kbps, Aspect Ratio: 4:3, Resolution: approx. 400x300 |
| Video | video_4x3_640k |
Bitrate: 640 kbps, Aspect Ratio: 4:3, Resolution: approx. 400x300 |
| Video | video_150k |
Bitrate: 150 kbps, maintains original aspect ratio, width may be based on 400px |
| Video | video_240k |
Bitrate: 240 kbps, maintains original aspect ratio, width may be based on 400px |
| Video | video_440k |
Bitrate: 440 kbps, maintains original aspect ratio, width may be based on 400px |
| Video | video_640k |
Bitrate: 640 kbps, maintains original aspect ratio, width may be based on 400px |
| Video | video_1000k |
Bitrate: 1000 kbps, maintains original aspect ratio |
| Video | video_1500k |
Bitrate: 1500 kbps, maintains original aspect ratio |
Note: The resolution in presets may be adjusted based on the source video’s characteristics to maintain the aspect ratio.
This example transcodes a video named test.mp4 located in the Object Storage bucket vod-wcs-test001 to FLV format. It sets the video bitrate to 128k. The transcoded file will be named test_file.flv and saved in the same bucket.
Parameter Combination (fops):
avthumb/flv/vb/128k|saveas/Urlsafe_Base64_Encode(vod-wcs-test001:test_file.flv)
Pseudo-code Request (curl):
curl -v -X POST \
--data "bucket=Urlsafe_Base64_Encode(vod-wcs-test001)&key=Urlsafe_Base64_Encode(test.mp4)&fops=Urlsafe_Base64_Encode(avthumb/flv/vb/128k|saveas/Urlsafe_Base64_Encode(vod-wcs-test001:test_file.flv))&force=1&separate=1" \
--header "Authorization: AccessKey:EncodeSign" \
--url "<http://mgrDomain/fops>"
Actual Request (Base64 Encoded):
curl -v -X POST \
-d "bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdC5tcDQ=&fops=YXZ0aHVtYi9mbHYvdmIvMTI4a3xzYXZlYXMvZG05a0xYZGpjeTEwWlhOME1EQXhPblJsYzNSZlptbHNaUzVtYkhZPQ==&force=1&separate=1" \
-H "Authorization: AccessKey:EncodeSign" \
--url "<http://mgrDomain/fops>"
This example transcodes a video named test.mp4 in the Object Storage bucket vod-wcs-test001 to HLS format, which generates an .m3u8 manifest file and corresponding .ts segments. The example uses the video_16x9_150k preset. This preset typically includes parameters such as:
The main transcoded .m3u8 file will be named test.m3u8 and saved in the same bucket.
Parameter Combination (fops):
avthumb/m3u8/preset/video_16x9_150k|saveas/Urlsafe_Base64_Encode(vod-wcs-test001:test.m3u8)
Pseudo-code Request (curl):
curl -v -X POST \
--data "bucket=Urlsafe_Base64_Encode(vod-wcs-test001)&key=Urlsafe_Base64_Encode(test.mp4)&fops=Urlsafe_Base64_Encode(avthumb/m3u8/preset/video_16x9_150k|saveas/Urlsafe_Base64_Encode(vod-wcs-test001:test.m3u8))&force=1&separate=1" \
--header "Authorization: AccessKey:EncodeSign" \
--url "<http://mgrDomain/fops>"
Actual Request (Base64 Encoded):
curl -v -X POST \
-d "bucket=dm9kLXdjcy10ZXN0MDAx&key=dGVzdC5tcDQ=&fops=YXZ0aHVtYi9tM3U4L3ByZXNldC92aWRlb18xNng5XzE1MGt8c2F2ZWFzL2RtOWtMWGRqY3kxMFpYTjBNREF4T25SbGMzUXViVE4xT0E9PQ==&force=1&separate=1" \
-H "Authorization: AccessKey:EncodeSign" \
--url "<http://mgrDomain/fops>"