Transcoding

Last updated: 2020-05-25 10:49:39

    Transcoding is an offline task that converts a video bitstream. It changes parameters of the source bitstream, such as codec, resolution, and bitrate, to adapt it to different devices and network conditions. The following benefits can be achieved with transcoding:

    • Increased compatibility: a source video can be transcoded to formats (e.g., MP4) that are compatible with more types of devices for smooth playback.
    • Increased bandwidth adaptability: a source video can be transcoded for output in multiple definitions such as LD, SD, HD, and FHD. End users can select the most appropriate bitrate depending on their network conditions.
    • Improved playback efficiency: the moov atom can be moved from the end of an MP4 file to its beginning, so the video can be played before it is entirely downloaded.
    • Watermarking: a watermark can be added to a video to mark video ownership or copyright. For more information, please see Watermark.
    • Reduced bandwidth consumption: with a more advanced codec (e.g., H.265), the bitrate of a video can be substantially reduced while retaining the original quality, which helps reduce the bandwidth consumption.

    After a video is transcoded, the playback URL of the output video can be obtained according to Result Getting. You can use your own player or a third-party player to play back the output video.

    The transcoding feature is mainly suitable for UGSV scenarios. For long video scenarios (video websites, online education, etc.), adaptive bitrate streaming can deliver a better user experience.

    Transcoding-Template">

    Transcoding Template

    The target specification of an output video after transcoding is subject to parameters such as codec, resolution, and bitrate, which can be customized in the form of VOD transcoding template as shown below:

    Category Parameter Description
    Muxing
    Container format The following video and audio container formats are supported:
  • Video: MP4, TS, HLS, and FLV
  • Audio: MP3, M4A, FLAC, and OGG
  • Video stream deletion If this parameter is enabled, the output video after transcoding will contain only the audio stream with the video stream discarded
    Audio stream deletion If this parameter is enabled, the output video after transcoding will contain only the video stream with the audio stream discarded
    Video encoding Codec H.264 and H.265 are supported
    Bitrate Supported bitrate range: 10 Kbps–35 Mbps
    Frame rate Supported frame rate range: 1–60 fps; common values: 24, 25, and 30 fps
    Resolution
  • Supported width range: 128–4,096 px
  • Supported height range: 128–4,096 px
  • GOP length Supported GOP length range: 1–10s
    Profile
  • When the video codec is H.264, the `Baseline`, `Main`, and `High` profiles are supported
  • When the video codec is H.265, only the `Main` profile is supported
  • Color space YUV420P is supported
    Audio encoding Codec MP3, AAC, AC3, and FLAC are supported
    Sample rate The following audio sample rates are supported:
  • 34,000 Hz
  • 44,100 Hz
  • 48,000 Hz
  • Bitrate Supported bitrate range: 26–256 Kbps, including the following values:
  • 48 Kbps
  • 64 Kbps
  • 128 Kbps
  • Channel
  • Mono
  • Dual
  • Stereo
  • For common transcoding specifications, VOD provides a preset transcoding template. In addition, you can also create and manage custom transcoding templates in the console (for detailed directions, please see Template Settings) or through server API.

    Task Initiation

    There are three ways to initiate a transcoding task, namely, directly initiating through server API, directly initiating through the console, and specifying a task upon upload. For more information, please see Task Initiation for video processing.

    Below are instructions for initiating transcoding tasks in these ways:

    • Call the server API ProcessMedia to initiate a task: specify the transcoding template ID in the MediaProcessTask.TranscodeTaskSet parameter in the request.
    • Initiate a task on a video through the console: add a task flow in the console, set the target transcoding specification in the task flow, and use the task flow to initiate video processing.
    • Specify a task upon upload from server: add a task flow in the console, set the target transcoding specification in the task flow, and specify this task flow as the procedure in the ApplyUpload request.
    • Specify a task upon upload from client: add a task flow in the console, set the target transcoding specification in the task flow, and specify this task flow as the procedure parameter in the signature for upload from client.
    • Upload through console: add a task flow in the console, set the target transcoding specification in the task flow, upload a video through the console, select Automatic Processing After Upload, and specify to execute this task flow upon video upload completion.

    ">

    Result Getting

    After initiating a transcoding task, you can wait for result notification asynchronously or perform task query synchronously to get the task execution result. Below is an example of getting the result notification in normal callback mode after the transcoding task is initiated (the fields with null value are omitted):

    {
        "EventType":"ProcedureStateChanged",
        "ProcedureStateChangeEvent":{
            "TaskId":"1256768367-Procedure-2e1af2456351812be963e309cc133403t0",
            "Status":"FINISH",
            "FileId":"5285890784246869930",
            "FileName":"Animal World",
            "FileUrl":"http://1256768367.vod2.myqcloud.com/xxx/xxx/AtUCmy6gmIYA.mp4",
            "MetaData":{
                "AudioDuration":60,
                "AudioStreamSet":[
                    {
                        "Bitrate":383854,
                        "Codec":"aac",
                        "SamplingRate":48000
                    }
                ],
                "Bitrate":1021028,
                "Container":"mov,mp4,m4a,3gp,3g2,mj2",
                "Duration":60,
                "Height":480,
                "Rotate":0,
                "Size":7700180,
                "VideoDuration":60,
                "VideoStreamSet":[
                    {
                        "Bitrate":637174,
                        "Codec":"h264",
                        "Fps":23,
                        "Height":480,
                        "Width":640
                    }
                ],
                "Width":640
            },
            "MediaProcessResultSet":[
                {
                    "Type":"Transcode",
                    "TranscodeTask":{
                        "Status":"SUCCESS",
                        "ErrCode":0,
                        "Message":"",
                        "Input":{
                            "Definition":220
                        },
                        "Output":{
                            "Url":"http://1256768367.vod2.myqcloud.com/xxx/xxx/v.f20.m3u8",
                            "Size":63120997,
                            "Container":"mov,mp4,m4a,3gp,3g2,mj2",
                            "Height":480,
                            "Width":640,
                            "Bitrate":513402,
                            "Md5":"084d403c73930ca2f835679af1f37bd3",
                            "Duration":60,
                            "VideoStreamSet":[
                                {
                                    "Bitrate":473101,
                                    "Codec":"h264",
                                    "Fps":24,
                                    "Height":480,
                                    "Width":640
                                }
                            ],
                            "AudioStreamSet":[
                                {
                                    "Bitrate":48581,
                                    "Codec":"aac",
                                    "SamplingRate":44100
                                }
                            ],
                            "Definition":220
                        }
                    }
                }
            ],
            "TasksPriority":0,
            "TasksNotifyMode":""
        }
    }

    In the callback result, ProcedureStateChangeEvent.MediaProcessResultSet contains the transcoding result in Type of Transcode, and Definition is 220.

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback
    Help