全部产品

视频剪辑

本篇文档提供了C/C++ SDK视频剪辑模块相关功能的API调用示例。包含发起剪辑合成、创建云剪辑工程、修改云剪辑工程、删除云剪辑工程、获取单个云剪辑工程、设置云剪辑工程素材等。

初始化客户端

使用前请先初始化客户端,请参见初始化

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

调用ProduceEditingProjectVideo接口,完成通过时间线-发起剪辑合成功能。

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

说明

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

#include <stdio.h>
#include <string>
#include <map>
#include <jsoncpp/json/json.h>
#include "vod_sdk/openApiUtil.h"

Json::Value buildMediaMetadata(){
    Json::Value mediaMetadata;
    // Produce Media Title
    mediaMetadata["Title"] = "TestTitle";
    // Produce Media Description
    mediaMetadata["Description"] = "TestDescription";
    // Produce Media UserDefined Cover URL
    mediaMetadata["CoverURL"] = "http://192.168.0.0/16/media/cover/mediaid.jpg";
    // Produce Media Category ID
    mediaMetadata["CateId"] = "<your cateid>";
    // Produce Media Category Name
    mediaMetadata["Tags"] = "Tag1,Tag2";
    return mediaMetadata;
}

Json::Value buildProduceConfig(){
    Json::Value produceConfig;
    /*
    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.
    1. Not required 
    2. Use default transcode template group id when empty
    */
    produceConfig["TemplateGroupId"] = "<your TemplateGroupId>";
    return produceConfig;
}

/**
* This Sample shows how to merge two videos
*/
Json::Value buildTimeline(){
    Json::Value timeline;

    // Video Track
    Json::Value videoTracks;
    Json::Value videoTrack;
    // Video Track Clips
    Json::Value videoTrackClips;
    Json::Value videoTrackClip1;
    videoTrackClip1["MediaId"] = "11119b4d7cf14dc7b83b0e801cbe****";
    videoTrackClips.append(videoTrackClip1);
    Json::Value videoTrackClip2;
    videoTrackClip2["MediaId"] = "22229b4d7cf14dc7b83b0e801cbe****";
    videoTrackClips.append(videoTrackClip2);

    videoTrack["VideoTrackClips"] = videoTrackClips;
    videoTracks.append(videoTrack);

    timeline["VideoTracks"] = videoTracks;

    return timeline;
}

VodApiResponse produceEditingProjectVideo(VodCredential authInfo) {
    string apiName = "ProduceEditingProjectVideo";
    map<string, string> args;
    args["Timeline"] = buildTimeline().toStyledString();
    args["MediaMetadata"] = buildMediaMetadata().toStyledString();
    args["ProduceConfig"] = buildProduceConfig().toStyledString();
    return getAcsResponse(authInfo, apiName, args);
}

