This topic describes how to merge multiple videos, cut out the beginning, middle, or end of your videos, and merge parts of multiple videos. Videos are cut and merged based on the timeline data.

Overview

You can call the ProduceEditingProjectVideo operation to merge videos. The timeline data is essential in video editing. For more information about video editing and merging, see Overview. You can configure the parameters of the timeline in different ways based on your requirements.

Merge videos

You can merge multiple videos in sequence without the need to specify the start or end time. Sample code:

{
    "VideoTracks": [
        {
            "VideoTrackClips": [
                {
                    "MediaId": "4bcf9b4d7cf14dc7b83b0e801cbe****"
                },
                {
                    "MediaId": "789f9b4d7cf14dc7b83b0e801cbe****"
                }
            ]
        }
    ]
}

Cut out the beginning of a video

If you want to cut out the beginning of a video, specify only the end time. The following code provides an example on how to extract the first 5 seconds of a video:

{
    "VideoTracks": [
        {
            "VideoTrackClips": [
                {
                    "MediaId": "4bcf9b4d7cf14dc7b83b0e801cbe****",
                    "Out": 5
                }
            ]
        }
    ]
}

Cut out the end of a video

If you want to cut out the end of a video, specify only the start time. The following code provides an example on how to extract the last 10 seconds of a video:

{
    "VideoTracks": [
        {
            "VideoTrackClips": [
                {
                    "MediaId": "4bcf9b4d7cf14dc7b83b0e801cbe****",
                    "In": 10
                }
            ]
        }
    ]
}

Cut out the middle of a video

If you want to cut out the middle of a video, specify the start and end time. Sample code:

Notice
  • In indicates the start time and Out indicates the end time. The end time must be later than the start time. Otherwise, an error occurs.
  • If the value of Out exceeds the video duration, the end time of the video is used as the Out value.
{
    "VideoTracks": [
        {
            "VideoTrackClips": [
                {
                    "MediaId": "4bcf9b4d7cf14dc7b83b0e801cbe****",
                    "In": 5,
                    "Out": 10
                }
            ]
        }
    ]
}

Cut videos and merge multiple video parts

You can extract multiple parts from multiple videos and merge the extracted parts. The following sample code provides an example on how to merge two parts of 4bcf9b4d7cf14dc7b83b0e801cbe**** and one part of 789f9b4d7cf14dc7b83b0e801cbe**** based on the order of the array in sequence:

Note In indicates the start time and Out indicates the end time. The end time must be later than the start time. Otherwise, an error occurs.
{
    "VideoTracks": [
        {
            "VideoTrackClips": [
                {
                    "MediaId": "4bcf9b4d7cf14dc7b83b0e801cbe****",
                    "In": 12,
                    "Out": 16
                },{
                    "MediaId": "4bcf9b4d7cf14dc7b83b0e801cbe****",
                    "In": 4,
                    "Out": 7
                },{
                    "MediaId": "789f9b4d7cf14dc7b83b0e801cbe****",
                    "In": 12,
                    "Out": 20
                }
            ]
        }
    ]
}