All Products
Search
Document Center

Video editing

Last Updated: Jul 11, 2019

Initialize a client

Initialize a client before using the SDK. For more information, see initVodClient.

Produce videos based on a timeline

In most scenarios, you can use this method to produce videos. For more information about the request and response parameters, see ProduceEditingProjectVideo.

For more information about examples of producing videos based on a timeline, see Video editing: Examples.

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

Json::Value buildMediaMetadata(){
    Json::Value mediaMetadata;
    // Sets the title of the produced video.
    mediaMetadata["Title"] = "TestTitle";
    // Sets the description of the produced video.
    mediaMetadata["Description"] = "TestDescription";
    // Sets the user-defined thumbnail URL of the produced video.
    mediaMetadata["CoverURL"] = "http://test.testvod123.com/media/cover/mediaid.jpg";
    // Sets the category ID of the produced video.
    mediaMetadata["CateId"] = "<your cateid>"; 
    // Sets the tags of the produced video.
    mediaMetadata["Tags"] = "Tag1,Tag2";
    return mediaMetadata;
}

Json::Value buildProduceConfig(){
    Json::Value produceConfig;
    /*
    A mezzanine file is generated in the production process. You can transcode this mezzanine file to other formats. This process is similar to the transcoding process after a file is uploaded. The TemplateGroupId parameter indicates the transcoding template group ID to be used by the generated mezzanine file of the produced video for transcoding.
    1. This parameter is optional. 
    2. If you do not set this parameter, the default transcoding template group ID is used.
    */
    produceConfig["TemplateGroupId"] = "<your TemplateGroupId>"; 
    return produceConfig;
}

/**
* The following example shows how to merge two videos.
*/
Json::Value buildTimeline(){
    Json::Value timeline;

    // Specifies video tracks.
    Json::Value videoTracks;
    Json::Value videoTrack;
    // Specifies video track clips.
    Json::Value videoTrackClips;
    Json::Value videoTrackClip1;
    videoTrackClip1["MediaId"] = "11119b4d7cf14dc7b83b0e801cbe1ce6";
    videoTrackClips.append(videoTrackClip1);
    Json::Value videoTrackClip2;
    videoTrackClip2["MediaId"] = "22229b4d7cf14dc7b83b0e801cbe1ce6";
    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);
}

