全部产品
云市场

转码模板

更新时间:2019-03-06 16:26:12

初始化客户端

使用前请先初始化客户端,参考 initVodClient 接口。

添加转码模板组

接口参数和返回字段请参考 AddTranscodeTemplateGroup

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. var transcodeTemplateList = [
  4. {
  5. //视频流转码配置
  6. Video: {
  7. Width: 640,
  8. Bitrate: 400,
  9. Fps: 25,
  10. Remove: false,
  11. Codec: 'H.264',
  12. Gop: '250'
  13. },
  14. //音频流转码配置
  15. Audio: {
  16. Codec: 'AAC',
  17. Bitrate: '64',
  18. Channels: '2',
  19. Samplerate: '32000'
  20. },
  21. //封装容器
  22. Container: {
  23. Format: 'mp4'
  24. },
  25. //条件转码配置
  26. TransConfig: {
  27. IsCheckReso: false,
  28. IsCheckResoFail: false,
  29. IsCheckVideoBitrate: false,
  30. IsCheckVideoBitrateFail: false,
  31. IsCheckAudioBitrate: false,
  32. IsCheckAudioBitrateFail: false
  33. },
  34. // // 加密配置(只支持m3u8)
  35. // EncryptSetting: {
  36. // EncryptType: 'Private'
  37. // },
  38. //清晰度
  39. Definition: 'LD',
  40. //模板名称
  41. TemplateName: 'testtemplate',
  42. //水印ID(多水印关联)
  43. WatermarkIds: ['USER_DEFAULT_WATERMARK','xxxxxxbdc1ff65782f8995c6ddxxxxxx']
  44. }
  45. ];
  46. client.request("AddTranscodeTemplateGroup", {
  47. // 转码模板组名称
  48. Name: 'grouptest',
  49. // 转码模板配置数据
  50. TranscodeTemplateList: JSON.stringify(transcodeTemplateList)
  51. }, {}).then(function (response) {
  52. console.log('TranscodeTemplateGroupId = ' + response.TranscodeTemplateGroupId);
  53. console.log('RequestId = ' + response.RequestId);
  54. }).catch(function (response) {
  55. console.log('ErrorCode = ' + response.data.Code);
  56. console.log('ErrorMessage = ' + response.data.Message);
  57. console.log('RequestId = ' + response.data.RequestId);
  58. });

修改转码模板组

接口参数和返回字段请参考 UpdateTranscodeTemplateGroup

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. var transcodeTemplateList = [
  4. {
  5. // 转码模板ID
  6. TranscodeTemplateId: 'xxxxxx4423bca267f931d3b256xxxxxx',
  7. // 视频流转码配置
  8. Video: {
  9. Width: 640,
  10. Bitrate: 500,
  11. Fps: 25,
  12. Remove: false,
  13. Codec: 'H.264',
  14. Gop: '250'
  15. },
  16. // 音频流转码配置
  17. Audio: {
  18. Codec: 'AAC',
  19. Bitrate: '64',
  20. Channels: '2',
  21. Samplerate: '32000'
  22. },
  23. // 封装容器
  24. Container: {
  25. Format: 'mp4'
  26. },
  27. // 条件转码配置
  28. TransConfig: {
  29. IsCheckReso: false,
  30. IsCheckResoFail: false,
  31. IsCheckVideoBitrate: false,
  32. IsCheckVideoBitrateFail: false,
  33. IsCheckAudioBitrate: false,
  34. IsCheckAudioBitrateFail: false
  35. },
  36. // // 加密配置(只支持m3u8)
  37. // EncryptSetting: {
  38. // EncryptType: 'Private'
  39. // },
  40. // 清晰度
  41. Definition: 'LD',
  42. // 模板名称
  43. TemplateName: 'testtemplate',
  44. // 水印ID(多水印关联)
  45. WatermarkIds: ['USER_DEFAULT_WATERMARK','xxxxxxbdc1ff65782f8995c6ddxxxxxx']
  46. }
  47. ];
  48. client.request("UpdateTranscodeTemplateGroup", {
  49. TranscodeTemplateGroupId: 'xxxxxx42788dfd94e27d7358b2xxxxxx',
  50. TranscodeTemplateList: JSON.stringify(transcodeTemplateList)
  51. }, {}).then(function (response) {
  52. console.log('TranscodeTemplateGroupId = ' + response.TranscodeTemplateGroupId);
  53. console.log('RequestId = ' + response.RequestId);
  54. }).catch(function (response) {
  55. console.log('ErrorCode = ' + response.data.Code);
  56. console.log('ErrorMessage = ' + response.data.Message);
  57. console.log('RequestId = ' + response.data.RequestId);
  58. });

查询转码模板组列表

