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.

// Call example
var client = initVodClient('<Your AccessKey ID>','<Your AccessKey Secret>');

// Constructs a timeline for producing videos.
var timeline = {
    // Specifies video tracks.
    VideoTracks: [{
        // Specifies video track clips.
        VideoTrackClips: [{
            MediaId: 'MediaId1'
        },{
            MediaId: 'MediaId2'
        }]
    }]
};
// Specifies the metadata of the produced video.
var mediaMetadata = {
    Title: 'Title', // The title of the produced video.
    Description: 'Description', // The description of the produced video.
    CoverURL: 'http://test.testvod123.com/media/cover/mediaid.jpg', // The user-defined thumbnail URL of the produced video.
    CateId: null, // The category ID of the produced video.
    Tags: 'Tag1,Tag2' // The tags of the produced video.
};
// Specifies the production configuration.
var 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.
     */
    TemplateGroupId: null
};
client.request("ProduceEditingProjectVideo", {
    Timeline: JSON.stringify(timeline),
    MediaMetadata: JSON.stringify(mediaMetadata),
    ProduceConfig: JSON.stringify(produceConfig)
}, {}).then(function (response) {
    // The ID of the produced video.
    console.log('MediaId = '+ response.MediaId);
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

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.

// Call example
var client = initVodClient('<Your AccessKey ID>','<Your AccessKey Secret>');

// Specifies the metadata of the produced video.
var mediaMetadata = {
    Title: 'Title', // The title of the produced video.
    Description: 'Description', // The description of the produced video.
    CoverURL: 'http://test.testvod123.com/media/cover/mediaid.jpg', // The user-defined thumbnail URL of the produced video.
    CateId: null, // The category ID of the produced video.
    Tags: 'Tag1,Tag2' // The tags of the produced video.
};
// Specifies the production configuration.
var 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.
     */
    TemplateGroupId: null
};
client.request("ProduceEditingProjectVideo", {
    ProjectId: 'ProjectId', // Sets the ID of the online editing project.
    MediaMetadata: JSON.stringify(mediaMetadata),
    ProduceConfig: JSON.stringify(produceConfig)
}, {}).then(function (response) {
    // The ID of the produced video.
    console.log('MediaId = '+ response.MediaId);
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

Create an online editing project

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

// Call example
var client = initVodClient('<Your AccessKey ID>','<Your AccessKey Secret>');

// Constructs a timeline of the online editing project.
var timeline = {
    // Specifies video tracks.
    VideoTracks: [{
        // Specifies video track clips.
        VideoTrackClips: [{
            MediaId: 'MediaId1'
        },{
            MediaId: 'MediaId2'
        }]
    }]
};
client.request("AddEditingProject", {
    Timeline: JSON.stringify(timeline),
    Title: 'Editing Project Title', // Sets the title of the online editing project.
    Description: 'Editing Project Description', // Sets the description of the online editing project.
    CoverURL: 'http://test.testvod123.com/editingproject/cover/projectid.jpg' // Sets the thumbnail URL of the online editing project.
}, {}).then(function (response) {
    if (response.Project){
        console.log('Editing Project Id = '+ response.Project.ProjectId);
        console.log('Editing Project Title = '+ response.Project.Title);
        console.log('Editing Project Description = '+ response.Project.Description);
    }
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

Modify an online editing project

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

// Call example
var client = initVodClient('<Your AccessKey ID>','<Your AccessKey Secret>');

// Constructs a timeline of the online editing project.
var timeline = {
    // Specifies video tracks.
    VideoTracks: [{
        // Specifies video track clips.
        VideoTrackClips: [{
            MediaId: 'MediaId1'
        },{
            MediaId: 'MediaId2'
        }]
    }]
};
client.request("UpdateEditingProject", {
    ProjectId: 'ProjectId',
    Timeline: JSON.stringify(timeline),
    Title: 'Editing Project Title', // Sets the title of the online editing project.
    Description: 'Editing Project Description', // Sets the description of the online editing project.
    CoverURL: 'http://test.testvod123.com/editingproject/cover/projectid.jpg' // Sets the thumbnail URL of the online editing project.
}, {}).then(function (response) {
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

Delete one or more online editing projects

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

// Call example
var client = initVodClient('<Your AccessKey ID>','<Your AccessKey Secret>');

client.request("DeleteEditingProject", {
    ProjectIds: 'ProjectId1,projectid2'
}, {}).then(function (response) {
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

Obtain the information about an online editing project

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

// Call example
var client = initVodClient('<Your AccessKey ID>','<Your AccessKey Secret>');

client.request("GetEditingProject", {
    ProjectId: 'ProjectId'
}, {}).then(function (response) {
    if (response.Project){
        console.log('Editing Project Id = '+ response.Project.ProjectId);
        console.log('Editing Project Timeline = '+ response.Project.Timeline);
        console.log('Editing Project Title = '+ response.Project.Title);
        console.log('Editing Project Description = '+ response.Project.Description);
        console.log('Editing Project CoverURL = '+ response.Project.CoverURL);
        console.log('Editing Project CreationTime = '+ response.Project.CreationTime);
        console.log('Editing Project ModifiedTime = '+ response.Project.ModifiedTime);
        console.log('Editing Project Status = '+ response.Project.Status);
    }
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

Search for online editing projects

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

// Call example
var client = initVodClient('<Your AccessKey ID>','<Your AccessKey Secret>');

client.request("SearchEditingProject", {
    Title: 'TitleKeywords',
    StartTime: '2018-12-28T14:42:18Z',
    EndTime: '2018-12-30T14:42:18Z',
    PageSize: 10,
    PageNo: 1
}, {}).then(function (response) {
    if (response.ProjectList && response.ProjectList.Project && response.ProjectList.Project.length > 0){
        console.log('Total Size = ' + response.Total);
        for(var i=0; i<response.ProjectList.Project.length; i++){
            var project = response.ProjectList.Project[i];
            console.log('No ' + i + ' Editing Project');
            console.log('Editing Project Id = '+ project.ProjectId);
            console.log('Editing Project Title = '+ project.Title);
            console.log('Editing Project Description = '+ project.Description);
            console.log('Editing Project CoverURL = '+ project.CoverURL);
            console.log('Editing Project CreationTime = '+ project.CreationTime);
            console.log('Editing Project ModifiedTime = '+ project.ModifiedTime);
            console.log('Editing Project Status = '+ project.Status);
        }
    }
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

Set materials to be edited for an online editing project

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

// Call example
var client = initVodClient('<Your AccessKey ID>','<Your AccessKey Secret>');

client.request("SetEditingProjectMaterials", {
    ProjectId: 'ProjectId',
    MaterialIds: 'MaterialId1,MaterialId2'
}, {}).then(function (response) {
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});

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

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

// Call example
var client = initVodClient('<Your AccessKey ID>','<Your AccessKey Secret>');

client.request("GetEditingProjectMaterials", {
    ProjectId: 'ProjectId',
    Type: 'video'
}, {}).then(function (response) {
    if (response.MaterialList && response.MaterialList.Material && response.MaterialList.Material.length > 0){
        for(var i=0; i<response.MaterialList.Material.length; i++){
            var material = response.MaterialList.Material[i];
            console.log('No ' + i + ' Editing Project');
            console.log('Editing Project Material Id = '+ material.MaterialId);
            console.log('Editing Project Material Title = '+ material.Title);
            console.log('Editing Project Material Category ID = '+ material.CateId);
            console.log('Editing Project Material Category Name = '+ material.CateName);
            console.log('Editing Project Material Tags = '+ material.Tags);
            console.log('Editing Project Material CoverURL = '+ material.CoverURL);
            console.log('Editing Project Material Create Time = '+ material.CreationTime);
            console.log('Editing Project Material Last ModifiedTime = '+ material.ModifiedTime);
        }
    }
    console.log('RequestId = ' + response.RequestId);
}).catch(function (response) {
    console.log('ErrorCode = ' + response.data.Code);
    console.log('ErrorMessage = ' + response.data.Message);
    console.log('RequestId = ' + response.data.RequestId);
});