Last updated: 2021-02-23 16:18:52

1. API Description

Domain name for API request:

This API is used to compose a media file, including:

  1. Clipping a media file to generate a new media file;
  2. Clipping and splicing multiple media files to generate a new media file;
  3. Clipping and splicing the media streams of multiple media files to generate a new media file;

A maximum of 100 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common parameter. The value used for this API: ComposeMedia.
Version Yes String Common parameter. The value used for this API: 2018-07-17.
Region No String Common parameter. This parameter is not required for this API.
Tracks.N Yes Array of MediaTrack List of input media tracks, i.e., information of multiple tracks composed of video, audio, image, and other materials.
  • Multiple input tracks are aligned with the output media file on the time axis.
  • The materials of each track at the same time point on the time axis will be superimposed. Specifically, videos or images will be superimposed for video image by track order, where a material with a higher track order will be more on top, while audio materials will be mixed.
  • Up to 10 tracks are supported for each type (video, audio, or image).
  • Output Yes ComposeMediaOutput Information of output media file.
    Canvas No Canvas Canvas used for composing video file.
    SessionContext No String Used to pass through user request information. ComposeMediaComplete callback will return the value of this parameter. It contains up to 1,000 characters.
    SessionId No String Used to identify duplicate requests. After you send a request, if any request with the same SessionId has already been sent in the last three days (72 hours), an error message will be returned. SessionId contains up to 50 characters. If this parameter is not carried or is an empty string, no deduplication will be performed.
    SubAppId No Integer Subapplication ID in VOD. If you need to access a resource in a subapplication, enter the subapplication ID in this field; otherwise, leave it empty.

    3. Output Parameters

    Parameter Name Type Description
    TaskId String Media file composing task ID, which can be used to query the status of composing task (with task type being MakeMedia).
    RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    4. Example

    Example1 Clipping two video streams and splicing the clips

    This example shows you how to splice the 2nd to 62nd seconds of 5285485487985271487 and the 6th to 81st seconds of 5285485487985271488, set a fade-in/fade-out transition of 5 seconds in between, and add image 5285485487985271489 with width and height of (100px, 100px) between the 3rd and 18th seconds of the video at the position of (20px, 20px).

    Input Example
    &<Common request parameters>

    Output Example

      "Response": {
        "RequestId": "6ca31e3a-6b8e-4b4e-9256-fdc700064ef3",
        "TaskId": "125xxx65-ComposeMedia-bffb15f07530b57bc1aabb01fac74bc2"

    Example2 Dubbing a VOD video

    This example shows you how to remove the original audio from 5285485487985271487, dub it starting from the 5th second with 5285485487985271488, and dub it starting from the 20th second with the 2nd to 16th seconds of 5285485487985271489 to generate a new VOD video.

    Input Example
    &<Common request parameters>

    Output Example

      "Response": {
        "RequestId": "6ca31e3a-6b8e-4b4e-9256-fdc700064ef3",
        "TaskId": "125xxx65-ComposeMedia-bffb15f07530b57bc1aabb01fac74bca"

    Example3 Playing two videos in picture-in-picture mode

    This example shows you how to use video 5285485487985271487 as the primary image and video 5285485487985271488 as the subimage in picture-in-picture mode, with their centers offset by 25% (i.e., the subimage is displayed in the bottom-right corner of the primary image), and the width of the subimage set to 30% of the primary image.

    Input Example
    &<Common request parameters>

    Output Example

      "Response": {
        "RequestId": "6ca31e3a-6b8e-4b4e-9256-fdc700064ef3",
        "TaskId": "125xxx65-ComposeMedia-bffb15f07530b57bc1aabb01fac74bca"

    5. Developer Resources


    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    FailedOperation Operation failed.
    FailedOperation.InvalidVodUser The VOD service is not activated.
    FailedOperation.UploadCosFail Operation failed: failed to upload file to COS.
    InternalError Internal error.
    InternalError.GetFileInfoError Internal error: an error occurred while getting media file information.
    InternalError.GetMediaListError Internal error: an error occurred while getting the media list.
    InvalidParameter Invalid parameter.
    InvalidParameterValue.ClipDuration Incorrect parameter value: the clipping duration is too long.
    InvalidParameterValue.SessionId The deduplication ID already exists. The request is removed due to duplication.
    UnauthorizedOperation Unauthorized operation.

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback