全部产品
云市场

视频剪辑

更新时间:2018-12-30 10:15:03

初始化客户端

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

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

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

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

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. // Build Editing Project Timeline
  4. var timeline = {
  5. // Video Track
  6. VideoTracks: [{
  7. // Video Track Clips
  8. VideoTrackClips: [{
  9. MediaId: 'MediaId1'
  10. },{
  11. MediaId: 'MediaId2'
  12. }]
  13. }]
  14. };
  15. // Set Produce Media Metadata
  16. var mediaMetadata = {
  17. Title: 'Title', // Produce Media Title
  18. Description: 'Description', // Produce Media Description
  19. CoverURL: 'http://test.testvod123.com/media/cover/mediaid.jpg', // Produce Media UserDefined Cover URL
  20. CateId: null, // Produce Media Category ID
  21. Tags: 'Tag1,Tag2' // Produce Media Category Name
  22. };
  23. // Set Produce Configuration
  24. var produceConfig = {
  25. /*
  26. 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.
  27. 1. Not required
  28. 2. Use default transcode template group id when empty
  29. */
  30. TemplateGroupId: null
  31. };
  32. client.request("ProduceEditingProjectVideo", {
  33. Timeline: JSON.stringify(timeline),
  34. MediaMetadata: JSON.stringify(mediaMetadata),
  35. ProduceConfig: JSON.stringify(produceConfig)
  36. }, {}).then(function (response) {
  37. // Produce Media ID
  38. console.log('MediaId = '+ response.MediaId);
  39. console.log('RequestId = ' + response.RequestId);
  40. }).catch(function (response) {
  41. console.log('ErrorCode = ' + response.data.Code);
  42. console.log('ErrorMessage = ' + response.data.Message);
  43. console.log('RequestId = ' + response.data.RequestId);
  44. });

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

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

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. // Set Produce Media Metadata
  4. var mediaMetadata = {
  5. Title: 'Title', // Produce Media Title
  6. Description: 'Description', // Produce Media Description
  7. CoverURL: 'http://test.testvod123.com/media/cover/mediaid.jpg', // Produce Media UserDefined Cover URL
  8. CateId: null, // Produce Media Category ID
  9. Tags: 'Tag1,Tag2' // Produce Media Category Name
  10. };
  11. // Set Produce Configuration
  12. var produceConfig = {
  13. /*
  14. 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.
  15. 1. Not required
  16. 2. Use default transcode template group id when empty
  17. */
  18. TemplateGroupId: null
  19. };
  20. client.request("ProduceEditingProjectVideo", {
  21. ProjectId: 'ProjectId', // Set Editing Project ID need to produce
  22. MediaMetadata: JSON.stringify(mediaMetadata),
  23. ProduceConfig: JSON.stringify(produceConfig)
  24. }, {}).then(function (response) {
  25. // Produce Media ID
  26. console.log('MediaId = '+ response.MediaId);
  27. console.log('RequestId = ' + response.RequestId);
  28. }).catch(function (response) {
  29. console.log('ErrorCode = ' + response.data.Code);
  30. console.log('ErrorMessage = ' + response.data.Message);
  31. console.log('RequestId = ' + response.data.RequestId);
  32. });

创建云剪辑工程

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

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. // Build Editing Project Timeline
  4. var timeline = {
  5. // Video Track
  6. VideoTracks: [{
  7. // Video Track Clips
  8. VideoTrackClips: [{
  9. MediaId: 'MediaId1'
  10. },{
  11. MediaId: 'MediaId2'
  12. }]
  13. }]
  14. };
  15. client.request("AddEditingProject", {
  16. Timeline: JSON.stringify(timeline),
  17. Title: 'Editing Project Title', // Set Editing Project Title
  18. Description: 'Editing Project Description', // Set Editing Project Description
  19. CoverURL: 'http://test.testvod123.com/editingproject/cover/projectid.jpg' // Set Editing Project Cover URL
  20. }, {}).then(function (response) {
  21. if (response.Project){
  22. console.log('Editing Project Id = '+ response.Project.ProjectId);
  23. console.log('Editing Project Title = '+ response.Project.Title);
  24. console.log('Editing Project Description = '+ response.Project.Description);
  25. }
  26. console.log('RequestId = ' + response.RequestId);
  27. }).catch(function (response) {
  28. console.log('ErrorCode = ' + response.data.Code);
  29. console.log('ErrorMessage = ' + response.data.Message);
  30. console.log('RequestId = ' + response.data.RequestId);
  31. });

