Updates a custom transcoding template.

Usage notes

A custom transcoding template cannot be updated if it is being used by a job that has been submitted.

QPS limit

You can call this operation up to 100 times per second. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. For more information, see QPS limit.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes UpdateTemplate

The operation that you want to perform. Set the value to UpdateTemplate.

TemplateId String Yes 16f01ad6175e4230ac42bb5182cd****

The ID of the template. You can obtain the template ID from the response of the AddTemplate operation.

Name String Yes MPS-example

The name of the template. The name can be up to 128 bytes in length.

Container String No {"Format":"mp4"}

The container format. The value is a JSON object. Default format: MP4.

  • Video formats: FLV, MP4, HLS (M3U8 + TS), and MPEG-DASH (MPD + fMP4)
  • Audio formats: MP3, MP4, OGG, FLAC, and M4A
  • Images formats: GIF and WebP

For more information, see the "Container" section of the Parameter details topic.

Video String No {"Codec":"H.264","Profile":"high","Bitrate":"500","Crf":"15","Width":"256","Height":"800","Fps":"25","Gop":"10"}

The configuration of the video stream. The value is a JSON object. For more information, see the "Videor" section of the Parameter details topic.

Audio String No {"Codec":"aac","Samplerate":"44100","Bitrate":"500","Channels":"2"}

The configuration of the audio stream. The value is a JSON object. For more information, see the "Audio" section of the Parameter details topic.

MuxConfig String No {"Segment":{"Duration":"10"}}

The transmuxing configuration. The value is a JSON object. For more information, see the "MuxConfig" section of the Parameter details topic.

TransConfig String No {"TransMode":"onepass"}

The general transcoding configuration. The value is a JSON object. For more information, see the "TransConfig" section of the Parameter details topic.

Response parameters

Parameter Type Example Description
RequestId String 5E4FB22E-B9EA-4E24-8FFC-B407EA71QW21

The ID of the request.

Template Object

The type of the transcoding template.

Video Object

The video codec configurations.

LongShortMode String false

Indicates whether the auto-rotate screen feature is enabled.

  • If this feature is enabled, the width of the output video corresponds to the long side of the input video, which is the height of the input video in portrait mode. The height of the output video corresponds to the short side of the input video, which is the width of the input video in portrait mode.
  • true: The auto-rotate screen feature is enabled.
  • false: The auto-rotate screen feature is disabled.
  • Default value: false.
Bufsize String 6000

The size of the buffer.

  • Unit: KB.
  • Default value: 6000.
Degrain String 10

The level of quality control on the video.

BitrateBnd Object

The average bitrate range of the video.

Max String 500

The upper limit of the total bitrate. Unit: Kbit/s.

Min String 100

The lower limit of the total bitrate. Unit: Kbit/s.

PixFmt String yuv420p

The pixel format. Valid values: standard pixel formats such as yuv420p and yuvj420p.

Pad String 1280:800:0:140

The black borders to be added to the video.

  • Format: width:height:left:top.
  • Example: 1280:800:0:140.
Codec String H.264

The video codec. Default value: H.264.

Height String 800

The height of the output video.

  • Unit: pixel.
  • Default value: the height of the input video.
Qscale String 1

The strength of the independent noise reduction algorithm.

Crop String border

The method used to crop the video. Valid values:

  • border: automatically detects and removes borders.
  • Other values: the custom cropping modes. Format: width:height:left:top. Example: 1280:800:0:140.
Bitrate String 200

The average bitrate of the video. Unit: Kbit/s.

Maxrate String 500

The maximum bitrate of the output video. Unit: Kbit/s.

MaxFps String 60

The maximum frame rate.

Profile String high

The encoding profile. Valid values:

  • baseline: applicable to mobile devices.
  • main: applicable to standard-definition devices.
  • high: applicable to high-definition devices.
  • Default value: high.
Crf String 15

The bitrate quality control factor.

  • Default value when the Codec parameter is set to H.264: 23. Default value when the Codec parameter is set to H.265: 26.
  • If this parameter is specified, the setting of the Bitrate parameter is invalid.
Remove String false

Indicates whether the video stream is deleted. Valid values:

  • true: The video stream is deleted.
  • false: The video stream is retained.
  • Default value: false.
Gop String 10

The maximum number of frames between two keyframes. Default value: 250.

Width String 256

The width of the video.

  • Unit: pixel.
  • Default value: the original video width.
Fps String 25

The frame rate.

  • A value of 60 is returned if the frame rate of the input video exceeds 60.
  • Default value: the frame rate of the input video.
Preset String medium

The preset video algorithm. Default value: medium. Valid values:

  • veryfast
  • fast
  • medium
  • slow
  • slower
ScanMode String interlaced

The scan mode. Valid values:

  • interlaced: An interlaced scan is performed.
  • progressive: A progressive scan is performed.
ResoPriority String 1

