最終更新日:2024-09-13 11:00:18
Video Transcoding enables the conversion of your videos, which are stored on Object Storage, from their original format to a variety of bitrates, resolutions, and codecs. This process ensures compatibility across multiple devices, guaranteeing the most optimal viewer experience.
At CDNetworks, we accommodate a wide range of video and audio formats and codecs, including the following:
Transcoding can be executed while uploading the video to Object Storage, on existing videos within Object Storage, or simultaneously with other media processing operations.
Structure your fops
in the request body as follows:
<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)>
Video Transcoding Fops Parameters
Parameter | Required | Description |
---|---|---|
op | Yes | Operation type. For video transcoding, set the operation type to avthumb . |
format | Yes | Target format for output, supports mp4, flv, m3u8, mpd, etc. |
r | No | Video frame rate, also known as frames displayed per second. Does not support dynamic frame rates. Common frame rates: 24, 25, 30, etc. |
ab | No | Audio bitrate, unit: bits per second (bit/s). Common bitrates: 64k, 128k, 192k, 256k, 320k, etc. |
vb | No | Video bitrate, unit: bits per second (bit/s). Supports dynamic bitrate. Common video bitrates: 128k, 1.25m, 5m, etc. |
vcodec | No | Video codecs, the transcoding supports a variety of formats including H.266, H.265, MPEG-4, H.264, and more. If no specific codec is selected, the output video will maintain the same codec as the original.Codec Options:libx: H.264libvpx: VP8 and VP9(Google codecs)libxvid: MPEG-4libws265: H.265 codecsvvc: H.266 |
acodec | No | Audio codecs, the transcoding supports a variety of formats including MP3, AAC, OGG, and more. If no specific codec is selected, the output audio will maintain the same codec as the original. |
s | No | Specify the video resolution for transcoding, either in the format width x height (e.g., 1920x1080) or using one of our preset values.Resolution Options:Width and Height: If you provide both width and height, the transcoded video will strictly follow these dimensions. Note: If the output aspect ratio (width/height) differs from the original video, the output may be stretched and lose its original shape. Width or Height: If you provide only width or height, the transcoded video will automatically scale based on the original video’s aspect ratio, preventing stretching. For example, if the original video is 1920x1080 and you provide 1280x or x720, the output video will be scaled to 1280x720. |
autoscale | No | This parameter is intended to be used in conjunction with the Resolution parameter. It determines if transcoding adheres strictly to the provided Resolution (previous parameter) or automatically scales the video while maintaining its original aspect ratio.0 (default) : The transcoding will strictly follow the Resolution dimensions, even if it causes stretching or distortion. For example, an original video with dimensions of 1920x1920, when specified as 1280x720, will be adjusted to fit within the 1280x720 frame, no matter the potential for distortion.1 : The transcoding will automatically scale based on the original video’s aspect ratio to fit within the specified Resolution dimensions. For example, a 1920x1920 original video specified as 1280x720 will be scaled to 720x720, maintaining the original 1:1 aspect ratio of the video. |
autofill | No | This parameter works with the Resolution parameter to control how the transcoded video fills the target dimensions. A value of 1 indicates that black bars are added to extend the video to the desired size(padding), eliminating the need for stretching or distortion. For instance, if the original video measures 1920x1920 and the target output resolution is set at 1280x720, the output will maintain the size of 1280x720. However, the actual frame size will be 720x720, with the video centrally placed and accompanied by black bars on either side. |
GOPInterval | No | Set the time between key frames in milliseconds (ms) with this parameter. This option conflicts with the g parameter, which defines the number of frames between key frames. |
rotate | No | Specify the clockwise rotation angle in degrees: 90, 180, 270, or auto for automatic adjustment. No rotation by default. |
an | No | Remove the audio track. Set to 0 to keep it, or 1 to remove it. The default setting is 0. |
vn | No | Remove the video stream. Set to 0 to keep it, or 1 to remove it. The default setting is 0. |
moovToFront | No | The moov atom in MP4 files contains essential metadata. Set moovToFront to 1 to place the moov atom at the beginning for improved playback performance, especially for streaming. 0 (default): Keep metadata at the end (as usual).1: Move metadata to the beginning for faster startup. |
sar | No | Control the video’s aspect ratio (e.g., 1:1). This overrides the chosen resolution. If you set the resolution to 720x720 and SAR to 1:2, the final video will be 720x1420 to preserve the intended aspect ratio. |
preset | No | The HLS Preset (or Preset Set) refers to a pre-designed bundle of transcoding templates. These templates come with pre-set parameters to streamline your transcoding process. However, when using a preset set, other parameters can be specified to override corresponding preset parameters. See all the presets we currently support in the table below. |
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) . |
HLS Presets
Type | Preset | Description |
---|---|---|
Audio | audio_32k | Audio with a bitrate of 32k |
Audio | audio_48k | Audio with a bitrate of 48k |
Audio | audio_64k | Audio with a bitrate of 64k |
Video | video_16x9_150k | Video with a bitrate of 150K, aspect ratio 16:9, resolution 400x224 |
Video | video_16x9_240k | Video with a bitrate of 240K, aspect ratio 16:9, resolution 400x224 |
Video | video_16x9_440k | Video with a bitrate of 440K, aspect ratio 16:9, resolution 400x224 |
Video | video_16x9_640k | Video with a bitrate of 640K, aspect ratio 16:9, resolution 400x224 |
Video | video_4x3_150k | Video with a bitrate of 150K, aspect ratio 4:3, resolution 400x300 |
Video | video_4x3_240k | Video with a bitrate of 240K, aspect ratio 4:3, resolution 400x300 |
Video | video_4x3_440k | Video with a bitrate of 440K, aspect ratio 4:3, resolution 400x300 |
Video | video_4x3_640k | Video with a bitrate of 640K, aspect ratio 4:3, resolution 400x300 |
Video | video_150k | Video with a bitrate of 150K, aspect ratio defined as original |
Video | video_240k | Video with a bitrate of 240K, aspect ratio defined as original |
Video | video_440k | Video with a bitrate of 440K, aspect ratio defined as original |
Video | video_640k | Video with a bitrate of 640K, aspect ratio defined as original |
Video | video_1000k | Video with a bitrate of 1000K, aspect ratio defined as original |
Video | video_1500k | Video with a bitrate of 1500K, aspect ratio defined as original |
The following example demonstrates how to transcode a video named test.mp4
from the vod-wcs-test001
bucket into an FLV format with a bitrate of 128K. The resulting video will be named test_file.flv
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.mp4)&fops=Urlsafe_Base64_Encode(avthumb/flv/vb/128k|saveas/Urlsafe_Base64_Encode(vod-wcs-test001:test_file.flv))&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=YXZ0aHVtYi9mbHYvdmIvMTI4a3xzYXZlYXMvZG05a0xYZGpjeTEwWlhOME1EQXhPblJsYzNSZlptbHNaUzVtYkhZPQ==&force=1&separate=1"
-H "Authorization:AccessKey:EncodeSign"
--url "http://mgrDomain/fops"
This example shows how to transcode a test.mp4
video from the vod-wcs-test001
bucket into HLS format. The output video will have a bitrate of 150K, an aspect ratio of 16:9, and a resolution of 400x224. The HLS manifest file 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/preset/video_16x9_150k|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=YXZ0aHVtYi9tM3U4L3ByZXNldC92aWRlb18xNng5XzE1MGt8c2F2ZWFzL2RtOWtMWGRqY3kxMFpYTjBNREF4T25SbGMzUXViVE4xT0E9PQ==&force=1&separate=1"
-H "Authorization:Authorization:AccessKey:EncodeSign"
--url "http://mgrDomain/fops"