// Call example
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
    VodApiResponse response = produceEditingProjectVideo(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

Produce videos based on an online editing project

If online editing projects need to be managed with high requirements, you can use this method to produce videos. For more information about the request and response parameters, see ProduceEditingProjectVideo.

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

Json::Value buildMediaMetadata(){
    Json::Value mediaMetadata;
    // Sets the title of the produced video.
    mediaMetadata["Title"] = "TestTitle";
    // Sets the description of the produced video.
    mediaMetadata["Description"] = "TestDescription";
    // Sets the user-defined thumbnail URL of the produced video.
    mediaMetadata["CoverURL"] = "http://test.testvod123.com/media/cover/mediaid.jpg";
    // Sets the category ID of the produced video.
    mediaMetadata["CateId"] = "<your cateid>";
    // Sets the tags of the produced video.
    mediaMetadata["Tags"] = "Tag1,Tag2";
    return mediaMetadata;
}

Json::Value buildProduceConfig(){
    Json::Value produceConfig;
    /*
    A mezzanine file is generated in the production process. You can transcode this mezzanine file to other formats. This process is similar to the transcoding process after a file is uploaded. The TemplateGroupId parameter indicates the transcoding template group ID to be used by the generated mezzanine file of the produced video for transcoding.
    1. This parameter is optional. 
    2. If you do not set this parameter, the default transcoding template group ID is used.
    */
    produceConfig["TemplateGroupId"] = "<your TemplateGroupId>";
    return produceConfig;
}

VodApiResponse produceEditingProjectVideo(VodCredential authInfo) {
    string apiName = "ProduceEditingProjectVideo";
    map<string, string> args;
    // Sets the ID of the online editing project.
    args["ProjectId"] = "<your ProjectId>"; 
    // Specifies the metadata of the produced video.
    args["MediaMetadata"] = buildMediaMetadata().toStyledString();
    // Specifies the production configuration.
    args["ProduceConfig"] = buildProduceConfig().toStyledString();
    return getAcsResponse(authInfo, apiName, args);
}

// Call example
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
    VodApiResponse response = produceEditingProjectVideo(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

Create an online editing project

For more information about the request and response parameters, see AddEditingProject.

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

/**
* The following example shows how to merge two videos.
*/
Json::Value buildTimeline(){
    Json::Value timeline;

    // Specifies video tracks.
    Json::Value videoTracks;
    Json::Value videoTrack;
    // Specifies video track clips.
    Json::Value videoTrackClips;
    Json::Value videoTrackClip1;
    videoTrackClip1["MediaId"] = "11119b4d7cf14dc7b83b0e801cbe1ce6";
    videoTrackClips.append(videoTrackClip1);
    Json::Value videoTrackClip2;
    videoTrackClip2["MediaId"] = "22229b4d7cf14dc7b83b0e801cbe1ce6";
    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;
    // Constructs a timeline of the online editing project.
    args["Timeline"] = buildTimeline().toStyledString();
    // Sets the title of the online editing project.
    args["Title"] = "Editing Project Title";
    // Sets the thumbnail URL of the online editing project.
    args["CoverURL"] = "http://test.testvod123.com/editingproject/cover/projectid.jpg";
    // Sets the description of the online editing project.
    args["Description"] = "Editing Project Description";
    return getAcsResponse(authInfo, apiName, args);
}

// Call example
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
    VodApiResponse response = addEditingProject(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

Modify an online editing project

For more information about the request and response parameters, see UpdateEditingProject.

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

/**
* The following example shows how to merge two videos.
*/
Json::Value buildTimeline(){
    Json::Value timeline;

    // Specifies video tracks.
    Json::Value videoTracks;
    Json::Value videoTrack;
    // Specifies video track clips.
    Json::Value videoTrackClips;
    Json::Value videoTrackClip1;
    videoTrackClip1["MediaId"] = "11119b4d7cf14dc7b83b0e801cbe1ce6";
    videoTrackClips.append(videoTrackClip1);
    Json::Value videoTrackClip2;
    videoTrackClip2["MediaId"] = "22229b4d7cf14dc7b83b0e801cbe1ce6";
    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";
    // Constructs a timeline of the online editing project.
    args["Timeline"] = buildTimeline().toStyledString();
    // Sets the title of the online editing project.
    args["Title"] = "Editing Project Title";
    // Sets the thumbnail URL of the online editing project.
    args["CoverURL"] = "http://test.testvod123.com/editingproject/cover/projectid.jpg";
    // Sets the description of the online editing project.
    args["Description"] = "Editing Project Description";
    return getAcsResponse(authInfo, apiName, args);
}

// Call example
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
    VodApiResponse response = updateEditingProject(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

Delete one or more online editing projects

For more information about the request and response parameters, see 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);
}

// Call example
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
    VodApiResponse response = deleteEditingProject(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

Obtain the information about an online editing project

For more information about the request and response parameters, see 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);
}

// Call example
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
    VodApiResponse response = getEditingProject(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

Search for online editing projects

For more information about the request and response parameters, see 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);
}

// Call example
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
    VodApiResponse response = searchEditingProject(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

Set materials to be edited for an online editing project

For more information about the request and response parameters, see 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);
}

// Call example
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
    VodApiResponse response = setEditingProjectMaterials(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}

Obtain a list of materials to be edited for an online editing project

For more information about the request and response parameters, see 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);
}

// Call example
void main() {
    VodCredential authInfo = initVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
    VodApiResponse response = getEditingProjectMaterials(authInfo);
    printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}