Domain name for API request: vod.tencentcloudapi.com.
This API is used to compose a media file, including:
A maximum of 100 requests can be initiated per second for this API.
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. |
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. |
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. |
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).
https://vod.tencentcloudapi.com/?Action=ComposeMedia
&Tracks.0.Type=Video
&Tracks.0.TrackItems.0.Type=Video
&Tracks.0.TrackItems.0.VideoItem.SourceMedia=5285485487985271487
&Tracks.0.TrackItems.0.VideoItem.SourceMediaStartTime=2
&Tracks.0.TrackItems.0.VideoItem.Duration=60
&Tracks.0.TrackItems.1.Type=Transition
&Tracks.0.TrackItems.1.TransitionItem.Duration=5
&Tracks.0.TrackItems.1.TransitionItem.TransitionOperations.0.Type=ImageFadeInFadeOut
&Tracks.0.TrackItems.2.Type=Video
&Tracks.0.TrackItems.2.VideoItem.SourceMedia=5285485487985271488
&Tracks.0.TrackItems.2.VideoItem.SourceMediaStartTime=6
&Tracks.0.TrackItems.2.VideoItem.Duration=75
&Tracks.1.Type=Sticker
&Tracks.1.TrackItems.0.Type=Sticker
&Tracks.1.TrackItems.0.StickerItem.SourceMedia=5285485487985271489
&Tracks.1.TrackItems.0.StickerItem.StartTime=3
&Tracks.1.TrackItems.0.StickerItem.Duration=15
&Tracks.1.TrackItems.0.StickerItem.CoordinateOrigin=TopLeft
&Tracks.1.TrackItems.0.StickerItem.XPos=20px
&Tracks.1.TrackItems.0.StickerItem.YPos=20px
&Tracks.1.TrackItems.0.StickerItem.Width=100px
&Tracks.1.TrackItems.0.StickerItem.Height=100px
&Output.FileName=test
&Output.Container=mp4
&<Common request parameters>
{
"Response": {
"RequestId": "6ca31e3a-6b8e-4b4e-9256-fdc700064ef3",
"TaskId": "125xxx65-ComposeMedia-bffb15f07530b57bc1aabb01fac74bc2"
}
}
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.
https://vod.tencentcloudapi.com/?Action=ComposeMedia
&Tracks.0.Type=Video
&Tracks.0.TrackItems.0.Type=Video
&Tracks.0.TrackItems.0.VideoItem.SourceMedia=5285485487985271487
&Tracks.0.TrackItems.0.VideoItem.AudioOperations.0.Type=Volume
&Tracks.0.TrackItems.0.VideoItem.AudioOperations.0.VolumeParam.Mute=1
&Tracks.1.Type=Audio
&Tracks.1.TrackItems.0.Type=Empty
&Tracks.1.TrackItems.0.EmptyItem.Duration=5
&Tracks.1.TrackItems.1.Type=Audio
&Tracks.1.TrackItems.1.AudioItem.SourceMedia=5285485487985271488
&Tracks.1.TrackItems.1.AudioItem.Duratiion=15
&Tracks.1.TrackItems.2.Type=Audio
&Tracks.1.TrackItems.2.AudioItem.SourceMedia=5285485487985271489
&Tracks.1.TrackItems.2.AudioItem.SourceMediaStartTime=2
&Tracks.1.TrackItems.2.AudioItem.Duration=14
&Output.FileName=test
&Output.Container=mp4
&<Common request parameters>
{
"Response": {
"RequestId": "6ca31e3a-6b8e-4b4e-9256-fdc700064ef3",
"TaskId": "125xxx65-ComposeMedia-bffb15f07530b57bc1aabb01fac74bca"
}
}
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.
https://vod.tencentcloudapi.com/?Action=ComposeMedia
&Tracks.0.Type=Video
&Tracks.0.TrackItems.0.Type=Video
&Tracks.0.TrackItems.0.VideoItem.SourceMedia=5285485487985271487
&Tracks.1.Type=Video
&Tracks.1.TrackItems.0.Type=Video
&Tracks.1.TrackItems.0.VideoItem.SourceMedia=5285485487985271488
&Tracks.1.TrackItems.0.VideoItem.CoordinateOrigin=Center
&Tracks.1.TrackItems.0.VideoItem.XPos=25%
&Tracks.1.TrackItems.0.VideoItem.YPos=25%
&Tracks.1.TrackItems.0.VideoItem.Width=30%
&Output.FileName=test
&Output.Container=mp4
&<Common request parameters>
{
"Response": {
"RequestId": "6ca31e3a-6b8e-4b4e-9256-fdc700064ef3",
"TaskId": "125xxx65-ComposeMedia-bffb15f07530b57bc1aabb01fac74bca"
}
}
TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.
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?