全部产品
云市场

转码模板

更新时间:2019-03-06 16:25:56

初始化客户端

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

添加转码模板组

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

  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include <jsoncpp/json/json.h>
  5. #include "vod_sdk/openApiUtil.h"
  6. /**
  7. * 构建需要添加的转码模板配置数据
  8. */
  9. Json::Value buildTranscodeTemplateList() {
  10. Json::Value transcodeTemplateList;
  11. Json::Value transcodeTemplate;
  12. //视频流转码配置
  13. Json::Value video;
  14. video["Width"] = 640;
  15. video["Bitrate"] = 400;
  16. video["Fps"] = 25;
  17. video["Remove"] = false;
  18. video["Codec"] = "H.264";
  19. video["Gop"] = "250";
  20. transcodeTemplate["Video"] = video;
  21. //音频流转码配置
  22. Json::Value audio;
  23. audio["Codec"] = "AAC";
  24. audio["Bitrate"] = "64";
  25. audio["Channels"] = "2";
  26. audio["Samplerate"] = "32000";
  27. transcodeTemplate["Audio"] = audio;
  28. //封装容器
  29. Json::Value container;
  30. container["Format"] = "mp4";
  31. transcodeTemplate["Container"] = container;
  32. //条件转码配置
  33. Json::Value transconfig;
  34. transconfig["IsCheckReso"] = false;
  35. transconfig["IsCheckResoFail"] = false;
  36. transconfig["IsCheckVideoBitrate"] = false;
  37. transconfig["IsCheckVideoBitrateFail"] = false;
  38. transconfig["IsCheckAudioBitrate"] = false;
  39. transconfig["IsCheckAudioBitrateFail"] = false;
  40. transcodeTemplate["TransConfig"] = transconfig;
  41. //加密配置(只支持m3u8)
  42. //Json::Value encryptSetting;
  43. //encryptSetting["EncryptType"] = "Private";
  44. //transcodeTemplate["EncryptSetting"] = encryptSetting;
  45. //清晰度
  46. transcodeTemplate["Definition"] = "LD";
  47. //模板名称
  48. transcodeTemplate["TemplateName"] = "testtemplate";
  49. //水印ID(多水印关联)
  50. Json::Value watermarkIdList;
  51. watermarkIdList.append("263261bdc1ff65782f8995c6dd22a16a");
  52. //USER_DEFAULT_WATERMARK 代表默认水印ID
  53. watermarkIdList.append("USER_DEFAULT_WATERMARK");
  54. transcodeTemplate["WatermarkIds"] = watermarkIdList;
  55. transcodeTemplateList.append(transcodeTemplate);
  56. return transcodeTemplateList;
  57. }
  58. /**
  59. * 添加转码模板组配置
  60. */
  61. VodApiResponse addTranscodeTemplateGroup(VodCredential authInfo) {
  62. string apiName = "AddTranscodeTemplateGroup";
  63. map<string, string> args;
  64. args["Name"] = "grouptest";
  65. args["TranscodeTemplateList"] = buildTranscodeTemplateList().toStyledString();
  66. return getAcsResponse(authInfo, apiName, args);
  67. }
  68. // 请求示例
  69. void main() {
  70. VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  71. VodApiResponse response = addTranscodeTemplateGroup(authInfo);
  72. printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
  73. }

