MPS supports merging multiple videos into a single output, merging clips of recorded live streams, and extracting clips from a video. Use the merging feature to combine videos of different formats, codecs, and resolutions into a unified output. Use the clipping feature to extract a time range from a video and save it as a new file.
Merge videos
Set the following parameters to configure a video merging job:
-
The start part to merge and the OSS bucket where it is stored.
NoteThe Location parameter specifies the region where the OSS bucket resides. This value must match the region where MPS is activated. For example, if your MPS endpoint is mts.cn-hangzhou.aliyuncs.com, set Location to oss-cn-hangzhou.
-
Set the following parameters for the job output:
-
Video
The output video properties, such as width, height, and bitrate. If the aspect ratios of the videos to be merged, including the start and end parts, differ from the output aspect ratio, MPS automatically adds black bars to fill the frame. Prepare start and end parts in multiple aspect ratios to match different output resolutions.
-
MergeList
The list of videos to merge, processed in the order specified. The last entry in the list is the end part. Supports up to five videos, including the start and end parts. To merge more than five videos, use
MergeConfigUrlinstead.NoteSpecify only one of MergeList and
MergeConfigUrl.Each entry in MergeList takes the following parameters:
-
MergeURL
The OSS path of the video to merge.
NoteAll videos in the merge job must be in the same OSS region as the start part. Cross-region merging is not supported.
-
Start
The start point of the segment to merge. Set this parameter to merge only part of a video. Default value: 0.
-
Duration
The duration of the segment to merge, measured from the Start point. Set this parameter to merge only part of a video. By default, the segment runs from the Start point to the end of the video.
-
-
MergeConfigUrl
The OSS URL of a JSON configuration file for the merge job. The file content follows the same schema as the
MergeListparameter.NoteVideos are merged in the order specified in the configuration file. The last entry is the end part. Supports up to 100 videos, including the start and end parts.
-
Extract a video clip
Set the following parameters to extract a clip from a video:
-
The source video and the OSS bucket where it is stored.
NoteThe Location parameter specifies the region where the OSS bucket resides. This value must match the region where MPS is activated. For example, if your MPS endpoint is mts.cn-hangzhou.aliyuncs.com, set Location to oss-cn-hangzhou.
-
Set the following parameters for the job output:
-
TimeSpan
The time range of the clip to extract. Defines where the clip starts and how long it runs.
Set the following parameters to define the time span:
-
Seek
The point in time where the clip starts.
-
Duration
The length of the clip.
-
End
The length of the trailing portion of the original video to remove.
NoteIf End is specified, Duration is ignored.
-
-
ConfigToClipFirstPart
Controls whether clipping is applied before or after merging. Set to true to clip the first part of the videos before merging. Set to false to merge the inputs first, then clip the output. Default value: false.
-
Example
Add start and end parts whose resolution is 640 × 480 pixels to a video whose resolution is 1280 × 720 pixels to produce an MP4 video whose resolution is 1280 × 720 pixels. The start and end parts are letterboxed with black bars on the left and right. The main video is normally displayed.
For sample code in different programming languages, see: