Domain name for API request: vod.tencentcloudapi.com.
This API is used to compose a media file. You can use it to do the following:
The output file is in MP4 or MP3 format. In the callback for media composition, the event type is ComposeMediaComplete.
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 Params. The value used for this API: ComposeMedia. |
Version | Yes | String | Common Params. The value used for this API: 2018-07-17. |
Region | No | String | Common Params. This parameter is not required. |
Tracks.N | Yes | Array of MediaTrack | List of input media tracks, including video, audio, and image tracks. |
Output | Yes | ComposeMediaOutput | Information of output media file. |
SubAppId | No | Integer | The VOD application ID. For customers who activate VOD service from December 25, 2023, if they want to access resources in a VOD application (whether it's the default application or a newly created one), they must fill in this field with the application ID. |
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. |
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, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem. |
Eliminate the original audio of 5285485487985271487, use 5285485487985271488 for dubbing starting from 5 seconds, use 2 to 16 seconds of 5285485487985271489 starting from 20 seconds for dubbing, and generate a new video.
POST / HTTP/1.1
Host: vod.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: ComposeMedia
<Public request parameters>
{
"Output": {
"Container": "mp4",
"FileName": "test"
},
"Tracks": [
{
"TrackItems": [
{
"Type": "Empty",
"EmptyItem": {
"Duration": "5"
}
},
{
"AudioItem": {
"SourceMedia": "5285485487985271488",
"Duration": "15"
},
"Type": "Audio"
},
{
"AudioItem": {
"Duration": "14",
"SourceMedia": "5285485487985271489",
"SourceMediaStartTime": "2"
},
"Type": "Audio"
}
],
"Type": "Audio"
},
{
"TrackItems": [
{
"Type": "Video",
"VideoItem": {
"SourceMedia": "5285485487985271487",
"AudioOperations": [
{
"VolumeParam": {
"Mute": "1"
},
"Type": "Volume"
}
]
}
}
],
"Type": "Video"
}
]
}
{
"Response": {
"RequestId": "6ca31e3a-6b8e-4b4e-9256-fdc700064ef3",
"TaskId": "125xxx65-ComposeMedia-bffb15f07530b57bc1aabb01fac74bca"
}
}
Take the 2nd to 62nd second of 5285485487985271487 and the 6th to 81st second of 5285485487985271488 for splicing. Set a 5-second fade-in and fade-out transition in the middle. Paste a picture 5285485487985271489 from 3 seconds to 18 seconds of the video. The position is (20px , 20px), width and height (100px, 100px).
POST / HTTP/1.1
Host: vod.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: ComposeMedia
<Public request parameters>
{
"Output": {
"Container": "mp4",
"FileName": "test"
},
"Tracks": [
{
"TrackItems": [
{
"StickerItem": {
"CoordinateOrigin": "TopLeft",
"XPos": "20px",
"YPos": "20px",
"Height": "100px",
"Width": "100px",
"StartTime": "3",
"Duration": "15",
"SourceMedia": "5285485487985271489"
},
"Type": "Sticker"
}
],
"Type": "Sticker"
},
{
"TrackItems": [
{
"TransitionItem": {
"Duration": "5",
"MediaTransitions": [
{
"Type": "ImageFadeInFadeOut"
}
]
},
"Type": "Transition"
},
{
"Type": "Video",
"VideoItem": {
"Duration": "60",
"SourceMedia": "5285485487985271487",
"SourceMediaStartTime": "2"
}
},
{
"Type": "Video",
"VideoItem": {
"Duration": "75",
"SourceMedia": "5285485487985271488",
"SourceMediaStartTime": "6"
}
}
],
"Type": "Video"
}
]
}
{
"Response": {
"RequestId": "6ca31e3a-6b8e-4b4e-9256-fdc700064ef3",
"TaskId": "125xxx65-ComposeMedia-bffb15f07530b57bc1aabb01fac74bc2"
}
}
Use the video of 5285485487985271487 as the main picture of the picture-in-picture; use the video of 5285485487985271488 as the sub-picture of the picture-in-picture; the center of the sub-picture is offset by 25% of the main picture (that is, in the lower right corner of the main picture), and the width accounts for 30% of the picture.
POST / HTTP/1.1
Host: vod.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: ComposeMedia
<Public request parameters>
{
"Output": {
"Container": "mp4",
"FileName": "test"
},
"Tracks": [
{
"TrackItems": [
{
"Type": "Video",
"VideoItem": {
"CoordinateOrigin": "Center",
"Width": "30%",
"SourceMedia": "5285485487985271488",
"XPos": "25%",
"YPos": "25%"
}
}
],
"Type": "Video"
},
{
"TrackItems": [
{
"Type": "Video",
"VideoItem": {
"SourceMedia": "5285485487985271487"
}
}
],
"Type": "Video"
}
]
}
{
"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.SessionContextTooLong | SessionContext is too long. |
InvalidParameterValue.SessionId | The deduplication ID already exists. The request is removed due to duplication. |
UnauthorizedOperation | Unauthorized operation. |
本页内容是否解决了您的问题?