Cria um modelo de transcodificação personalizado. Você precisa configurar informações como o formato do contêiner, as configurações de fluxo de vídeo e as configurações de fluxo de áudio.
Descrição da operação
Ao chamar esta operação, você precisa definir parâmetros de transcodificação, como os relacionados ao formato do contêiner, fluxo de vídeo e fluxo de áudio. Se você não especificar alguns parâmetros, os fluxos gerados usando o modelo não conterão as informações especificadas por esses parâmetros.
Limite de QPS
Você pode chamar esta operação até 100 vezes por segundo por conta. As solicitações que excederem esse limite serão descartadas e você poderá sofrer interrupções de serviço. Recomendamos que você observe esse limite ao chamar esta operação. Para mais informações, consulte Limite de QPS.
Experimente agora
Testar
Autorização RAM
|
Ação |
Nível de acesso |
Tipo de recurso |
Chave de condição |
Ação dependente |
|
mts:AddTemplate |
create |
*All Resource
|
Nenhuma | Nenhuma |
Parâmetros da solicitação
|
Parâmetro |
Tipo |
Obrigatório |
Descrição |
Exemplo |
| Name |
string |
Sim |
O nome do modelo de transcodificação. O nome pode ter até 128 bytes de comprimento. |
mps-example |
| Container |
string |
Não |
O formato do contêiner. O valor deve ser um objeto JSON que contém o parâmetro Format. Se você não especificar este parâmetro, o arquivo de mídia transcodificado estará no formato MP4 por padrão. Este parâmetro é obrigatório se você deseja usar o modelo de transcodificação para gerar arquivos de mídia em outros formatos. Para mais informações, consulte Container.
Nota
Se o formato do contêiner for FLV, o codec de vídeo não pode ser definido como H.265.
Nota
|
{"Format":"mp4"} |
| Video |
string |
Não |
As configurações do fluxo de vídeo. O valor deve ser um objeto JSON. Para mais informações, consulte Video. Nota
Se você não especificar este parâmetro, os arquivos de saída não conterão fluxos de vídeo. Este parâmetro é obrigatório se você deseja manter os fluxos de vídeo. |
{"Codec":"H.264","Profile":"high","Bitrate":"500","Crf":"15","Width":"256","Height":"800","Fps":"25","Gop":"10s"} |
| Audio |
string |
Não |
As configurações do fluxo de áudio. O valor deve ser um objeto JSON. Para mais informações, consulte Audio. Nota
Se você não especificar este parâmetro, os arquivos de saída não conterão fluxos de áudio. Este parâmetro é obrigatório se você deseja manter os fluxos de áudio. |
{"Codec":"H.264","Samplerate":"44100","Bitrate":"500","Channels":"2"} |
| TransConfig |
string |
Não |
As configurações gerais de transcodificação. O valor deve ser um objeto JSON. Para mais informações, consulte TransConfig. Se você não especificar este parâmetro, as configurações padrão serão usadas. Este parâmetro é obrigatório se as configurações padrão não atenderem aos seus requisitos de negócio. |
{"TransMode":"onepass"} |
| MuxConfig |
string |
Não |
As configurações de segmentação. O valor deve ser um objeto JSON. Para mais informações, consulte MuxConfig. Se você não especificar este parâmetro, os arquivos de segmento de mídia não serão gerados. Este parâmetro é obrigatório se você deseja gerar arquivos de segmento de mídia. |
{"Segment":{"Duration":"10"}} |
Container
| Parâmetro | Tipo | Obrigatório | Descrição |
| Format | String | Não | O valor padrão deste parâmetro é MP4. A transcodificação de vídeo suporta os seguintes formatos: FLV, MP4, HLS (M3U8 + TS) e MPEG-DASH (MPD + fMP4). A transcodificação de áudio suporta os seguintes formatos: MP3, MP4, OGG, FLAC e M4A. A transcodificação de imagem suporta os formatos GIF e WebP. Se você definir o formato do contêiner como GIF, o codec de vídeo deve ser definido como GIF. Se você definir o formato do contêiner como WebP, o codec de vídeo deve ser definido como WebP. Se você definir o formato do contêiner como FLV, o codec de vídeo não pode ser definido como H.265. |
Video
| Parâmetro | Tipo | Obrigatório | Descrição |
| Codec | String | Não | O codec de vídeo. Valores válidos: H.264, H.265, GIF e WebP. Valor padrão: H.264. |
| Profile | String | Não | O perfil do codec. Valores válidos: baseline, main e high. Valor padrão: high. Um valor de baseline especifica que os arquivos de mídia são transcodificados para dispositivos móveis. Um valor de main especifica que os arquivos de mídia são transcodificados para dispositivos de definição padrão. Um valor de high especifica que os arquivos de mídia são transcodificados para dispositivos de alta definição. Se várias definições estiverem disponíveis, recomendamos que você defina este parâmetro como baseline para a definição mais baixa, a fim de garantir a reprodução normal em dispositivos de baixo desempenho. Defina este parâmetro como main ou high para outras definições. Este parâmetro é válido apenas se o parâmetro Codec estiver definido como H.264. |
| Bitrate | String | Não | Valores válidos: 10 a 50000. Unidade: Kbit/s. |
| Crf | String | Não | O fator de taxa constante. Valores válidos: 0 a 51. Valor padrão: 26. Se você especificar este parâmetro, a configuração do parâmetro Bitrate se torna inválida. |
| Width | String | Não | A largura do vídeo. Valores válidos: 128 a 4096. Valor padrão: a largura do vídeo de entrada. Unidade: pixel. |
| Height | String | Não | A altura do vídeo. Valores válidos: 128 a 4096. Valor padrão: a altura do vídeo de entrada. Unidade: pixel. |
| Fps | String | Não | A taxa de quadros do vídeo. Valor padrão: a taxa de quadros do arquivo de entrada. O valor é 60 se a taxa de quadros do arquivo de entrada exceder 60. Valores válidos: 0 a 60. Unidade: quadros por segundo. |
| Gop | String | Não | O tamanho do grupo de imagens (GOP). O tamanho do GOP pode ser o intervalo máximo de keyframes ou o número máximo de quadros em um grupo de quadros. Se você especificar o intervalo máximo de keyframes, a unidade (s) é obrigatória. Valor padrão: 10s. Se você especificar o número máximo de quadros, o valor não possui unidade. Valores válidos: 1 a 100000. |
| Preset | String | Não | O algoritmo de vídeo predefinido. Valores válidos: veryfast, fast, medium, slow e slower. Valor padrão: medium. Este parâmetro é válido apenas se o parâmetro Codec estiver definido como H.264. |
| ScanMode | String | Não | O modo de varredura. Valores válidos: interlaced e progressive. |
| Bufsize | String | Não | O tamanho do buffer. Valores válidos: 1000 a 128000. Valor padrão: 6000. Unidade: KB. |
| Maxrate | String | Não | O bitrate máximo do vídeo. Valores válidos: 10 a 50000. Unidade: Kbit/s. |
| PixFmt | String | Não | O formato de pixel do vídeo. Formatos de pixel padrão como yuv420p e yuvj420p são suportados. Por padrão, yuv420p ou o formato de pixel do vídeo de entrada é usado. |
| Remove | String | Não | Especifica se o fluxo de vídeo deve ser excluído. Um valor de true especifica a exclusão do fluxo de vídeo. Um valor de false especifica a manutenção do fluxo de vídeo. Valor padrão: false. |
| Crop | String | Não | O método de corte do vídeo. Um valor de border especifica a detecção e o corte automáticos das bordas pretas. Um valor no formato largura:altura:esquerda:topo especifica o corte da imagem do vídeo com base nas configurações personalizadas. Exemplo: 1280:800:0:140. |
| Pad | String | Não | As bordas pretas a serem adicionadas ao vídeo. O valor deve estar no formato largura:altura:esquerda:topo. Exemplo: 1280:800:0:140. |
| LongShortMode | String | Não | Especifica se o recurso de rotação automática de tela deve ser ativado. Se este recurso estiver ativado, a largura do vídeo de saída corresponde ao lado longo do vídeo de entrada, que é a altura do vídeo de entrada no modo retrato. A altura do vídeo de saída corresponde ao lado curto do vídeo de entrada, que é a largura do vídeo de entrada no modo retrato. Um valor de true especifica a ativação do recurso de rotação automática de tela. Um valor de false especifica a desativação do recurso de rotação automática de tela. Valor padrão: false. |
A tabela a seguir descreve as combinações suportadas de formatos de contêiner, codecs de vídeo e codecs de áudio.
| Formato do contêiner | Codec de áudio | Codec de vídeo |
| FLV | AAC e MP3 | H.264 |
| MP4 | AAC e MP3 | H.264 e H.265 |
| TS | AAC e MP3 | H.264 e H.265 |
| M3U8 | AAC e MP3 | H.264 e H.265 |
| GIF | Não suportado | GIF |
A tabela a seguir descreve os parâmetros de fluxo de vídeo suportados por diferentes codecs de vídeo. Um valor de Y especifica que um parâmetro é suportado. Um valor de N especifica que um parâmetro não é suportado.
| Codec de vídeo | H.264 | H.265 | GIF |
| Profile | Y | N | N |
| Bitrate | Y | Y | N |
| Crf | Y | Y | N |
| Width | Y | Y | Y |
| Height | Y | Y | Y |
| Fps | Y | Y | Y |
| Gop | Y | Y | N |
| Preset | Y | N | N |
| ScanMode | Y | Y | Y |
| Bufsize | Y | Y | N |
| Maxrate | Y | Y | N |
| PixFmt | Y | Y | bgr8 |
Audio
| Parâmetro | Tipo | Obrigatório | Descrição |
| Codec | String | Não | O codec de áudio. Valores válidos: AAC, MP3, VORBIS e FLAC. Valor padrão: AAC. |
| Profile | String | Não | O perfil do codec de áudio. Valores válidos se o parâmetro Codec estiver definido como AAC: aac_low, aac_he, aac_he_v2, aac_ld e aac_eld. |
| Samplerate | String | Não | A taxa de amostragem. Valores válidos: 22050, 32000, 44100, 48000 e 96000. Valor padrão: 44100. Unidade: Hz. Se o formato do contêiner de vídeo for FLV e o codec de áudio for MP3, a taxa de amostragem não pode ser 32000, 48000 ou 96000. Se o codec de áudio for MP3, a taxa de amostragem não pode ser 96000. |
| Bitrate | String | Não | O bitrate de áudio do arquivo de saída. Valores válidos: 8 a 1000. Valor padrão: 128. Unidade: Kbit/s. |
| Channels | String | Não | O número de canais de som. Valor padr |
Elementos de resposta
|
Elemento |
Tipo |
Descrição |
Exemplo |
|
object |
Os parâmetros de resposta. |
||
| RequestId |
string |
O ID da solicitação. |
FA258E67-09B8-4EAA-8F33-BA567834A2C3 |
| Template |
object |
Os detalhes do modelo de transcodificação. |
|
| Video |
object |
As configurações do codec de vídeo. |
|
| Bufsize |
string |
The size of the buffer.
|
6000 |
| LongShortMode |
string |
Indicates whether the auto-rotate screen feature is enabled. Default value: false. Valid values:
Nota
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. |
false |
| Degrain |
string |
The level of quality control on the video. |
10 |
| BitrateBnd |
object |
The bitrate range of the video. |
|
| Max |
string |
The maximum bitrate. |
1500 |
| Min |
string |
The minimum bitrate. |
800 |
| PixFmt |
string |
The pixel format. Standard pixel formats such as yuv420p and yuvj420p are supported. The default pixel format can be yuv420p or the pixel format of the input video. |
yuv420p |
| Pad |
string |
The black borders to be added to the video. The value is in the width:height:left:top format. |
1280:800:0:140 |
| Codec |
string |
The video codec. Valid values: H.264, H.265, GIF, and WebP. Default value: H.264. |
H.264 |
| Height |
string |
The height of the video.
|
800 |
| Qscale |
string |
The level of the independent denoising algorithm. |
1 |
| Crop |
string |
The method of video cropping. Valid values:
|
border |
| Bitrate |
string |
The bitrate of the output video. Unit: Kbit/s. |
500 |
| Maxrate |
string |
The maximum bitrate of the video. Unit: Kbit/s. |
500 |
| MaxFps |
string |
The maximum frame rate. |
60 |
| Profile |
string |
The codec profile.
If multiple definitions are available, we recommend that you set this parameter to baseline for the lowest definition to ensure normal playback on low-end devices. Set this parameter to main or high for other definitions. Nota
This parameter is valid only if the Codec parameter is set to H.264. |
high |
| Crf |
string |
The constant rate factor. Default value if the video codec is set to H.264: 23. Default value if the video codec is set to H.265: 26. Nota
If this parameter is specified, the setting of the Bitrate parameter becomes invalid. |
15 |
| Remove |
string |
Indicates whether the video stream is deleted.
|
false |
| Gop |
string |
The GOP size. The GOP size can be the maximum interval of keyframes or the maximum number of frames in a frame group. If the maximum interval is specified, the value contains the unit (s). If the maximum number of frames is specified, the value does not contain a unit. Default value: 10s. |
10s |
| Width |
string |
The width of the video.
|
256 |
| Fps |
string |
The frame rate. Default value: the frame rate of the input file. The value is 60 if the frame rate of the input file exceeds 60. Unit: frames per second. |
25 |
| Preset |
string |
The preset video algorithm. Default value: medium. Valid values:
Nota
This parameter is valid only if the Codec parameter is set to H.264. |
fast |
| ScanMode |
string |
The scan mode. Valid values:
|
interlaced |
| ResoPriority |
string |
The policy of resolution adjustment. |
0 |
| Hdr2sdr |
string |
Indicates whether the HDR2SDR conversion feature is enabled. If this feature is enabled, high dynamic range (HDR) videos are transcoded to standard dynamic range (SDR) videos. |
true |
| NarrowBand |
object |
The Narrowband HD settings. |
|
| Version |
string |
The Narrowband HD version. Only 1.0 may be returned. |
1.0 |
| Abrmax |
number |
The upper limit of the dynamic bitrate. If this parameter is set, the average bitrate is in the range of (0, 1000000]. |
3000 |
| MaxAbrRatio |
number |
The maximum ratio of the upper limit of dynamic bitrate. If this parameter is set, the value of Abrmax does not exceed x times of the source video bitrate. Valid values: (0,1.0]. |
1.0 |
| TransConfig |
object |
As configurações gerais de transcodificação. |
|
| IsCheckAudioBitrate |
string |
Indicates whether the audio bitrate is checked. If this feature is enabled and the system detects that the audio bitrate of the output file is greater than that of the input file, the audio bitrate of the input file is retained after transcoding.
|
true |
| TransMode |
string |
The transcoding mode. Valid values:
|
onepass |
| IsCheckReso |
string |
Indicates whether the resolution is checked.
Nota
If this feature is enabled and the system detects that the resolution of the output file is higher than that of the input file based on the width or height, the resolution of the input file is retained after transcoding. |
true |
| IsCheckVideoBitrateFail |
string |
Indicates whether the video bitrate is checked. If this feature is enabled and the system detects that the video bitrate of the output file is higher than that of the input file, the input file is not transcoded. This parameter has a higher priority than the IsCheckVideoBitrate parameter.
|
true |
| AdjDarMethod |
string |
The method of resolution adjustment. Default value: none. Valid values:
|
rescale |
| IsCheckVideoBitrate |
string |
Indicates whether the video bitrate is checked.
Nota
If this feature is enabled 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. |
true |
| IsCheckResoFail |
string |
Indicates whether the resolution is checked.
Nota
If this feature is enabled and the system detects that the resolution of the output file is higher than that of the input file based on the width or height, an error that indicates a transcoding failure is returned. |
true |
| IsCheckAudioBitrateFail |
string |
Indicates whether the audio bitrate is checked. If this feature is enabled and the system detects that the audio bitrate of the output file is higher than that of the input file, the input file is not transcoded. This parameter has a higher priority than the IsCheckAudioBitrate parameter. Valid values:
|
true |
| State |
string |
O status do modelo. Valores válidos:
|
Normal |
| MuxConfig |
object |
As configurações de transmuxing. |
|
| Webp |
object |
The transmuxing settings for WebP. |
|
| Loop |
string |
The loop count. |
0 |
| Gif |
object |
The transmuxing settings for GIF. |
|
| FinalDelay |
string |
The duration for which the final frame is paused. Unit: centiseconds. |
0 |
| DitherMode |
string |
The color dithering algorithm of the palette. Valid values: sierra and bayer. |
sierra |
| Loop |
string |
The loop count. |
0 |
| IsCustomPalette |
string |
Indicates whether the custom palette is used. |
false |
| Segment |
object |
The segment settings. |
|
| Duration |
string |
The length of the segment. Unit: seconds. |
10 |
| Name |
string |
O nome do modelo de transcodificação. |
mps-example |
| Audio |
object |
As configurações do codec de áudio. |
|
| Profile |
string |
The codec profile of the audio. Valid values if the Codec parameter is set to AAC:
|
aac_low |
| Remove |
string |
Indicates whether the audio stream is deleted.
|
true |
| Codec |
string |
The audio codec format. Default value: aac. Valid values:
|
aac |
| Samplerate |
string |
The sampling rate.
|
44100 |
| Qscale |
string |
The level of the independent denoising algorithm. |
5 |
| Channels |
string |
The number of sound channels. Default value: 2. |
2 |
| Volume |
object |
The volume control configurations |
|
| Method |
string |
The volume adjustment method. Valid values:
|
auto |
| Level |
string |
The volume adjustment range.
|
-20 |
| IntegratedLoudnessTarget |
string |
The output volume. This parameter takes effect only when the value of Method is dynamic. Unit: dB. Valid values: [-70,-5]. Default value: -6. |
-6 |
| TruePeak |
string |
The peak volume. This parameter takes effect only when the value of Method is dynamic. Unit: dB. Valid values: [-9,0]. Default value: -1. |
0 |
| LoudnessRangeTarget |
string |
The range of the volume relative to the output volume. This parameter takes effect only when the value of Method is dynamic. Unit: dB. Valid values: [1,20]. Default value: 8. |
8 |
| PeakLevel |
string |
The volume adjustment coefficient. This parameter takes effect only when the value of Method is adaptive. Valid values: [0,1]. Default value: 0.9. |
0.9 |
| Bitrate |
string |
The audio bitrate of the output file.
|
500 |
| Id |
string |
O ID do modelo de transcodificação. Recomendamos que você mantenha este ID para chamadas de operação subsequentes. |
16f01ad6175e4230ac42bb5182cd**** |
| Container |
object |
As configurações do formato do contêiner. |
|
| Format |
string |
The container format. |
mp4 |
Exemplos
Resposta de sucesso
JSON formato
{
"RequestId": "FA258E67-09B8-4EAA-8F33-BA567834A2C3",
"Template": {
"Video": {
"Bufsize": "6000",
"LongShortMode": "false",
"Degrain": "10",
"BitrateBnd": {
"Max": "1500",
"Min": "800"
},
"PixFmt": "yuv420p",
"Pad": "1280:800:0:140",
"Codec": "H.264",
"Height": "800",
"Qscale": "1",
"Crop": "border",
"Bitrate": "500",
"Maxrate": "500",
"MaxFps": "60",
"Profile": "high",
"Crf": "15",
"Remove": "false",
"Gop": "10s",
"Width": "256",
"Fps": "25",
"Preset": "fast",
"ScanMode": "interlaced",
"ResoPriority": "0",
"Hdr2sdr": "true",
"NarrowBand": {
"Version": "1.0",
"Abrmax": 3000,
"MaxAbrRatio": 1
}
},
"TransConfig": {
"IsCheckAudioBitrate": "true",
"TransMode": "onepass",
"IsCheckReso": "true",
"IsCheckVideoBitrateFail": "true",
"AdjDarMethod": "rescale",
"IsCheckVideoBitrate": "true",
"IsCheckResoFail": "true",
"IsCheckAudioBitrateFail": "true"
},
"State": "Normal",
"MuxConfig": {
"Webp": {
"Loop": "0"
},
"Gif": {
"FinalDelay": "0",
"DitherMode": "sierra",
"Loop": "0",
"IsCustomPalette": "false"
},
"Segment": {
"Duration": "10"
}
},
"Name": "mps-example",
"Audio": {
"Profile": "aac_low",
"Remove": "true",
"Codec": "aac",
"Samplerate": "44100",
"Qscale": "5",
"Channels": "2",
"Volume": {
"Method": "auto",
"Level": "-20",
"IntegratedLoudnessTarget": "-6",
"TruePeak": "0",
"LoudnessRangeTarget": "8",
"PeakLevel": "0.9"
},
"Bitrate": "500"
},
"Id": "16f01ad6175e4230ac42bb5182cd****",
"Container": {
"Format": "mp4"
}
}
}
Códigos de erro
Consulte Códigos de Erro para uma lista completa.
Notas de versão
Consulte Notas de Versão para uma lista completa.