All Products
Search
Document Center

Cutting and merging

Last Updated: Jul 11, 2019

Overview

We have introduced video editing, its overall process, and the two methods of using the media editing service in Overview. Media editing is essentially initiated and implemented by the media editing service. The timeline is the key data processed by the media editing service and also the core object in video editing. The internal parameters of the timeline can be organized in multiple ways to cope with different business scenarios.

Examples

The following examples show how timeline data is organized for basic video cutting and merging.

Merge multiple videos entirely

This action merges multiple videos as a whole in sequence. You do not need to set the start or end time for merging the videos. For example:

  1. {
  2. "VideoTracks": [
  3. {
  4. "VideoTrackClips": [
  5. {
  6. "MediaId": "4bcf9b4d7cf14dc7b83b0e801cbe1ce6"
  7. },
  8. {
  9. "MediaId": "789f9b4d7cf14dc7b83b0e801cbe1a12"
  10. }
  11. ]
  12. }
  13. ]
  14. }

Cut a video with the starting part retained

This action does not require specifying the start time for cutting a video. The video is cut from the very beginning by default. You only need to specify the end time for cutting the video. The following example describes how to extract the first 5 seconds of a video:

  1. {
  2. "VideoTracks": [
  3. {
  4. "VideoTrackClips": [
  5. {
  6. "MediaId": "4bcf9b4d7cf14dc7b83b0e801cbe1ce6",
  7. "Out": 5
  8. }
  9. ]
  10. }
  11. ]
  12. }

Cut a video with the ending part retained

This action does not require specifying the end time for cutting a video. The video is cut to the very end by default. You only need to specify the start time for cutting the video. The following example describes how to extract the last 10 seconds of a video:

  1. {
  2. "VideoTracks": [
  3. {
  4. "VideoTrackClips": [
  5. {
  6. "MediaId": "4bcf9b4d7cf14dc7b83b0e801cbe1ce6",
  7. "In": 10
  8. }
  9. ]
  10. }
  11. ]
  12. }

Cut a video with the middle part retained

This action requires specifying the start time (the In parameter) and end time (the Out parameter) for cutting a video. Only the part between the start time and end time is retained.

Note: If the Out value exceeds the video duration, the video duration is used as the actual Out value.

  1. {
  2. "VideoTracks": [
  3. {
  4. "VideoTrackClips": [
  5. {
  6. "MediaId": "4bcf9b4d7cf14dc7b83b0e801cbe1ce6",
  7. "In": 5,
  8. "Out": 10
  9. }
  10. ]
  11. }
  12. ]
  13. }

Merge any parts of multiple videos

This action extracts multiple parts from multiple videos and merges the extracted parts. The following example describes how to extract two clips from video 4bcf9b4d7cf14dc7b83b0e801cbe1ce6 and one clip from video 789f9b4d7cf14dc7b83b0e801cbe1a23 and merge the extracted clips based on the sequence specified in the array:

  1. {
  2. "VideoTracks": [
  3. {
  4. "VideoTrackClips": [
  5. {
  6. "MediaId": "4bcf9b4d7cf14dc7b83b0e801cbe1ce6",
  7. "In": 12,
  8. "Out": 16
  9. },{
  10. "MediaId": "4bcf9b4d7cf14dc7b83b0e801cbe1ce6",
  11. "In": 4,
  12. "Out": 7
  13. },{
  14. "MediaId": "789f9b4d7cf14dc7b83b0e801cbe1a23",
  15. "In": 12,
  16. "Out": 20
  17. }
  18. ]
  19. }
  20. ]
  21. }