全部产品
云市场

视频剪辑

更新时间:2019-01-17 13:54:45

初始化客户端

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

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

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

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

  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include <jsoncpp/json/json.h>
  5. #include "vod_sdk/openApiUtil.h"
  6. Json::Value buildMediaMetadata(){
  7. Json::Value mediaMetadata;
  8. // Produce Media Title
  9. mediaMetadata["Title"] = "TestTitle";
  10. // Produce Media Description
  11. mediaMetadata["Description"] = "TestDescription";
  12. // Produce Media UserDefined Cover URL
  13. mediaMetadata["CoverURL"] = "http://test.testvod123.com/media/cover/mediaid.jpg";
  14. // Produce Media Category ID
  15. mediaMetadata["CateId"] = "<your cateid>";
  16. // Produce Media Category Name
  17. mediaMetadata["Tags"] = "Tag1,Tag2";
  18. return mediaMetadata;
  19. }
  20. Json::Value buildProduceConfig(){
  21. Json::Value produceConfig;
  22. /*
  23. 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.
  24. 1. Not required
  25. 2. Use default transcode template group id when empty
  26. */
  27. produceConfig["TemplateGroupId"] = "<your TemplateGroupId>";
  28. return produceConfig;
  29. }
  30. /**
  31. * This Sample shows how to merge two videos
  32. */
  33. Json::Value buildTimeline(){
  34. Json::Value timeline;
  35. // Video Track
  36. Json::Value videoTracks;
  37. Json::Value videoTrack;
  38. // Video Track Clips
  39. Json::Value videoTrackClips;
  40. Json::Value videoTrackClip1;
  41. videoTrackClip1["MediaId"] = "11119b4d7cf14dc7b83b0e801cbe1ce6";
  42. videoTrackClips.append(videoTrackClip1);
  43. Json::Value videoTrackClip2;
  44. videoTrackClip2["MediaId"] = "22229b4d7cf14dc7b83b0e801cbe1ce6";
  45. videoTrackClips.append(videoTrackClip2);
  46. videoTrack["VideoTrackClips"] = videoTrackClips;
  47. videoTracks.append(videoTrack);
  48. timeline["VideoTracks"] = videoTracks;
  49. return timeline;
  50. }
  51. VodApiResponse produceEditingProjectVideo(VodCredential authInfo) {
  52. string apiName = "ProduceEditingProjectVideo";
  53. map<string, string> args;
  54. args["Timeline"] = buildTimeline().toStyledString();
  55. args["MediaMetadata"] = buildMediaMetadata().toStyledString();
  56. args["ProduceConfig"] = buildProduceConfig().toStyledString();
  57. return getAcsResponse(authInfo, apiName, args);
  58. }
  59. // 请求示例
  60. void main() {
  61. VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  62. VodApiResponse response = produceEditingProjectVideo(authInfo);
  63. printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
  64. }

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

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

  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include <jsoncpp/json/json.h>
  5. #include "vod_sdk/openApiUtil.h"
  6. Json::Value buildMediaMetadata(){
  7. Json::Value mediaMetadata;
  8. // Produce Media Title
  9. mediaMetadata["Title"] = "TestTitle";
  10. // Produce Media Description
  11. mediaMetadata["Description"] = "TestDescription";
  12. // Produce Media UserDefined Cover URL
  13. mediaMetadata["CoverURL"] = "http://test.testvod123.com/media/cover/mediaid.jpg";
  14. // Produce Media Category ID
  15. mediaMetadata["CateId"] = "<your cateid>";
  16. // Produce Media Category Name
  17. mediaMetadata["Tags"] = "Tag1,Tag2";
  18. return mediaMetadata;
  19. }
  20. Json::Value buildProduceConfig(){
  21. Json::Value produceConfig;
  22. /*
  23. 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.
  24. 1. Not required
  25. 2. Use default transcode template group id when empty
  26. */
  27. produceConfig["TemplateGroupId"] = "<your TemplateGroupId>";
  28. return produceConfig;
  29. }
  30. VodApiResponse produceEditingProjectVideo(VodCredential authInfo) {
  31. string apiName = "ProduceEditingProjectVideo";
  32. map<string, string> args;
  33. // Set Editing Project ID need to produce
  34. args["ProjectId"] = "<your ProjectId>";
  35. // Set Produce Media Metadata
  36. args["MediaMetadata"] = buildMediaMetadata().toStyledString();
  37. // Set Produce Configuration
  38. args["ProduceConfig"] = buildProduceConfig().toStyledString();
  39. return getAcsResponse(authInfo, apiName, args);
  40. }
  41. // 请求示例
  42. void main() {
  43. VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  44. VodApiResponse response = produceEditingProjectVideo(authInfo);
  45. printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
  46. }

