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.

function buildMediaMetadata() {
    $mediaMetadata = array();
    // Sets the title of the produced video.
    $mediaMetadata['Title'] = 'Title';
    // Sets the description of the produced video.
    $mediaMetadata['Description'] = 'Description';
    // 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'] = null;
    // Sets the tags of the produced video.
    $mediaMetadata['Tags'] = 'Tag1,Tag2,Test';

    return json_encode($mediaMetadata);
}

function buildProduceConfig() {
    $produceConfig = array();
    /*
     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'] = null;
    return json_encode($produceConfig);
}

function buildTimeline() {
    $timeline = array();

    // Specifies video tracks.
    $videoTracks = array();
    $videoTrack = array();

    // Specifies video track clips.
    $videoTrackClips = array();
    $videoTrackClip1 = array();
    $videoTrackClip1['MediaId'] = '6893fca9814640c8821efa523xxxxxx';
    $videoTrackClips[] = $videoTrackClip1;

    $videoTrackClip2 = array();
    $videoTrackClip2['MediaId'] = '070bbc13d8294e35b36c3e7abxxxxxx';
    $videoTrackClips[] = $videoTrackClip2;

    $videoTrack['VideoTrackClips'] = $videoTrackClips;
    $videoTracks[] = $videoTrack;
    $timeline['VideoTracks'] = $videoTracks;

    return json_encode($timeline);
}

try {
     $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');

    $request = new vod\ProduceEditingProjectVideoRequest();
    // Specifies the metadata of the produced video.
    $request->setMediaMetadata(buildMediaMetadata()); 
    // Specifies the production configuration.
    $request->setProduceConfig(buildProduceConfig());
    // Constructs a timeline for producing videos.
    $request->setTimeline(buildTimeline());

    // Obtains a response.
    $result = $client->getAcsResponse($request);
    var_dump($result);
} catch (Exception $e) {
    print $e->getMessage()."\n";
}

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.

function buildMediaMetadata() {
    $mediaMetadata = array();
    // Sets the title of the produced video.
    $mediaMetadata['Title'] = 'Title';
    // Sets the description of the produced video.
    $mediaMetadata['Description'] = 'Description';
    // 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'] = null;
    // Sets the tags of the produced video.
    $mediaMetadata['Tags'] = 'Tag1,Tag2,Test';

    return json_encode($mediaMetadata);
}

function buildProduceConfig() {
    $produceConfig = array();
    /*
     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'] = null;
    return json_encode($produceConfig);
}

try {
     $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');

    $request = new vod\ProduceEditingProjectVideoRequest();
    // Sets the ID of the online editing project.
    $request->setProjectId('7794d3757fe548e0abacb5dd10xxxxxx'); 
    // Specifies the metadata of the produced video.
    $request->setMediaMetadata(buildMediaMetadata()); 
    // Specifies the production configuration.
    $request->setProduceConfig(buildProduceConfig()); 

    // Obtains a response.
    $result = $client->getAcsResponse($request); 
    var_dump($result);
} catch (Exception $e) {
    print $e->getMessage()."\n";
}

Create an online editing project

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

function buildTimeline() {
    $timeline = array();

    // Specifies video tracks.
    $videoTracks = array();
    $videoTrack = array();

    // Specifies video track clips.
    $videoTrackClips = array();
    $videoTrackClip1 = array();
    $videoTrackClip1['MediaId'] = '6893fca9814640c8821efa523xxxxxx';
    $videoTrackClips[] = $videoTrackClip1;

    $videoTrackClip2 = array();
    $videoTrackClip2['MediaId'] = '070bbc13d8294e35b36c3e7abxxxxxx';
    $videoTrackClips[] = $videoTrackClip2;

    $videoTrack['VideoTrackClips'] = $videoTrackClips;
    $videoTracks[] = $videoTrack;
    $timeline['VideoTracks'] = $videoTracks;

    return json_encode($timeline);
}

try {
    $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');

    $request = new vod\AddEditingProjectRequest();
    // Constructs a timeline of the online editing project.
    $request->setTimeline(buildTimeline()); 
   // Sets the title of the online editing project.
    $request->setTitle('Editing Project Title'); 
    // Sets the description of the online editing project.
    $request->setDescription('Editing Project Description'); 
    // Sets the thumbnail URL of the online editing project.
    $request->setCoverURL('http://test.testvod123.com/editingproject/cover/projectid.jpg'); 

    // Obtains a response.
    $result = $client->getAcsResponse($request); 
    var_dump($result);
} catch (Exception $e) {
    print $e->getMessage()."\n"; 
}

Modify an online editing project

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

function buildTimeline() {
    $timeline = array();

    // Specifies video tracks.
    $videoTracks = array();
    $videoTrack = array();

    // Specifies video track clips.
    $videoTrackClips = array();
    $videoTrackClip1 = array();
    $videoTrackClip1['MediaId'] = '6893fca9814640c8821efa523xxxxxx';
    $videoTrackClips[] = $videoTrackClip1;

    $videoTrackClip2 = array();
    $videoTrackClip2['MediaId'] = '070bbc13d8294e35b36c3e7abxxxxxx';
    $videoTrackClips[] = $videoTrackClip2;

    $videoTrack['VideoTrackClips'] = $videoTrackClips;
    $videoTracks[] = $videoTrack;
    $timeline['VideoTracks'] = $videoTracks;

    return json_encode($timeline);
}

try {
    $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>'); 

    $request = new vod\UpdateEditingProjectRequest();
    // Sets the ID of the online editing project.
    $request->setProjectId('e7c5d44105d3487db23703be1xxxxxx'); 
    // Constructs a timeline of the online editing project.
    $request->setTimeline(buildTimeline()); 
    // Sets the title of the online editing project.
    $request->setTitle('Editing Project Title2'); 
    // Sets the description of the online editing project.
    $request->setDescription('Editing Project Description2'); 
    // Sets the thumbnail URL of the online editing project.
    $request->setCoverURL('http://test.testvod123.com/editingproject/cover/projectid.jpg'); 

    // Obtains a response.
    $result = $client->getAcsResponse($request);
    var_dump($result);
} catch (Exception $e) {
    print $e->getMessage()."\n"; 
}

Delete one or more online editing projects

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

try {
    $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>'); 

    $request = new vod\DeleteEditingProjectRequest();
    // Specifies the IDs of the online editing projects to be deleted. Separate multiple online editing project IDs with a comma (,).
    $request->setProjectIds('e7c5d44105d3487db23703be13xxxxxx,12c5d44105d3487db23703be13xxxxxx'); 

    // Obtains a response.
    $result = $client->getAcsResponse($request);
    var_dump($result);
} catch (Exception $e) {
    print $e->getMessage()."\n"; 
}

Obtain the information about an online editing project

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

try {
    $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');

    $request = new vod\GetEditingProjectRequest();
    // Sets the ID of the online editing project.
    $request->setProjectId('7794d3757fe548e0abacb5dd1xxxxxx'); 

    // Obtains a response.
    $result = $client->getAcsResponse($request);
    var_dump($result);
} catch (Exception $e) {
    print $e->getMessage()."\n"; 
}

Search for online editing projects

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

try {
    $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');

    $request = new vod\SearchEditingProjectRequest();
    $request->setTitle('Title Keywords');
    $request->setStartTime('2017-01-11T12:00:00Z'); 
    $request->setEndTime('2017-01-12T12:00:00Z');
    $request->setPageSize(10);
    $request->setPageNo(1); 

    // Obtains a response.
    $result = $client->getAcsResponse($request);
    var_dump($result);
} catch (Exception $e) {
    print $e->getMessage()."\n"; 
}

Set materials to be edited for an online editing project

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

// Sets materials to be edited for an online editing project.
try {
    $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');

    $request = new vod\SetEditingProjectMaterialsRequest();
    // Sets the ID of the online editing project.    
    $request->setProjectId('7794d3757fe548e0abacb5dd10xxxxx');
    // Specifies the materials for the online editing project. Separate multiple material IDs with a comma (,).
    $request->setMaterialIds('materialId1,materialId2'); 

    // Obtains a response.
    $result = $client->getAcsResponse($request); 
    var_dump($result);
} catch (Exception $e) {
    print $e->getMessage()."\n";
}

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

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

try {
    $client = initVodClient('<AccessKeyId>', '<AccessKeySecret>'); 

    $request = new vod\GetEditingProjectMaterialsRequest();
    // Sets the ID of the online editing project.
    $request->setProjectId('7794d3757fe548e0abacb5dd10xxxxx');
    // Sets the type of the online editing project.
    $request->setType('video');

    // Obtains a response.
    $result = $client->getAcsResponse($request); 
    var_dump($result);
} catch (Exception $e) {
    print $e->getMessage()."\n";
}