接口参数和返回字段请参考 ListTranscodeTemplateGroup

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. client.request("ListTranscodeTemplateGroup", {}, {}).then(function (response) {
  4. if (response.TranscodeTemplateGroupList && response.TranscodeTemplateGroupList.length > 0){
  5. for (var i=0; i<response.TranscodeTemplateGroupList.length; i++){
  6. var transcodeTemplateGroup = response.TranscodeTemplateGroupList[i];
  7. console.log('The ' + i + ' TranscodeTemplateGroup.');
  8. //转码模板组ID
  9. console.log('TranscodeTemplateGroupId = ' + transcodeTemplateGroup.TranscodeTemplateGroupId);
  10. //转码模板组名称
  11. console.log('Name = ' + transcodeTemplateGroup.Name);
  12. //转码模板组创建时间
  13. console.log('CreationTime = ' + transcodeTemplateGroup.CreationTime);
  14. //转码模板组最近修改时间
  15. console.log('ModifyTime = ' + transcodeTemplateGroup.ModifyTime);
  16. //是否是默认转码模板组
  17. console.log('IsDefault = ' + transcodeTemplateGroup.IsDefault);
  18. }
  19. }
  20. console.log('RequestId = ' + response.RequestId);
  21. }).catch(function (response) {
  22. console.log('ErrorCode = ' + response.data.Code);
  23. console.log('ErrorMessage = ' + response.data.Message);
  24. console.log('RequestId = ' + response.data.RequestId);
  25. });

查询单个转码模板组

接口参数和返回字段请参考 GetTranscodeTemplateGroup

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. client.request("GetTranscodeTemplateGroup", {
  4. TranscodeTemplateGroupId: 'xxxxxx42788dfd94e27d7358b2xxxxxx'
  5. }, {}).then(function (response) {
  6. console.log(response);
  7. if (response.TranscodeTemplateGroup){
  8. // 转码模板组ID
  9. console.log('TranscodeTemplateGroupId = ' + response.TranscodeTemplateGroup.TranscodeTemplateGroupId);
  10. // 转码模板组名称
  11. console.log('Name = ' + response.TranscodeTemplateGroup.Name);
  12. // 转码模板组创建时间
  13. console.log('CreationTime = ' + response.TranscodeTemplateGroup.CreationTime);
  14. // 转码模板组最近修改时间
  15. console.log('ModifyTime = ' + response.TranscodeTemplateGroup.ModifyTime);
  16. // 转码模板信息
  17. if (response.TranscodeTemplateGroup.TranscodeTemplateList && response.TranscodeTemplateGroup.TranscodeTemplateList.length > 0){
  18. for (var i=0; i<response.TranscodeTemplateGroup.TranscodeTemplateList.length; i++){
  19. var transcodeTemplate = response.TranscodeTemplateGroup.TranscodeTemplateList[i];
  20. console.log("The " + i + " TranscodeTemplate.");
  21. // 转码模板ID
  22. console.log('TranscodeTemplateId = ' + transcodeTemplate.TranscodeTemplateId);
  23. // 转码模板名称
  24. console.log('TemplateName = ' + transcodeTemplate.TemplateName);
  25. // 转码模板清晰度标记
  26. console.log('Definition = ' + transcodeTemplate.Definition);
  27. // 转码模板封装格式配置
  28. console.log('Container = ');
  29. console.log(transcodeTemplate.Container);
  30. // 转码模板视频转码配置
  31. console.log('Video = ');
  32. console.log(transcodeTemplate.Video);
  33. // 转码模板音频转码配置
  34. console.log('Audio = ');
  35. console.log(transcodeTemplate.Audio);
  36. // 转码模板条件转码配置
  37. console.log('TransConfig = ');
  38. console.log(transcodeTemplate.TransConfig);
  39. // 转码需要压制的水印对应ID
  40. console.log('WatermarkIds = ');
  41. console.log(transcodeTemplate.WatermarkIds);
  42. }
  43. }
  44. }
  45. console.log('RequestId = ' + response.RequestId);
  46. }).catch(function (response) {
  47. console.log('ErrorCode = ' + response.data.Code);
  48. console.log('ErrorMessage = ' + response.data.Message);
  49. console.log('RequestId = ' + response.data.RequestId);
  50. });

设置默认转码模板组

接口参数和返回字段请参考 SetDefaultTranscodeTemplateGroup

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. client.request("SetDefaultTranscodeTemplateGroup", {
  4. // 转码模板组ID
  5. TranscodeTemplateGroupId: 'xxxxxx42788dfd94e27d7358b2xxxxxx'
  6. }, {}).then(function (response) {
  7. console.log('RequestId = ' + response.RequestId);
  8. }).catch(function (response) {
  9. console.log('ErrorCode = ' + response.data.Code);
  10. console.log('ErrorMessage = ' + response.data.Message);
  11. console.log('RequestId = ' + response.data.RequestId);
  12. });

删除转码模板组

接口参数和返回字段请参考 DeleteTranscodeTemplateGroup

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. client.request("DeleteTranscodeTemplateGroup", {
  4. TranscodeTemplateGroupId: 'xxxxxx42788dfd94e27d7358b2xxxxxx'
  5. }, {}).then(function (response) {
  6. console.log(response);
  7. console.log('RequestId = ' + response.RequestId);
  8. }).catch(function (response) {
  9. console.log('ErrorCode = ' + response.data.Code);
  10. console.log('ErrorMessage = ' + response.data.Message);
  11. console.log('RequestId = ' + response.data.RequestId);
  12. });