The policy of resolution adjustment.

TransConfig Object

The general transcoding configurations.

IsCheckAudioBitrate String false

Indicates whether the audio bitrate is checked. If this parameter is set to true and the system detects that the bitrate of the output audio is greater than the bitrate of the input audio, the bitrate of the input audio is retained after transcoding. In this case, the specified audio bitrate does not take effect. This parameter has a lower priority than the IsCheckAudioBitrateFail parameter. Valid values:

  • true: The audio bitrate is checked.
  • false: The audio bitrate is not checked.
  • Default values:
    • If the parameter is left empty and the codec of the output audio is different from that of the input audio, the default value is false.
    • If the parameter is left empty and the codec of the output audio is the same as that of the input audio, the default value is true.
TransMode String onepass

The transcoding mode. Default value: onepass. Valid values:

  • onepass
  • twopass
  • CBR
IsCheckReso String false

Indicates whether the resolution is checked. If this parameter is set to true and the system detects that the output resolution is higher than the input resolution based on the width or height, the system considers that the output resolution equals the input resolution.

  • true: The resolution is checked.
  • false: The resolution is not checked.
  • Default value: false.
IsCheckVideoBitrateFail String false

Indicates whether the video bitrate is checked. This parameter takes precedence over the IsCheckVideoBitrate parameter.

  • true: The video bitrate is checked.
  • false: The video bitrate is not checked.
  • Default value: false.
AdjDarMethod String none

The method of resolution adjustment. Default value: none. Valid values:

  • rescale: The input video is rescaled.
  • crop: The input video is cropped.
  • none: No change is made.
IsCheckVideoBitrate String false

Indicates whether the video bitrate is checked. If this parameter is set to true and the system detects that the video bitrate of the output file is greater than that of the input file, the video bitrate of the input file is retained after transcoding. Valid values:

  • true: The video bitrate is checked.
  • false: The video bitrate is not checked.
  • Default value: false.
IsCheckResoFail String false

Indicates whether the resolution is checked. If this parameter is set to true and the system detects that the output resolution is higher than the input resolution based on the width or height, a transcoding failure is returned.

  • true: The resolution is checked.
  • false: The resolution is not checked.
  • Default value: false.
IsCheckAudioBitrateFail String false

Indicates whether the audio bitrate is checked. This parameter takes precedence over the IsCheckAudioBitrate parameter.

  • true: The audio bitrate is checked.
  • false: The audio bitrate is not checked.
  • Default value: false.
State String Normal

The status of the template. Valid values:

  • Normal: The template is normal.
  • Deleted: The template is deleted.
MuxConfig Object

The transmuxing configuration.

Webp Object

The transmuxing configuration for WebP.

Loop String 0

The loop count.

Gif Object

The transmuxing configuration for GIF.

FinalDelay String false

The duration for which the final frame is paused. Unit: milliseconds.

DitherMode String bayer

The color dithering algorithm of the palette. Valid values: sierra and bayer.

Loop String 0

The loop count.

IsCustomPalette String 0

Indicates whether the custom palette is used.

Segment Object

The segment configuration.

Duration String 10

The length of the segment. Unit: seconds.

Name String MPS-example

The name of the template.

Audio Object

The audio codec configuration.

Profile String aac_low

The codec profile of the audio. Valid values when the Codec parameter is set to aac:

  • aac_low
  • aac_he
  • aac_he_v2
  • aac_ld
  • aac_eld
Remove String false

Indicates whether the audio stream is deleted. Valid values:

  • true: The audio stream is deleted.
  • false: The audio stream is retained.
  • Default value: false.
Codec String aac

The audio codec. Default value: aac. Valid values:

  • aac
  • mp3
  • vorbis
  • flac
Samplerate String 44100

The sampling rate.

  • Unit: Hz.
  • Default value: 44100.
Qscale String 1

The strength of the independent noise reduction algorithm.

Channels String 2

The number of sound channels. Default value: 2.

Bitrate String 500

The audio bitrate of the output file.

  • Valid values: [8, 1000].
  • Unit: Kbit/s.
  • Default value: 128.
Id String 16f01ad6175e4230ac42bb5182cd****

The ID of the transcoding template.

Container Object

The container configuration.

Format String mp4

The container format.

Examples

Sample requests