修改转码模板组

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

  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include <jsoncpp/json/json.h>
  5. #include "vod_sdk/openApiUtil.h"
  6. /**
  7. * 构建需要添加的转码模板配置数据
  8. */
  9. Json::Value buildTranscodeTemplateList() {
  10. Json::Value transcodeTemplateList;
  11. Json::Value transcodeTemplate;
  12. //视频流转码配置
  13. Json::Value video;
  14. video["Width"] = 640;
  15. video["Bitrate"] = 400;
  16. video["Fps"] = 25;
  17. video["Remove"] = false;
  18. video["Codec"] = "H.264";
  19. video["Gop"] = "250";
  20. transcodeTemplate["Video"] = video;
  21. //音频流转码配置
  22. Json::Value audio;
  23. audio["Codec"] = "AAC";
  24. audio["Bitrate"] = "64";
  25. audio["Channels"] = "2";
  26. audio["Samplerate"] = "32000";
  27. transcodeTemplate["Audio"] = audio;
  28. //封装容器
  29. Json::Value container;
  30. container["Format"] = "mp4";
  31. transcodeTemplate["Container"] = container;
  32. //条件转码配置
  33. Json::Value transconfig;
  34. transconfig["IsCheckReso"] = false;
  35. transconfig["IsCheckResoFail"] = false;
  36. transconfig["IsCheckVideoBitrate"] = false;
  37. transconfig["IsCheckVideoBitrateFail"] = false;
  38. transconfig["IsCheckAudioBitrate"] = false;
  39. transconfig["IsCheckAudioBitrateFail"] = false;
  40. transcodeTemplate["TransConfig"] = transconfig;
  41. //加密配置(只支持m3u8)
  42. //Json::Value encryptSetting;
  43. //encryptSetting["EncryptType"] = "Private";
  44. //transcodeTemplate["EncryptSetting"] = encryptSetting;
  45. //模板名称
  46. transcodeTemplate["TemplateName"] = "testtemplate";
  47. //需要修改的转码模板ID
  48. transcodeTemplate["TranscodeTemplateId"] = "85c2b18ac08fda33e8f6d9c56242f";
  49. //水印ID(多水印关联)
  50. Json::Value watermarkIdList;
  51. watermarkIdList.append("263261bdc1ff65782f8995c6dd22a16a");
  52. //USER_DEFAULT_WATERMARK 代表默认水印ID
  53. watermarkIdList.append("USER_DEFAULT_WATERMARK");
  54. transcodeTemplate["WatermarkIds"] = watermarkIdList;
  55. transcodeTemplateList.append(transcodeTemplate);
  56. return transcodeTemplateList;
  57. }
  58. /**
  59. * 修改转码模板组配置
  60. */
  61. VodApiResponse updateTranscodeTemplateGroup(VodCredential authInfo) {
  62. string apiName = "UpdateTranscodeTemplateGroup";
  63. map<string, string> args;
  64. //转码模板组ID
  65. args["TranscodeTemplateGroupId"] = "4c71a339fecec0152b4fa6f4527xxx";
  66. args["Name"] = "grouptest";
  67. args["TranscodeTemplateList"] = buildTranscodeTemplateList().toStyledString();
  68. return getAcsResponse(authInfo, apiName, args);
  69. }
  70. // 请求示例
  71. void main() {
  72. VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  73. VodApiResponse response = updateTranscodeTemplateGroup(authInfo);
  74. printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
  75. }

查询转码模板组列表

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

  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include <jsoncpp/json/json.h>
  5. #include "vod_sdk/openApiUtil.h"
  6. /**
  7. * 查询转码模板组列表
  8. */
  9. VodApiResponse listTranscodeTemplateGroup(VodCredential authInfo) {
  10. string apiName = "ListTranscodeTemplateGroup";
  11. map<string, string> args;
  12. return getAcsResponse(authInfo, apiName, args);
  13. }
  14. // 请求示例
  15. void main() {
  16. VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  17. VodApiResponse response = listTranscodeTemplateGroup(authInfo);
  18. printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
  19. }

查询单个转码模板组

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

  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include <jsoncpp/json/json.h>
  5. #include "vod_sdk/openApiUtil.h"
  6. /**
  7. * 查询单个转码模板组配置
  8. */
  9. VodApiResponse getTranscodeTemplateGroup(VodCredential authInfo) {
  10. string apiName = "GetTranscodeTemplateGroup";
  11. map<string, string> args;
  12. args["TranscodeTemplateGroupId"] = "a0fa0fda545e50e7a3eb75491f9f4";
  13. return getAcsResponse(authInfo, apiName, args);
  14. }
  15. // 请求示例
  16. void main() {
  17. VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  18. VodApiResponse response = getTranscodeTemplateGroup(authInfo);
  19. printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
  20. }

设置默认转码模板组

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

  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include <jsoncpp/json/json.h>
  5. #include "vod_sdk/openApiUtil.h"
  6. /**
  7. * 设置默认转码模板组
  8. */
  9. VodApiResponse setDefaultTranscodeTemplateGroup(VodCredential authInfo) {
  10. string apiName = "SetDefaultTranscodeTemplateGroup";
  11. map<string, string> args;
  12. args["TranscodeTemplateGroupId"] = "a0fa0fda545e50e7a3eb75491f9f4";
  13. return getAcsResponse(authInfo, apiName, args);
  14. }
  15. // 请求示例
  16. void main() {
  17. VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  18. VodApiResponse response = setDefaultTranscodeTemplateGroup(authInfo);
  19. printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
  20. }

删除转码模板组

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

  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include <jsoncpp/json/json.h>
  5. #include "vod_sdk/openApiUtil.h"
  6. /**
  7. * 删除转码模板组配置
  8. */
  9. VodApiResponse deleteTranscodeTemplateGroup(VodCredential authInfo) {
  10. string apiName = "DeleteTranscodeTemplateGroup";
  11. map<string, string> args;
  12. args["TranscodeTemplateGroupId"] = "a0fa0fda545e50e7a3eb75491f9f4";
  13. return getAcsResponse(authInfo, apiName, args);
  14. }
  15. // 请求示例
  16. void main() {
  17. VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  18. VodApiResponse response = deleteTranscodeTemplateGroup(authInfo);
  19. printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
  20. }