全部产品
云市场

视频剪辑

更新时间:2018-12-28 14:22:41

初始化客户端

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

发起剪辑合成-通过时间线

绝大多数场景下,使用这种方式即可合成视频。接口参数和返回字段请参考 ProduceEditingProjectVideo

通过时间线实现剪辑合成的更多Timeline示例可参考:视频剪辑-使用示例

  1. function buildMediaMetadata() {
  2. $mediaMetadata = array();
  3. // Produce Media Title
  4. $mediaMetadata['Title'] = 'Title';
  5. // Produce Media Description
  6. $mediaMetadata['Description'] = 'Description';
  7. // Produce Media UserDefined Cover URL
  8. $mediaMetadata['CoverURL'] = 'http://test.testvod123.com/media/cover/mediaid.jpg';
  9. // Produce Media Category ID
  10. $mediaMetadata['CateId'] = null;
  11. // Produce Media Category Name
  12. $mediaMetadata['Tags'] = 'Tag1,Tag2,Test';
  13. return json_encode($mediaMetadata);
  14. }
  15. function buildProduceConfig() {
  16. $produceConfig = array();
  17. /*
  18. The produce process can generate media mezzanine file. You can use the mezzanine file to transcode other media files,just like the transcode process after file upload finished. This field describe the Transocde TemplateGroup ID after produce mezzanine finished.
  19. 1. Not required
  20. 2. Use default transcode template group id when empty
  21. */
  22. $produceConfig['TemplateGroupId'] = null;
  23. return json_encode($produceConfig);
  24. }
  25. function buildTimeline() {
  26. $timeline = array();
  27. // Video Track
  28. $videoTracks = array();
  29. $videoTrack = array();
  30. // Video Track Clicps
  31. $videoTrackClips = array();
  32. $videoTrackClip1 = array();
  33. $videoTrackClip1['MediaId'] = '6893fca9814640c8821efa523xxxxxx';
  34. $videoTrackClips[] = $videoTrackClip1;
  35. $videoTrackClip2 = array();
  36. $videoTrackClip2['MediaId'] = '070bbc13d8294e35b36c3e7abxxxxxx';
  37. $videoTrackClips[] = $videoTrackClip2;
  38. $videoTrack['VideoTrackClips'] = $videoTrackClips;
  39. $videoTracks[] = $videoTrack;
  40. $timeline['VideoTracks'] = $videoTracks;
  41. return json_encode($timeline);
  42. }
  43. try {
  44. $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');
  45. $request = new vod\ProduceEditingProjectVideoRequest();
  46. // Set Produce Media Metadata
  47. $request->setMediaMetadata(buildMediaMetadata());
  48. // Set Produce Configuration
  49. $request->setProduceConfig(buildProduceConfig());
  50. // Build Editing Project Timeline
  51. $request->setTimeline(buildTimeline());
  52. // Get result
  53. $result = $client->getAcsResponse($request);
  54. var_dump($result);
  55. } catch (Exception $e) {
  56. print $e->getMessage()."\n";
  57. }

发起剪辑合成-通过云剪辑工程

对云剪辑工程有较高管理需求的场景下,可以使用这种方式合成视频。接口参数和返回字段请参考 ProduceEditingProjectVideo

  1. function buildMediaMetadata() {
  2. $mediaMetadata = array();
  3. // Produce Media Title
  4. $mediaMetadata['Title'] = 'Title';
  5. // Produce Media Description
  6. $mediaMetadata['Description'] = 'Description';
  7. // Produce Media UserDefined Cover URL
  8. $mediaMetadata['CoverURL'] = 'http://test.testvod123.com/media/cover/mediaid.jpg';
  9. // Produce Media Category ID
  10. $mediaMetadata['CateId'] = null;
  11. // Produce Media Category Name
  12. $mediaMetadata['Tags'] = 'Tag1,Tag2,Test';
  13. return json_encode($mediaMetadata);
  14. }
  15. function buildProduceConfig() {
  16. $produceConfig = array();
  17. /*
  18. The produce process can generate media mezzanine file. You can use the mezzanine file to transcode other media files,just like the transcode process after file upload finished. This field describe the Transocde TemplateGroup ID after produce mezzanine finished.
  19. 1. Not required
  20. 2. Use default transcode template group id when empty
  21. */
  22. $produceConfig['TemplateGroupId'] = null;
  23. return json_encode($produceConfig);
  24. }
  25. try {
  26. $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');
  27. $request = new vod\ProduceEditingProjectVideoRequest();
  28. // Set Editing Project ID need to produce
  29. $request->setProjectId('7794d3757fe548e0abacb5dd10xxxxxx');
  30. // Set Produce Media Metadata
  31. $request->setMediaMetadata(buildMediaMetadata());
  32. // Set Produce Configuration
  33. $request->setProduceConfig(buildProduceConfig());
  34. // Get result
  35. $result = $client->getAcsResponse($request);
  36. var_dump($result);
  37. } catch (Exception $e) {
  38. print $e->getMessage()."\n";
  39. }