http(s)://mts.cn-shanghai.aliyuncs.com/?Action=UpdateTemplate/?Action=UpdateTemplate
&ResourceOwnerId=1
&TemplateId=16f01ad6175e4230ac42bb5182cd****
&Name=MPS-example
&Container={"Format":"mp4"}
&Video={"Codec":"H.264","Profile":"high","Bitrate":"500","Crf":"15","Width":"256","Height":"800","Fps":"25","Gop":"10"}
&Audio={"Codec":"aac","Samplerate":"44100","Bitrate":"500","Channels":"2"}
&MuxConfig={"Segment":{"Duration":"10"}}
&TransConfig={"TransMode":"onepass"}
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<UpdateTemplateResponse>
    <RequestId>5E4FB22E-B9EA-4E24-8FFC-B407EA71QW21</RequestId>
    <Template>
        <Video>
            <LongShortMode>false</LongShortMode>
            <Bufsize>6000</Bufsize>
            <Degrain>10</Degrain>
            <BitrateBnd>
                <Max>500</Max>
                <Min>100</Min>
            </BitrateBnd>
            <PixFmt>yuv420p</PixFmt>
            <Pad>1280:800:0:140</Pad>
            <Codec>H.264</Codec>
            <Height>800</Height>
            <Qscale>1</Qscale>
            <Crop>border</Crop>
            <Bitrate>200</Bitrate>
            <Maxrate>500</Maxrate>
            <MaxFps>60</MaxFps>
            <Profile>high</Profile>
            <Crf>15</Crf>
            <Remove>false</Remove>
            <Gop>10</Gop>
            <Width>256</Width>
            <Fps>25</Fps>
            <Preset>medium</Preset>
            <ScanMode>interlaced</ScanMode>
            <ResoPriority>1</ResoPriority>
        </Video>
        <TransConfig>
            <IsCheckAudioBitrate>false</IsCheckAudioBitrate>
            <TransMode>onepass</TransMode>
            <IsCheckReso>false</IsCheckReso>
            <IsCheckVideoBitrateFail>false</IsCheckVideoBitrateFail>
            <AdjDarMethod>none</AdjDarMethod>
            <IsCheckVideoBitrate>false</IsCheckVideoBitrate>
            <IsCheckResoFail>false</IsCheckResoFail>
            <IsCheckAudioBitrateFail>false</IsCheckAudioBitrateFail>
        </TransConfig>
        <State>Normal</State>
        <MuxConfig>
            <Webp>
                <Loop>0</Loop>
            </Webp>
            <Gif>
                <FinalDelay>false</FinalDelay>
                <DitherMode>bayer</DitherMode>
                <Loop>0</Loop>
                <IsCustomPalette>0</IsCustomPalette>
            </Gif>
            <Segment>
                <Duration>10</Duration>
            </Segment>
        </MuxConfig>
        <Name>MPS-example</Name>
        <Audio>
            <Profile>aac_low</Profile>
            <Remove>false</Remove>
            <Codec>aac</Codec>
            <Samplerate>44100</Samplerate>
            <Qscale>1</Qscale>
            <Channels>2</Channels>
            <Bitrate>500</Bitrate>
        </Audio>
        <Id>16f01ad6175e4230ac42bb5182cd****</Id>
        <Container>
            <Format>mp4</Format>
        </Container>
    </Template>
</UpdateTemplateResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "5E4FB22E-B9EA-4E24-8FFC-B407EA71QW21",
  "Template" : {
    "Video" : {
      "LongShortMode" : "false",
      "Bufsize" : "6000",
      "Degrain" : "10",
      "BitrateBnd" : {
        "Max" : "500",
        "Min" : "100"
      },
      "PixFmt" : "yuv420p",
      "Pad" : "1280:800:0:140",
      "Codec" : "H.264",
      "Height" : "800",
      "Qscale" : "1",
      "Crop" : "border",
      "Bitrate" : "200",
      "Maxrate" : "500",
      "MaxFps" : "60",
      "Profile" : "high",
      "Crf" : "15",
      "Remove" : "false",
      "Gop" : "10",
      "Width" : "256",
      "Fps" : "25",
      "Preset" : "medium",
      "ScanMode" : "interlaced",
      "ResoPriority" : "1"
    },
    "TransConfig" : {
      "IsCheckAudioBitrate" : "false",
      "TransMode" : "onepass",
      "IsCheckReso" : "false",
      "IsCheckVideoBitrateFail" : "false",
      "AdjDarMethod" : "none",
      "IsCheckVideoBitrate" : "false",
      "IsCheckResoFail" : "false",
      "IsCheckAudioBitrateFail" : "false"
    },
    "State" : "Normal",
    "MuxConfig" : {
      "Webp" : {
        "Loop" : "0"
      },
      "Gif" : {
        "FinalDelay" : "false",
        "DitherMode" : "bayer",
        "Loop" : "0",
        "IsCustomPalette" : "0"
      },
      "Segment" : {
        "Duration" : "10"
      }
    },
    "Name" : "MPS-example",
    "Audio" : {
      "Profile" : "aac_low",
      "Remove" : "false",
      "Codec" : "aac",
      "Samplerate" : "44100",
      "Qscale" : "1",
      "Channels" : "2",
      "Bitrate" : "500"
    },
    "Id" : "16f01ad6175e4230ac42bb5182cd****",
    "Container" : {
      "Format" : "mp4"
    }
  }
}

Error codes

For a list of error codes, see Service error codes.