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.

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.vod.Model.V20170321;
using Newtonsoft.Json.Linq;

namespace Aliyun.Acs.vod.Sdk.ProduceEditingProjectVideo
{
    class MainClass
    {
         /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name="args">The command-line arguments. </param>
        public static void Main(string[] args)
        {
            try
            {
                // Constructs a request.
                ProduceEditingProjectVideoRequest request = new ProduceEditingProjectVideoRequest();
                // Constructs a timeline for producing videos.
                request.Timeline = BuildTimeline();
                // Specifies the metadata of the produced video.
                request.MediaMetadata = BuildMediaMetadata();
                // Specifies the production configuration.
                request.ProduceConfig = BuildProduceConfig();
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                ProduceEditingProjectVideoResponse response = client.GetAcsResponse(request);
                Console.WriteLine("RequestId = " + response.RequestId);
                Console.WriteLine("MediaId = " + response.MediaId);
                Console.WriteLine("ProjectId = " + response.ProjectId);
            }
            catch (ServerException e)
            {
                if (e.RequestId ! = null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (ClientException e)
            {
                if (e.RequestId ! = null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (Exception e)
            {
                Console.WriteLine("ErrorMessage = " + e.ToString());
            }
        }

        /// <summary>
        /// Constructs a timeline for producing videos.
        /// </summary>
        /// <returns>The timeline.</returns>
        private static string BuildTimeline() {
            JObject timeLine = new JObject();
            // Specifies video tracks.
            JArray videoTracks = new JArray();
            JObject videoTrack = new JObject();

            // Specifies video track clips.
            JArray videoTrackClips = new JArray();
            JObject videoTrackClip1 = new JObject();
            videoTrackClip1.Add("MediaId", "11119b4d7cf14dc7b83b0e801cbe1ce6");
            videoTrackClips.Add(videoTrackClip1);

            JObject videoTrackClip2 = new JObject();
            videoTrackClip2.Add("MediaId", "22229b4d7cf14dc7b83b0e801cbe1ce6");
            videoTrackClips.Add(videoTrackClip2);
            videoTrack.Add("VideoTrackClips", videoTrackClips);
            videoTracks.Add(videoTrack);

            timeLine.Add("VideoTracks", videoTracks);

            return timeLine.ToString();
        }

        /// <summary>
        /// Specifies the metadata of the produced video.
        /// </summary>
        /// <returns>The metadata of the produced video.</returns>
        private static string BuildMediaMetadata() {
            JObject mediaMetadata = new JObject();
            // Sets the title of the produced video.
            mediaMetadata.Add("Title", "Title");
            // Sets the description of the produced video.
            mediaMetadata.Add("Description", "Description");
            // Sets the user-defined thumbnail URL of the produced video.
            mediaMetadata.Add("CoverURL", "http://test.testvod123.com/media/cover/mediaid.jpg");
            // Sets the category ID of the produced video.
            mediaMetadata.Add("CateId", null);
            // Sets the tags of the produced video.
            mediaMetadata.Add("Tags", "Tag1,Tag2,Test");

            return mediaMetadata.ToString();
        }

        /// <summary>
        /// Specifies the production configuration.
        /// </summary>
        /// <returns>The production configuration.</returns>
        private static string BuildProduceConfig() {
            JObject produceConfig = new JObject();
            /**
             * 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.Add("TemplateGroupId", null);
            return produceConfig.ToString();
        }
    }
}

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.

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.vod.Model.V20170321;
using Newtonsoft.Json.Linq;

namespace Aliyun.Acs.vod.Sdk.ProduceEditingProjectVideoProjectId
{
    class MainClass
    {
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name="args">The command-line arguments.</param>
        public static void Main(string[] args)
        {
            ProduceEditingProjectVideoResponse response = null;
            try
            {
                // Constructs a request.
                ProduceEditingProjectVideoRequest request = new ProduceEditingProjectVideoRequest();
                // Sets the ID of the online editing project.
                request.ProjectId = "ProjectId";
                // Specifies the metadata of the produced video.
                request.MediaMetadata = BuildMediaMetadata();
                // Specifies the production configuration.
                request.ProduceConfig = BuildProduceConfig();
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                response = client.GetAcsResponse(request);
                Console.WriteLine("RequestId = " + response.RequestId);
                Console.WriteLine("MediaId = " + response.MediaId);
                Console.WriteLine("ProjectId = " + response.ProjectId);
            }
            catch (ServerException e)
            {
                if (e.RequestId ! = null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (ClientException e)
            {
                if (e.RequestId ! = null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (Exception e)
            {
                Console.WriteLine("ErrorMessage = " + e.ToString());
            }
        }

        /// <summary>
        /// Specifies the metadata of the produced video.
        /// </summary>
        /// <returns>The metadata of the produced video.</returns>
        private static string BuildMediaMetadata()
        {
            JObject mediaMetadata = new JObject();

            // Sets the title of the produced video.
            mediaMetadata.Add("Title", "Title");
            // Sets the description of the produced video.
            mediaMetadata.Add("Description", "Description");
            // Sets the user-defined thumbnail URL of the produced video.
            mediaMetadata.Add("CoverURL", "http://test.testvod123.com/media/cover/mediaid.jpg");
            // Sets the category ID of the produced video.
            mediaMetadata.Add("CateId", null);
            // Sets the tags of the produced video.
            mediaMetadata.Add("Tags", "Tag1,Tag2,Test");

            return mediaMetadata.ToString();
        }

        /// <summary>
        /// Specifies the production configuration.
        /// </summary>
        /// <returns>The production configuration.</returns>
        private static string BuildProduceConfig()
        {
            JObject produceConfig = new JObject();
            /**
             * 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.Add("TemplateGroupId", null);

            return produceConfig.ToString();
        }
    }
}

Create an online editing project

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

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.AddEditingProject
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            try
            {
                // Constructs a request.
                AddEditingProjectRequest request = new AddEditingProjectRequest();
                request.Description = "new Description";
                request.Title = "new Title";
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                AddEditingProjectResponse response = client.GetAcsResponse(request);
                Console.WriteLine("RequestId = " + response.RequestId);
                if (response.Project ! = null) {
                    Console.WriteLine("ProjectId = " + response.Project.ProjectId);
                    Console.WriteLine("Title = " + response.Project.Title);
                }
            }
            catch (ServerException e)
            {
                if (e.RequestId ! = null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (ClientException e)
            {
                if (e.RequestId ! = null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (Exception e)
            {
                Console.WriteLine("ErrorMessage = " + e.ToString());
            }
        }
    }
}

Modify an online editing project

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

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.UpdateEditingProject
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            try
            {
                // Constructs a request.
                UpdateEditingProjectRequest request = new UpdateEditingProjectRequest();
                request.ProjectId = "YourProjectId";
                request.Title = "new Title";
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                UpdateEditingProjectResponse response = client.GetAcsResponse(request);
                Console.WriteLine("RequestId = " + response.RequestId);
            }
            catch (ServerException e)
            {
                if (e.RequestId ! = null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (ClientException e)
            {
                if (e.RequestId ! = null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (Exception e)
            {
                Console.WriteLine("ErrorMessage = " + e.ToString());
            }
        }
    }
}

Delete one or more online editing projects

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

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.DeleteEditingProject
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            try
            {
                // Constructs a request.
                DeleteEditingProjectRequest request = new DeleteEditingProjectRequest();
                // Specifies the IDs of the online editing projects to be deleted. Separate multiple online editing project IDs with a comma (,).
                request.ProjectIds = "projectid1,projectid2";
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                DeleteEditingProjectResponse response = client.GetAcsResponse(request);
                Console.WriteLine("RequestId = " + response.RequestId);
            }
            catch (ServerException e)
            {
                if (e.RequestId ! = null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (ClientException e)
            {
                if (e.RequestId ! = null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (Exception e)
            {
                Console.WriteLine("ErrorMessage = " + e.ToString());
            }
        }
    }
}

Obtain the information about an online editing project

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

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.GetEditingProject
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            try
            {
                // Constructs a request.
                GetEditingProjectRequest request = new GetEditingProjectRequest();
                request.ProjectId = "projectid";
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                GetEditingProjectResponse response = client.GetAcsResponse(request);
                Console.WriteLine("RequestId = " + response.RequestId);
                if (response.Project ! = null)
                {
                    Console.WriteLine("ProjectId = " + response.Project.ProjectId);
                    Console.WriteLine("Title = " + response.Project.Title);
                }
            }
            catch (ServerException e)
            {
                if (e.RequestId ! = null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (ClientException e)
            {
                if (e.RequestId ! = null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (Exception e)
            {
                Console.WriteLine("ErrorMessage = " + e.ToString());
            }
        }
    }
}

Search for online editing projects

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

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.SearchEditingProject
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            try
            {
                // Constructs a request.
                SearchEditingProjectRequest request = new SearchEditingProjectRequest();
                request.Title = "Title Keywords";
                request.StartTime = "2017-01-11T12:00:00Z";
                request.EndTime = "2017-01-12T12:00:00Z";
                request.PageSize = 10;
                request.PageNo = 1;
                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                SearchEditingProjectResponse response = client.GetAcsResponse(request);
                // The GUID generated by Alibaba Cloud for the request.
                Console.WriteLine("RequestId = " + response.RequestId);
                if (response.ProjectList ! = null && response.ProjectList.Count > 0)
                {
                    foreach (var project in response.ProjectList)
                    {
                        Console.WriteLine("ProjectId = " + project.ProjectId);
                    }
                }
            }
            catch (ServerException e)
            {
                if (e.RequestId ! = null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (ClientException e)
            {
                if (e.RequestId ! = null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (Exception e)
            {
                Console.WriteLine("ErrorMessage = " + e.ToString());
            }
        }
    }
}

Set materials to be edited for an online editing project

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

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.vod.Model.V20170321;

namespace Aliyun.Acs.vod.Sdk.SetEditingProjectMaterials
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            try
            {
                // Constructs a request.
                SetEditingProjectMaterialsRequest request = new SetEditingProjectMaterialsRequest();
                // Sets the ID of the online editing project.
                request.ProjectId = "projectid";
                // Specifies the materials for the online editing project. Separate multiple material IDs with a comma (,).
                request.MaterialIds = "materialId1,materialId2";

                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                SetEditingProjectMaterialsResponse response = client.GetAcsResponse(request);
                // The GUID generated by Alibaba Cloud for the request.
                Console.WriteLine("RequestId = " + response.RequestId);
            }
            catch (ServerException e)
            {
                if (e.RequestId ! = null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (ClientException e)
            {
                if (e.RequestId ! = null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (Exception e)
            {
                Console.WriteLine("ErrorMessage = " + e.ToString());
            }
        }
    }
}

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

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

using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.vod.Model.V20170321;

Aliyun.Acs.vod.Sdk.GetEditingProjectMaterials
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            try
            {
                // Constructs a request.
                GetEditingProjectMaterialsRequest request = new GetEditingProjectMaterialsRequest();
                request.ProjectId = "projectid";
                request.Type = "video";

                // Initializes the client.
                DefaultAcsClient client = InitVodClient("<Your AccessKey ID>", "<Your AccessKey Secret>");
                // Initiates the request and obtains a response.
                GetEditingProjectMaterialsResponse response = client.GetAcsResponse(request);
                Console.WriteLine("RequestId = " + response.RequestId);
                if (response.MaterialList ! = null && response.MaterialList.Count > 0)
                {
                    foreach (var material in response.MaterialList) 
                    {
                        Console.WriteLine("MaterialId = " + material.MaterialId);
                        Console.WriteLine("Title = " + material.Title);
                    }
                }
            }
            catch (ServerException e)
            {
                if (e.RequestId ! = null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (ClientException e)
            {
                if (e.RequestId ! = null)
                {
                    Console.WriteLine("RequestId = " + e.RequestId);
                }
                Console.WriteLine("ErrorCode = " + e.ErrorCode);
                Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
            }
            catch (Exception e)
            {
                Console.WriteLine("ErrorMessage = " + e.ToString());
            }
        }
    }
}