edit-icon download-icon

AddTemplate

Last Updated: Feb 08, 2018

Description

The AddTemplate API creates a custom template, which includes the container information, and settings such as video and audio stream settings. If some information is not set in the template, bitstreams that are transcoded using the template do not contain such information.

Request parameters

Parameter Type Required or not Description
Action String Yes API of the action, system required parameter. Set this parameter to AddTemplate.
Name String Yes Template name, up to 128 bytes.
Container String No Container, which is a JSON object. For details, see “7. Container” in “Parameters” of “Appendix.” Example: {"Format":"mp4"}.
Video String No Video stream configuration, which is a JSON object. For details, see “8. Video” in “Parameters” of “Appendix.” Example:
{
"Codec":"H.264",
"Profile":"high",
"Bitrate":"500",
"Crf":"15",
"Width":"256",
"Height":"800",
"Fps":"25",
"Gop":"10"
}
If the Video parameter is not set, video streams are not output after transcoding. If you want to retain the video, the Video parameter must be set.
Audio String No Audio stream configuration, which is a JSON object. For details, see “10. Audio” in “Parameters” of “Appendix.” Example:
{
"Codec":"aac",
"Samplerate":"44100",
"Bitrate":"500",
"Channels":"2"
}
If the Audio parameter is not set, audio streams are not output after transcoding. If you want to retain the audio, the Audio parameter must be set.
TransConfig String No General transcoding configuration, which is a JSON object. For details, see “16. TransConfig” in “Parameters” of “Appendix.” Example:
{
"TransMode":"onepass"
}
MuxConfig String No Encapsulation configuration, which is a JSON object. For details, see “17. MuxConfig” in “Parameters” of “Appendix.” Example:
{
"Segment":{
"Duration":"12"
}
}

Return parameters

Name Type Description
Template AliyunTemplate Transcoding template

Example

Request example

  1. http://mts.cn-hangzhou.aliyuncs.com/?Container=%7B%22Format%22%3A%22mp4%22%7D&Video=%7B%22Codec%22%3A%20%22H.264%22%2C%22Profile%22%3A%20%22high%22%2C%20%22BitRate%22%3A%20%22500%EF%BC%8C%22CRF%22%3A%20%2215%22%2C%20%22Width%22%3A%20%22256%22%2C%22Height%22%3A%20%22800%22%2C%20%22FPS%22%3A%20%2225%22%2C%20%22GOP%22%3A%20%2210%22%20%7D&Audio=%7B%22Codec%22%3A%22aac%22%2C%22SampleRate%22%3A%2244100%22%2C%0A%22BitRate%22%3A%22500%22%2C%22Channels%22%3A%222%22%7D%0A&Action=AddTemplate&<Public parameter>

Return example

XML

  1. <AddTemplateResponse>
  2. <RequestId>017F1B2D-2B5B-4441-ABBA-E0DC08F5AFEC</RequestId>
  3. <Template>
  4. <Id>88c6ca184c0e47098a5b665e2a126799</Id>
  5. <Name>MTS-example</Name>
  6. <Container>
  7. <Format>mp4</Format>
  8. </Container>
  9. <Video>
  10. <Codec>H.264</Codec>
  11. <Profile>high</Profile>
  12. <Bitrate>Auto</Bitrate>
  13. <Crf>15</Crf>
  14. <Width>256</Width>
  15. <Height>800</Height>
  16. <Fps>25</Fps>
  17. <Gop>10</Gop>
  18. <Preset>lower</Preset>
  19. <ScanMode></ScanMode>
  20. <Bufsize>6000</Bufsize>
  21. <Maxrate></Maxrate>
  22. <BitrateBnd>
  23. <Max></Max>
  24. <Min></Min>
  25. </BitrateBnd>
  26. </Video>
  27. <Audio>
  28. <Codec>aac</Codec>
  29. <Samplerate>44100</Samplerate>
  30. <Bitrate>500</Bitrate>
  31. <Channels>2</Channels>
  32. </Audio>
  33. <TransConfig>
  34. <TransMode>onepass</TransMode>
  35. </TransConfig>
  36. <State>Normal</State>
  37. </Template>
  38. </AddTemplateResponse>

JSON

  1. {
  2. "RequestId":"3E767BAD-9F4C-4FC8-9FAE-E3F4A639066B",
  3. "Template": {
  4. "Id": "88c6ca184c0e47098a5b665e2a126799",
  5. "Name": "MTS-example",
  6. "Container": {
  7. "Format": "mp4"
  8. },
  9. "Video": {
  10. "Codec": "H.264",
  11. "Profile": "high",
  12. "Bitrate": "Auto",
  13. "Crf": "15",
  14. "Width": "256",
  15. "Height": "800",
  16. "Fps": "25",
  17. "Gop": "10",
  18. "Preset": "lower",
  19. "ScanMode": "",
  20. "Bufsize": "6000",
  21. "Maxrate": "500",
  22. "BitrateBnd":{
  23. "Max":"",
  24. "Min":""
  25. }
  26. },
  27. "Audio": {
  28. "Codec": "aac",
  29. "Samplerate": "44100",
  30. "Bitrate": "500",
  31. "Channels": "2"
  32. },
  33. "TransConfig":{
  34. "TransMode":"onepass"
  35. },
  36. "State": "Normal"
  37. }
  38. }
  39. }
Thank you! We've received your feedback.