创建云剪辑工程

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

  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include <jsoncpp/json/json.h>
  5. #include "vod_sdk/openApiUtil.h"
  6. /**
  7. * This Sample shows how to merge two videos
  8. */
  9. Json::Value buildTimeline(){
  10. Json::Value timeline;
  11. // Video Track
  12. Json::Value videoTracks;
  13. Json::Value videoTrack;
  14. // Video Track Clips
  15. Json::Value videoTrackClips;
  16. Json::Value videoTrackClip1;
  17. videoTrackClip1["MediaId"] = "11119b4d7cf14dc7b83b0e801cbe1ce6";
  18. videoTrackClips.append(videoTrackClip1);
  19. Json::Value videoTrackClip2;
  20. videoTrackClip2["MediaId"] = "22229b4d7cf14dc7b83b0e801cbe1ce6";
  21. videoTrackClips.append(videoTrackClip2);
  22. videoTrack["VideoTrackClips"] = videoTrackClips;
  23. videoTracks.append(videoTrack);
  24. timeline["VideoTracks"] = videoTracks;
  25. return timeline;
  26. }
  27. VodApiResponse addEditingProject(VodCredential authInfo) {
  28. string apiName = "AddEditingProject";
  29. map<string, string> args;
  30. // Build Editing Project Timeline
  31. args["Timeline"] = buildTimeline().toStyledString();
  32. // Set Editing Project Title
  33. args["Title"] = "Editing Project Title";
  34. // Set Editing Project Cover URL
  35. args["CoverURL"] = "http://test.testvod123.com/editingproject/cover/projectid.jpg";
  36. // Set Editing Project Description
  37. args["Description"] = "Editing Project Description";
  38. return getAcsResponse(authInfo, apiName, args);
  39. }
  40. // 请求示例
  41. void main() {
  42. VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  43. VodApiResponse response = addEditingProject(authInfo);
  44. printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
  45. }

修改云剪辑工程

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

  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include <jsoncpp/json/json.h>
  5. #include "vod_sdk/openApiUtil.h"
  6. /**
  7. * This Sample shows how to merge two videos
  8. */
  9. Json::Value buildTimeline(){
  10. Json::Value timeline;
  11. // Video Track
  12. Json::Value videoTracks;
  13. Json::Value videoTrack;
  14. // Video Track Clips
  15. Json::Value videoTrackClips;
  16. Json::Value videoTrackClip1;
  17. videoTrackClip1["MediaId"] = "11119b4d7cf14dc7b83b0e801cbe1ce6";
  18. videoTrackClips.append(videoTrackClip1);
  19. Json::Value videoTrackClip2;
  20. videoTrackClip2["MediaId"] = "22229b4d7cf14dc7b83b0e801cbe1ce6";
  21. videoTrackClips.append(videoTrackClip2);
  22. videoTrack["VideoTrackClips"] = videoTrackClips;
  23. videoTracks.append(videoTrack);
  24. timeline["VideoTracks"] = videoTracks;
  25. return timeline;
  26. }
  27. VodApiResponse updateEditingProject(VodCredential authInfo) {
  28. string apiName = "UpdateEditingProject";
  29. map<string, string> args;
  30. args["ProjectId"] = "YourProjectId";
  31. // Build Editing Project Timeline
  32. args["Timeline"] = buildTimeline().toStyledString();
  33. // Set Editing Project Title
  34. args["Title"] = "Editing Project Title";
  35. // Set Editing Project Cover URL
  36. args["CoverURL"] = "http://test.testvod123.com/editingproject/cover/projectid.jpg";
  37. // Set Editing Project Description
  38. args["Description"] = "Editing Project Description";
  39. return getAcsResponse(authInfo, apiName, args);
  40. }
  41. // 请求示例
  42. void main() {
  43. VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  44. VodApiResponse response = updateEditingProject(authInfo);
  45. printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
  46. }

删除云剪辑工程

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

  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include <jsoncpp/json/json.h>
  5. #include "vod_sdk/openApiUtil.h"
  6. VodApiResponse deleteEditingProject(VodCredential authInfo) {
  7. string apiName = "DeleteEditingProject";
  8. map<string, string> args;
  9. args["ProjectIds"] = "projectid1,projectid2";
  10. return getAcsResponse(authInfo, apiName, args);
  11. }
  12. // 请求示例
  13. void main() {
  14. VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  15. VodApiResponse response = deleteEditingProject(authInfo);
  16. printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
  17. }

获取单个云剪辑工程

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

  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include <jsoncpp/json/json.h>
  5. #include "vod_sdk/openApiUtil.h"
  6. VodApiResponse getEditingProject(VodCredential authInfo) {
  7. string apiName = "GetEditingProject";
  8. map<string, string> args;
  9. args["ProjectId"] = "your projectId";
  10. return getAcsResponse(authInfo, apiName, args);
  11. }
  12. // 请求示例
  13. void main() {
  14. VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  15. VodApiResponse response = getEditingProject(authInfo);
  16. printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
  17. }

搜索云剪辑工程

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

  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include <jsoncpp/json/json.h>
  5. #include "vod_sdk/openApiUtil.h"
  6. VodApiResponse searchEditingProject(VodCredential authInfo) {
  7. string apiName = "SearchEditingProject";
  8. map<string, string> args;
  9. args["Title"] = "Title Keywords";
  10. args["StartTime"] = "2017-01-11T12:00:00Z";
  11. args["EndTime"] = "2017-01-12T12:00:00Z";
  12. args["PageSize"] = "10";
  13. args["PageNo"] = "1";
  14. return getAcsResponse(authInfo, apiName, args);
  15. }
  16. // 请求示例
  17. void main() {
  18. VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  19. VodApiResponse response = searchEditingProject(authInfo);
  20. printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
  21. }

设置云剪辑工程素材

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

  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include <jsoncpp/json/json.h>
  5. #include "vod_sdk/openApiUtil.h"
  6. VodApiResponse setEditingProjectMaterials(VodCredential authInfo) {
  7. string apiName = "SetEditingProjectMaterials";
  8. map<string, string> args;
  9. args["ProjectId"] = "<Your ProjectId>";
  10. args["MaterialIds"] = "materialId1,materialId2";
  11. return getAcsResponse(authInfo, apiName, args);
  12. }
  13. // 请求示例
  14. void main() {
  15. VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  16. VodApiResponse response = setEditingProjectMaterials(authInfo);
  17. printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
  18. }

获取云剪辑工程素材

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

  1. #include <stdio.h>
  2. #include <string>
  3. #include <map>
  4. #include <jsoncpp/json/json.h>
  5. #include "vod_sdk/openApiUtil.h"
  6. VodApiResponse getEditingProjectMaterials(VodCredential authInfo) {
  7. string apiName = "GetEditingProjectMaterials";
  8. map<string, string> args;
  9. args["ProjectId"] = "<Your ProjectId>";
  10. args["Type"] = "video";
  11. return getAcsResponse(authInfo, apiName, args);
  12. }
  13. // 请求示例
  14. void main() {
  15. VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  16. VodApiResponse response = getEditingProjectMaterials(authInfo);
  17. printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
  18. }