创建云剪辑工程

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

  1. function buildTimeline() {
  2. $timeline = array();
  3. // Video Track
  4. $videoTracks = array();
  5. $videoTrack = array();
  6. // Video Track Clicps
  7. $videoTrackClips = array();
  8. $videoTrackClip1 = array();
  9. $videoTrackClip1['MediaId'] = '6893fca9814640c8821efa523xxxxxx';
  10. $videoTrackClips[] = $videoTrackClip1;
  11. $videoTrackClip2 = array();
  12. $videoTrackClip2['MediaId'] = '070bbc13d8294e35b36c3e7abxxxxxx';
  13. $videoTrackClips[] = $videoTrackClip2;
  14. $videoTrack['VideoTrackClips'] = $videoTrackClips;
  15. $videoTracks[] = $videoTrack;
  16. $timeline['VideoTracks'] = $videoTracks;
  17. return json_encode($timeline);
  18. }
  19. try {
  20. $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');
  21. $request = new vod\AddEditingProjectRequest();
  22. // Build Editing Project Timeline
  23. $request->setTimeline(buildTimeline());
  24. // Set Editing Project Title
  25. $request->setTitle('Editing Project Title');
  26. // Set Editing Project Description
  27. $request->setDescription('Editing Project Description');
  28. // Set Editing Project Cover URL
  29. $request->setCoverURL('http://test.testvod123.com/editingproject/cover/projectid.jpg');
  30. // Get result
  31. $result = $client->getAcsResponse($request);
  32. var_dump($result);
  33. } catch (Exception $e) {
  34. print $e->getMessage()."\n";
  35. }

修改云剪辑工程

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

  1. function buildTimeline() {
  2. $timeline = array();
  3. // Video Track
  4. $videoTracks = array();
  5. $videoTrack = array();
  6. // Video Track Clicps
  7. $videoTrackClips = array();
  8. $videoTrackClip1 = array();
  9. $videoTrackClip1['MediaId'] = '6893fca9814640c8821efa523xxxxxx';
  10. $videoTrackClips[] = $videoTrackClip1;
  11. $videoTrackClip2 = array();
  12. $videoTrackClip2['MediaId'] = '070bbc13d8294e35b36c3e7abxxxxxx';
  13. $videoTrackClips[] = $videoTrackClip2;
  14. $videoTrack['VideoTrackClips'] = $videoTrackClips;
  15. $videoTracks[] = $videoTrack;
  16. $timeline['VideoTracks'] = $videoTracks;
  17. return json_encode($timeline);
  18. }
  19. try {
  20. $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');
  21. $request = new vod\UpdateEditingProjectRequest();
  22. // Set Editing Project ID
  23. $request->setProjectId('e7c5d44105d3487db23703be1xxxxxx');
  24. // Build Editing Project Timeline
  25. $request->setTimeline(buildTimeline());
  26. // Set Editing Project Title
  27. $request->setTitle('Editing Project Title2');
  28. // Set Editing Project Description
  29. $request->setDescription('Editing Project Description2');
  30. // Set Editing Project Cover URL
  31. $request->setCoverURL('http://test.testvod123.com/editingproject/cover/projectid.jpg');
  32. // Get result
  33. $result = $client->getAcsResponse($request);
  34. var_dump($result);
  35. } catch (Exception $e) {
  36. print $e->getMessage()."\n";
  37. }

删除云剪辑工程

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

  1. try {
  2. $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');
  3. $request = new vod\DeleteEditingProjectRequest();
  4. // Use comma to split Multi Editing Project IDs
  5. $request->setProjectIds('e7c5d44105d3487db23703be13xxxxxx,12c5d44105d3487db23703be13xxxxxx');
  6. // Get result
  7. $result = $client->getAcsResponse($request);
  8. var_dump($result);
  9. } catch (Exception $e) {
  10. print $e->getMessage()."\n";
  11. }

获取单个云剪辑工程

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

  1. try {
  2. $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');
  3. $request = new vod\GetEditingProjectRequest();
  4. // Set Editing Project ID
  5. $request->setProjectId('7794d3757fe548e0abacb5dd1xxxxxx');
  6. // Get result
  7. $result = $client->getAcsResponse($request);
  8. var_dump($result);
  9. } catch (Exception $e) {
  10. print $e->getMessage()."\n";
  11. }

搜索云剪辑工程

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

  1. try {
  2. $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');
  3. $request = new vod\SearchEditingProjectRequest();
  4. $request->setTitle('Title Keywords');
  5. $request->setStartTime('2017-01-11T12:00:00Z');
  6. $request->setEndTime('2017-01-12T12:00:00Z');
  7. $request->setPageSize(10);
  8. $request->setPageNo(1);
  9. // Get result
  10. $result = $client->getAcsResponse($request);
  11. var_dump($result);
  12. } catch (Exception $e) {
  13. print $e->getMessage()."\n";
  14. }

设置云剪辑工程素材

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

  1. // 设置云剪辑工程素材
  2. try {
  3. $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');
  4. $request = new vod\SetEditingProjectMaterialsRequest();
  5. // Set Editing Project ID
  6. $request->setProjectId('7794d3757fe548e0abacb5dd10xxxxx');
  7. // Set Editing Project Material IDs, use comma to split
  8. $request->setMaterialIds('materialId1,materialId2');
  9. // Get result
  10. $result = $client->getAcsResponse($request);
  11. var_dump($result);
  12. } catch (Exception $e) {
  13. print $e->getMessage()."\n";
  14. }

获取云剪辑工程素材

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

  1. try {
  2. $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');
  3. $request = new vod\GetEditingProjectMaterialsRequest();
  4. // Set Editing Project ID
  5. $request->setProjectId('7794d3757fe548e0abacb5dd10xxxxx');
  6. // Set Editing Project Type
  7. $request->setType('video');
  8. // Get result
  9. $result = $client->getAcsResponse($request);
  10. var_dump($result);
  11. } catch (Exception $e) {
  12. print $e->getMessage()."\n";
  13. }