// 请求示例
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
    VodApiResponse response = produceEditingProjectVideo(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

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

调用ProduceEditingProjectVideo接口,完成通过云剪辑工程-发起剪辑合成功能。

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

#include <stdio.h>
#include <string>
#include <map>
#include <jsoncpp/json/json.h>
#include "vod_sdk/openApiUtil.h"

Json::Value buildMediaMetadata(){
    Json::Value mediaMetadata;
    // Produce Media Title
    mediaMetadata["Title"] = "TestTitle";
    // Produce Media Description
    mediaMetadata["Description"] = "TestDescription";
    // Produce Media UserDefined Cover URL
    mediaMetadata["CoverURL"] = "http://192.168.0.0/16/media/cover/mediaid.jpg";
    // Produce Media Category ID
    mediaMetadata["CateId"] = "<your cateid>";
    // Produce Media Category Name
    mediaMetadata["Tags"] = "Tag1,Tag2";
    return mediaMetadata;
}

Json::Value buildProduceConfig(){
    Json::Value produceConfig;
    /*
    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.
    1. Not required 
    2. Use default transcode template group id when empty
    */
    produceConfig["TemplateGroupId"] = "<your TemplateGroupId>";
    return produceConfig;
}

VodApiResponse produceEditingProjectVideo(VodCredential authInfo) {
    string apiName = "ProduceEditingProjectVideo";
    map<string, string> args;
    // Set Editing Project ID need to produce
    args["ProjectId"] = "<your ProjectId>";
    // Set Produce Media Metadata
    args["MediaMetadata"] = buildMediaMetadata().toStyledString();
    // Set Produce Configuration
    args["ProduceConfig"] = buildProduceConfig().toStyledString();
    return getAcsResponse(authInfo, apiName, args);
}

// 请求示例
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
    VodApiResponse response = produceEditingProjectVideo(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

创建云剪辑工程

调用AddEditingProject接口,完成创建云剪辑工程功能。

接口参数和返回字段请参见AddEditingProject。调用示例如下:

#include <stdio.h>
#include <string>
#include <map>
#include <jsoncpp/json/json.h>
#include "vod_sdk/openApiUtil.h"

/**
* This Sample shows how to merge two videos
*/
Json::Value buildTimeline(){
    Json::Value timeline;

    // Video Track
    Json::Value videoTracks;
    Json::Value videoTrack;
    // Video Track Clips
    Json::Value videoTrackClips;
    Json::Value videoTrackClip1;
    videoTrackClip1["MediaId"] = "11119b4d7cf14dc7b83b0e801cbe****";
    videoTrackClips.append(videoTrackClip1);
    Json::Value videoTrackClip2;
    videoTrackClip2["MediaId"] = "22229b4d7cf14dc7b83b0e801cbe****";
    videoTrackClips.append(videoTrackClip2);

    videoTrack["VideoTrackClips"] = videoTrackClips;
    videoTracks.append(videoTrack);

    timeline["VideoTracks"] = videoTracks;

    return timeline;
}

VodApiResponse addEditingProject(VodCredential authInfo) {
    string apiName = "AddEditingProject";
    map<string, string> args;
    // Build Editing Project Timeline
    args["Timeline"] = buildTimeline().toStyledString();
    // Set Editing Project Title
    args["Title"] = "Editing Project Title";
    // Set Editing Project Cover URL
    args["CoverURL"] = "http://192.168.0.0/16/editingproject/cover/projectid.jpg";
    // Set Editing Project Description
    args["Description"] = "Editing Project Description";
    return getAcsResponse(authInfo, apiName, args);
}

// 请求示例
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
    VodApiResponse response = addEditingProject(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

修改云剪辑工程

调用UpdateEditingProject接口,完成修改云剪辑工程功能。

接口参数和返回字段请参见UpdateEditingProject。调用示例如下:

#include <stdio.h>
#include <string>
#include <map>
#include <jsoncpp/json/json.h>
#include "vod_sdk/openApiUtil.h"

/**
* This Sample shows how to merge two videos
*/
Json::Value buildTimeline(){
    Json::Value timeline;

    // Video Track
    Json::Value videoTracks;
    Json::Value videoTrack;
    // Video Track Clips
    Json::Value videoTrackClips;
    Json::Value videoTrackClip1;
    videoTrackClip1["MediaId"] = "11119b4d7cf14dc7b83b0e801cbe****";
    videoTrackClips.append(videoTrackClip1);
    Json::Value videoTrackClip2;
    videoTrackClip2["MediaId"] = "22229b4d7cf14dc7b83b0e801cbe****";
    videoTrackClips.append(videoTrackClip2);

    videoTrack["VideoTrackClips"] = videoTrackClips;
    videoTracks.append(videoTrack);

    timeline["VideoTracks"] = videoTracks;

    return timeline;
}

VodApiResponse updateEditingProject(VodCredential authInfo) {
    string apiName = "UpdateEditingProject";
    map<string, string> args;
    args["ProjectId"] = "YourProjectId";
    // Build Editing Project Timeline
    args["Timeline"] = buildTimeline().toStyledString();
    // Set Editing Project Title
    args["Title"] = "Editing Project Title";
    // Set Editing Project Cover URL
    args["CoverURL"] = "http://192.168.0.0/16/editingproject/cover/projectid.jpg";
    // Set Editing Project Description
    args["Description"] = "Editing Project Description";
    return getAcsResponse(authInfo, apiName, args);
}

// 请求示例
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
    VodApiResponse response = updateEditingProject(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

删除云剪辑工程

调用DeleteEditingProject接口,完成删除云剪辑工程功能。

接口参数和返回字段请参见DeleteEditingProject。调用示例如下:

#include <stdio.h>
#include <string>
#include <map>
#include <jsoncpp/json/json.h>
#include "vod_sdk/openApiUtil.h"

VodApiResponse deleteEditingProject(VodCredential authInfo) {
    string apiName = "DeleteEditingProject";
    map<string, string> args;
    args["ProjectIds"] = "projectid1,projectid2";
    return getAcsResponse(authInfo, apiName, args);
}

// 请求示例
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
    VodApiResponse response = deleteEditingProject(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

获取单个云剪辑工程

调用GetEditingProject接口,完成获取单个云剪辑工程功能。

接口参数和返回字段请参见GetEditingProject。调用示例如下:

#include <stdio.h>
#include <string>
#include <map>
#include <jsoncpp/json/json.h>
#include "vod_sdk/openApiUtil.h"

VodApiResponse getEditingProject(VodCredential authInfo) {
    string apiName = "GetEditingProject";
    map<string, string> args;
    args["ProjectId"] = "your projectId";
    return getAcsResponse(authInfo, apiName, args);
}

// 请求示例
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
    VodApiResponse response = getEditingProject(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

搜索云剪辑工程

调用SearchEditingProject接口,完成搜索云剪辑工程功能。

接口参数和返回字段请参见SearchEditingProject。调用示例如下:

#include <stdio.h>
#include <string>
#include <map>
#include <jsoncpp/json/json.h>
#include "vod_sdk/openApiUtil.h"

VodApiResponse searchEditingProject(VodCredential authInfo) {
    string apiName = "SearchEditingProject";
    map<string, string> args;
    args["Title"] = "Title Keywords";
    args["StartTime"] = "2017-01-11T12:00:00Z";
    args["EndTime"] = "2017-01-12T12:00:00Z";
    args["PageSize"] = "10";
    args["PageNo"] = "1";
    return getAcsResponse(authInfo, apiName, args);
}

// 请求示例
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
    VodApiResponse response = searchEditingProject(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

设置云剪辑工程素材

调用SetEditingProjectMaterials接口,完成设置云剪辑工程素材功能。

接口参数和返回字段请参见SetEditingProjectMaterials。调用示例如下:

#include <stdio.h>
#include <string>
#include <map>
#include <jsoncpp/json/json.h>
#include "vod_sdk/openApiUtil.h"

VodApiResponse setEditingProjectMaterials(VodCredential authInfo) {
    string apiName = "SetEditingProjectMaterials";
    map<string, string> args;
    args["ProjectId"] = "<Your ProjectId>";
    args["MaterialIds"] = "materialId1,materialId2";
    return getAcsResponse(authInfo, apiName, args);
}

// 请求示例
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
    VodApiResponse response = setEditingProjectMaterials(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

获取云剪辑工程素材

调用GetEditingProjectMaterials接口,完成获取云剪辑工程素材功能。

接口参数和返回字段请参见GetEditingProjectMaterials。调用示例如下:

#include <stdio.h>
#include <string>
#include <map>
#include <jsoncpp/json/json.h>
#include "vod_sdk/openApiUtil.h"

VodApiResponse getEditingProjectMaterials(VodCredential authInfo) {
    string apiName = "GetEditingProjectMaterials";
    map<string, string> args;
    args["ProjectId"] = "<Your ProjectId>";
    args["Type"] = "video";
    return getAcsResponse(authInfo, apiName, args);
}

// 请求示例
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
    VodApiResponse response = getEditingProjectMaterials(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}