修改云剪辑工程

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

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. // Build Editing Project Timeline
  4. var timeline = {
  5. // Video Track
  6. VideoTracks: [{
  7. // Video Track Clips
  8. VideoTrackClips: [{
  9. MediaId: 'MediaId1'
  10. },{
  11. MediaId: 'MediaId2'
  12. }]
  13. }]
  14. };
  15. client.request("UpdateEditingProject", {
  16. ProjectId: 'ProjectId',
  17. Timeline: JSON.stringify(timeline),
  18. Title: 'Editing Project Title', // Set Editing Project Title
  19. Description: 'Editing Project Description', // Set Editing Project Description
  20. CoverURL: 'http://test.testvod123.com/editingproject/cover/projectid.jpg' // Set Editing Project Cover URL
  21. }, {}).then(function (response) {
  22. console.log('RequestId = ' + response.RequestId);
  23. }).catch(function (response) {
  24. console.log('ErrorCode = ' + response.data.Code);
  25. console.log('ErrorMessage = ' + response.data.Message);
  26. console.log('RequestId = ' + response.data.RequestId);
  27. });

删除云剪辑工程

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

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

获取单个云剪辑工程

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

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. client.request("GetEditingProject", {
  4. ProjectId: 'ProjectId'
  5. }, {}).then(function (response) {
  6. if (response.Project){
  7. console.log('Editing Project Id = '+ response.Project.ProjectId);
  8. console.log('Editing Project Timeline = '+ response.Project.Timeline);
  9. console.log('Editing Project Title = '+ response.Project.Title);
  10. console.log('Editing Project Description = '+ response.Project.Description);
  11. console.log('Editing Project CoverURL = '+ response.Project.CoverURL);
  12. console.log('Editing Project CreationTime = '+ response.Project.CreationTime);
  13. console.log('Editing Project ModifiedTime = '+ response.Project.ModifiedTime);
  14. console.log('Editing Project Status = '+ response.Project.Status);
  15. }
  16. console.log('RequestId = ' + response.RequestId);
  17. }).catch(function (response) {
  18. console.log('ErrorCode = ' + response.data.Code);
  19. console.log('ErrorMessage = ' + response.data.Message);
  20. console.log('RequestId = ' + response.data.RequestId);
  21. });

搜索云剪辑工程

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

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. client.request("SearchEditingProject", {
  4. Title: 'TitleKeywords',
  5. StartTime: '2018-12-28T14:42:18Z',
  6. EndTime: '2018-12-30T14:42:18Z',
  7. PageSize: 10,
  8. PageNo: 1
  9. }, {}).then(function (response) {
  10. if (response.ProjectList && response.ProjectList.Project && response.ProjectList.Project.length > 0){
  11. console.log('Total Size = ' + response.Total);
  12. for(var i=0; i<response.ProjectList.Project.length; i++){
  13. var project = response.ProjectList.Project[i];
  14. console.log('No ' + i + ' Editing Project');
  15. console.log('Editing Project Id = '+ project.ProjectId);
  16. console.log('Editing Project Title = '+ project.Title);
  17. console.log('Editing Project Description = '+ project.Description);
  18. console.log('Editing Project CoverURL = '+ project.CoverURL);
  19. console.log('Editing Project CreationTime = '+ project.CreationTime);
  20. console.log('Editing Project ModifiedTime = '+ project.ModifiedTime);
  21. console.log('Editing Project Status = '+ project.Status);
  22. }
  23. }
  24. console.log('RequestId = ' + response.RequestId);
  25. }).catch(function (response) {
  26. console.log('ErrorCode = ' + response.data.Code);
  27. console.log('ErrorMessage = ' + response.data.Message);
  28. console.log('RequestId = ' + response.data.RequestId);
  29. });

设置云剪辑工程素材

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

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. client.request("SetEditingProjectMaterials", {
  4. ProjectId: 'ProjectId',
  5. MaterialIds: 'MaterialId1,MaterialId2'
  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. });

获取云剪辑工程素材

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

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. client.request("GetEditingProjectMaterials", {
  4. ProjectId: 'ProjectId',
  5. Type: 'video'
  6. }, {}).then(function (response) {
  7. if (response.MaterialList && response.MaterialList.Material && response.MaterialList.Material.length > 0){
  8. for(var i=0; i<response.MaterialList.Material.length; i++){
  9. var material = response.MaterialList.Material[i];
  10. console.log('No ' + i + ' Editing Project');
  11. console.log('Editing Project Material Id = '+ material.MaterialId);
  12. console.log('Editing Project Material Title = '+ material.Title);
  13. console.log('Editing Project Material Category ID = '+ material.CateId);
  14. console.log('Editing Project Material Category Name = '+ material.CateName);
  15. console.log('Editing Project Material Tags = '+ material.Tags);
  16. console.log('Editing Project Material CoverURL = '+ material.CoverURL);
  17. console.log('Editing Project Material Create Time = '+ material.CreationTime);
  18. console.log('Editing Project Material Last ModifiedTime = '+ material.ModifiedTime);
  19. }
  20. }
  21. console.log('RequestId = ' + response.RequestId);
  22. }).catch(function (response) {
  23. console.log('ErrorCode = ' + response.data.Code);
  24. console.log('ErrorMessage = ' + response.data.Message);
  25. console.log('RequestId = ' + response.data.RequestId);
  26. });