All Products
Search
Document Center

ApsaraVideo Media Processing:Set opening and ending scenes

Last Updated:Mar 06, 2024

ApsaraVideo Media Processing (MPS) allows you to add an opening scene at the beginning of your video in picture-in-picture (PiP) mode and an ending scene at the end of your video with transition effects. Opening and ending scenes are video clips in which you present important information. This topic describes how to set opening and ending scenes in MPS.

Parameter description

When you set opening and ending scenes, take note of the following parameters:

  • Input

    The video to which you want to add opening and ending scenes and the Object Storage Service (OSS) bucket in which the video is stored.

    Note

    The Location parameter specifies the region in which the OSS bucket that stores the input file resides. The value of the Location parameter must match the region in which you activate MPS. For example, if the endpoint of your MPS service is mts.cn-hangzhou.aliyuncs.com, you must set the Location parameter to oss-cn-hangzhou.

  • Output

    Take note of the following parameters when you configure a job output:

    • Video

      The information about the output file, such as the width, height, and bitrate. If the aspect ratio of the input video differs from the output aspect ratio, the images in the output video are stretched. We recommend that you specify only the output width or height. The unspecified dimension is automatically scaled based on the aspect ratio of the input video.

    • OpeningList

      The list of video clips to be merged into the opening scene. The video clips are merged in the same sequence specified in the list. You can specify up to two video clips.

      Specify the following four parameters for each video clip:

      • OpenUrl

        The OSS path of the video clip.

        Note

        The video clip must reside in the same OSS region as the input video. You cannot merge videos across regions.

      • Start

        The duration that elapses after the input video is played before the video clip is played. The value starts from 0. Unit: seconds. Default value: 0.

      • Width

        The width of the video clip. Valid values:

        • -1: the original width of the video clip.

        • Full: The width of the video clip equals the width of the main part.

        • Custom width: You can customize the width of the video clip. Valid values: [0,4096].

          Note

          The video clip is center-aligned based on the central point of the main part. The width of the video clip must be equal to or less than the width of the main part. Otherwise, the opening scene may not be displayed as expected.

      • Height

        The height of the video clip. Valid values:

        • -1: the original height of the video clip.

        • full: The height of the video clip equals the height of the main part.

        • Custom height: You can customize the height of the video clip. Valid values: [0,4096].

          Note

          The video clip is center-aligned based on the central point of the main part. The height of the video clip must be equal to or less than the height of the main part. Otherwise, the opening scene may not be displayed as expected.

    • TailSlateList

      The list of video clips to be merged into the ending scene. The video clips are merged in the same sequence specified in the list. You can specify up to two video clips.

      Specify the following parameters for each video clip:

      • TailUrl

        The OSS path of the video clip.

        Note

        The video clip must reside in the same OSS region as the input video. You cannot merge videos across regions.

      • Width

        The width of the video clip. Valid values:

        • -1: the original width of the video clip.

        • full: The width of the video clip equals the width of the main part.

        • Custom width: You can customize the width of the video clip. Valid values: [0,4096]

          Note

          The video clip is center-aligned based on the central point of the main part. The width of the video clip must be equal to or less than the width of the main part. Otherwise, the ending scene may not be displayed as expected.

      • Height

        The height of the video clip. Valid values:

        • -1: the original height of the video clip.

        • full: The height of the video clip equals the height of the main part.

        • Custom height: You can customize the height of the video clip. Valid values: [0,4096].

          Note

          The video clip is center-aligned based on the central point of the main part. The height of the video clip must be equal to or less than the height of the main part. Otherwise, the ending scene may not be displayed as expected.

      • BlendDuration

        The duration of the transition between the main part and the video clip. During the transition, the last frame of the main part fades out, and the first frame of the video clip fades in. Unit: seconds. Default value: 0.

      • IsMergeAudio

        Specifies whether to merge the audio content of the video clip.

      • BgColor

        The color of the bars added to the video clip if the width or height of the clip is less than that of the main part.

Example

Add opening and ending scenes to a video whose resolution is 1280 x 720 pixels. The opening and ending parts are MP4 files whose resolutions are 640 x480 pixels. The opening scene is displayed 2 seconds after the output video starts to play. The transition duration between the main part and the ending scene is 3 seconds. The color of the bars added to the ending scene is black. After you complete the settings, the opening scene is displayed in PiP mode on the main part at the 00:00:02 time point while the main part continues to play. When the main part comes to an end and fades out, the ending scene fades in and then fades out.

For information about the sample code to set opening and ending scenes by using MPS SDKs for different programming languages, see the following topics: