全部产品
云市场

转码模板

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

初始化客户端

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

添加转码模板组

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

  1. /**
  2. * 构建转码模板配置数据
  3. * @return
  4. */
  5. function buildTranscodeTemplateList() {
  6. $transcodeTemplateList = array();
  7. $transcodeTemplate = array();
  8. //视频流转码配置
  9. $video = array();
  10. $video["Width"] = 640;
  11. $video["Bitrate"] = 400;
  12. $video["Fps"] = 25;
  13. $video["Remove"] = false;
  14. $video["Codec"] = "H.264";
  15. $video["Gop"] = 250;
  16. $transcodeTemplate["Video"] = $video;
  17. //音频流转码配置
  18. $audio = array();
  19. $audio["Codec"] = "AAC";
  20. $audio["Bitrate"] = 64;
  21. $audio["Channels"] = 2;
  22. $audio["Samplerate"] = 32000;
  23. $transcodeTemplate["Audio"] = $audio;
  24. //封装容器
  25. $container = array();
  26. $container["Format"] = "mp4";
  27. $transcodeTemplate["Container"] = $container;
  28. //条件转码配置
  29. $transconfig = array();
  30. $transconfig["IsCheckReso"] = false;
  31. $transconfig["IsCheckResoFail"] = false;
  32. $transconfig["IsCheckVideoBitrate"] = false;
  33. $transconfig["IsCheckVideoBitrateFail"] = false;
  34. $transconfig["IsCheckAudioBitrate"] = false;
  35. $transconfig["IsCheckAudioBitrateFail"] = false;
  36. $transcodeTemplate["TransConfig"] = $transconfig;
  37. //加密配置(只支持m3u8)
  38. //$encryptSetting= array();
  39. //$encryptSetting["EncryptType"] = "Private";
  40. //$transcodeTemplate["EncryptSetting"] = $encryptSetting;
  41. //清晰度
  42. $transcodeTemplate["Definition"] = "LD";
  43. //模板名称
  44. $transcodeTemplate["TemplateName"] = "testtemplate";
  45. //水印ID(多水印关联)
  46. $watermarkIdList= array();
  47. $watermarkIdList[] = "263261bdc1ff65782f8995c6ddxxxxxx";
  48. //USER_DEFAULT_WATERMARK 代表默认水印ID
  49. $watermarkIdList[] = "USER_DEFAULT_WATERMARK";
  50. $transcodeTemplate["WatermarkIds"] = $watermarkIdList;
  51. $transcodeTemplateList[] = $transcodeTemplate;
  52. return json_encode($transcodeTemplateList);
  53. }
  54. /**
  55. * 添加转码模板组配置
  56. */
  57. function addTranscodeTemplateGroup($client) {
  58. $request = new vod\AddTranscodeTemplateGroupRequest();
  59. // 转码模板组名称
  60. $request->setName("grouptest");
  61. // 转码模板组信息
  62. $request->setTranscodeTemplateList(buildTranscodeTemplateList());
  63. return $client->getAcsResponse($request);
  64. }
  65. /**
  66. * 以下为调用示例
  67. */
  68. try {
  69. $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');
  70. $result = addTranscodeTemplateGroup($client);
  71. var_dump($result);
  72. } catch (Exception $e) {
  73. print $e->getMessage()."\n";
  74. }

修改转码模板组

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

  1. /**
  2. * 构建转码模板配置数据
  3. * @return
  4. */
  5. function buildTranscodeTemplateList() {
  6. $transcodeTemplateList = array();
  7. $transcodeTemplate = array();
  8. //视频流转码配置
  9. $video = array();
  10. $video["Width"] = 960;
  11. $video["Bitrate"] = 900;
  12. $video["Fps"] = 25;
  13. $video["Remove"] = false;
  14. $video["Codec"] = "H.264";
  15. $video["Gop"] = 250;
  16. $transcodeTemplate["Video"] = $video;
  17. //音频流转码配置
  18. $audio = array();
  19. $audio["Codec"] = "AAC";
  20. $audio["Bitrate"] = 96;
  21. $audio["Channels"] = 2;
  22. $audio["Samplerate"] = 32000;
  23. $transcodeTemplate["Audio"] = $audio;
  24. //封装容器
  25. $container = array();
  26. $container["Format"] = "mp4";
  27. $transcodeTemplate["Container"] = $container;
  28. //条件转码配置
  29. $transconfig = array();
  30. $transconfig["IsCheckReso"] = false;
  31. $transconfig["IsCheckResoFail"] = false;
  32. $transconfig["IsCheckVideoBitrate"] = false;
  33. $transconfig["IsCheckVideoBitrateFail"] = false;
  34. $transconfig["IsCheckAudioBitrate"] = false;
  35. $transconfig["IsCheckAudioBitrateFail"] = false;
  36. $transcodeTemplate["TransConfig"] = $transconfig;
  37. //加密配置(只支持m3u8)
  38. //$encryptSetting= array();
  39. //$encryptSetting["EncryptType"] = "Private";
  40. //$transcodeTemplate["EncryptSetting"] = $encryptSetting;
  41. //清晰度
  42. $transcodeTemplate["Definition"] = "SD";
  43. //模板名称
  44. $transcodeTemplate["TemplateName"] = "testtemplate";
  45. //模板ID
  46. $transcodeTemplate["TranscodeTemplateId"] = "214a67fab9fdf920f486faa77xxxxxx";
  47. //水印ID(多水印关联)
  48. $watermarkIdList= array();
  49. $watermarkIdList[] = "263261bdc1ff65782f8995c6ddxxxxxx";
  50. //USER_DEFAULT_WATERMARK 代表默认水印ID
  51. $watermarkIdList[] = "USER_DEFAULT_WATERMARK";
  52. $transcodeTemplate["WatermarkIds"] = $watermarkIdList;
  53. $transcodeTemplateList[] = $transcodeTemplate;
  54. return json_encode($transcodeTemplateList);
  55. }
  56. /**
  57. * 修改转码模板组配置
  58. */
  59. function updateTranscodeTemplateGroup($client) {
  60. $request = new vod\UpdateTranscodeTemplateGroupRequest();
  61. // 转码模板组名称
  62. $request->setName("grouptest1");
  63. // 转码模板组ID
  64. $request->setTranscodeTemplateGroupId("014a67fab9fdf920f486faa77xxxxxx");
  65. // 转码模板组信息
  66. $request->setTranscodeTemplateList(buildTranscodeTemplateList());
  67. return $client->getAcsResponse($request);
  68. }
  69. /**
  70. * 以下为调用示例
  71. */
  72. try {
  73. $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');
  74. $result = updateTranscodeTemplateGroup($client);
  75. var_dump($result);
  76. } catch (Exception $e) {
  77. print $e->getMessage()."\n";
  78. }

查询转码模板组列表

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

  1. /**
  2. * 查询转码模板组列表
  3. */
  4. function listTranscodeTemplateGroup($client) {
  5. $request = new vod\ListTranscodeTemplateGroupRequest();
  6. return $client->getAcsResponse($request);
  7. }
  8. /**
  9. * 以下为调用示例
  10. */
  11. try {
  12. $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');
  13. $result = listTranscodeTemplateGroup($client);
  14. var_dump($result);
  15. } catch (Exception $e) {
  16. print $e->getMessage()."\n";
  17. }

查询单个转码模板组

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

  1. /**
  2. * 查询单个转码模板组
  3. */
  4. function getTranscodeTemplateGroup($client) {
  5. $request = new vod\GetTranscodeTemplateGroupRequest();
  6. // 转码模板组ID
  7. $request->setTranscodeTemplateGroupId("014a67fab9fdf920f486faa77xxxxxx");
  8. return $client->getAcsResponse($request);
  9. }
  10. /**
  11. * 以下为调用示例
  12. */
  13. try {
  14. $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');
  15. $result = getTranscodeTemplateGroup($client);
  16. var_dump($result);
  17. } catch (Exception $e) {
  18. print $e->getMessage()."\n";
  19. }

设置默认转码模板组

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

  1. /**
  2. * 设置默认转码模板组
  3. */
  4. function setDefaultTranscodeTemplateGroup($client) {
  5. $request = new vod\SetDefaultTranscodeTemplateGroupRequest();
  6. // 转码模板组ID
  7. $request->setTranscodeTemplateGroupId("014a67fab9fdf920f486faa77xxxxxx");
  8. return $client->getAcsResponse($request);
  9. }
  10. /**
  11. * 以下为调用示例
  12. */
  13. try {
  14. $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');
  15. $result = setDefaultTranscodeTemplateGroup($client);
  16. var_dump($result);
  17. } catch (Exception $e) {
  18. print $e->getMessage()."\n";
  19. }

删除转码模板组

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

  1. /**
  2. * 删除转码模板组配置
  3. */
  4. function deleteTranscodeTemplateGroup($client) {
  5. $request = new vod\DeleteTranscodeTemplateGroupRequest();
  6. // 转码模板组ID
  7. $request->setTranscodeTemplateGroupId("014a67fab9fdf920f486faa773xxxxxx");
  8. return $client->getAcsResponse($request);
  9. }
  10. /**
  11. * 以下为调用示例
  12. */
  13. try {
  14. $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');
  15. $result = deleteTranscodeTemplateGroup($client);
  16. var_dump($result);
  17. } catch (Exception $e) {
  18. print $e->getMessage()."\n";
  19. }