Domain name for API request: vod.tencentcloudapi.com.
This API is used to clip an HLS video by time period and then generate a new HLS video which developers can share right away or store persistently.
VOD supports two types of clipping:
FileId
.FileId
.Notes:
In this mode, a video clip is saved as an independent video file with a FileId
, and its lifecycle is not subject to the input video. Even if the source video is deleted, the video clip still exists. Moreover, the video clip can be transcoded, published on WeChat, and processed in other ways.
Take the video of a two-hour long football match for example. The customer may only want to store the original two-hour video for two months to save costs, but want to store clipped highlights for a specified longer time and also to transcode and publish such highlights on WeChat. Clipping for persistent storage is suitable for this customer.
The advantage of clipping for persistent storage is that the video clip has a lifecycle independent of the input video and can be managed independently and stored persistently.
The video clip (an M3U8 file) shares the same TS segments with the input video instead of being an independent video. It only has a playback URL but has no FileId
, and its validity period is the same as that of the input video. Once the input video is deleted, the video clip cannot be played back.
As the video clip is not an independent video, it will not be managed as a VOD media asset. For example, it will not be counted in the total videos displayed on the VOD console, and also cannot be transcoded or published on WeChat.
Clipping for temporary sharing is lightweight and incurs no additional storage fees. However, the video clip has the same lifecycle as the source recording video and cannot be transcoded or processed in other ways.
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: SimpleHlsClip. |
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. |
Url | Yes | String | URL of the HLS video in VOD that needs to be clipped. |
StartTimeOffset | No | Float | Start offset time of clipping in seconds. Default value: 0, which means to clip from the beginning of the video. A negative number indicates how many seconds from the end of the video clipping will start at. For example, -10 means that clipping will start at the 10th second from the end. |
EndTimeOffset | No | Float | End offset time of clipping in seconds. Default value: 0, which means to clip till the end of the video. A negative number indicates how many seconds from the end of the video clipping will end. For example, -10 means that clipping will end at the 10th second from the end. |
IsPersistence | No | Integer | Whether to store the video clip persistently. 0: no (default), 1: yes. |
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 |
---|---|---|
Url | String | Address of clipped video. |
MetaData | MediaMetaData | Metadata of clipped video. Currently, Size , Rotate , VideoDuration , and AudioDuration fields use default value with no actual data. |
FileId | String | Unique ID of a video clip for persistent storage. |
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 clip a video from the 2nd to the 10th second.
https://vod.tencentcloudapi.com/?Action=SimpleHlsClip
&Url=http://xxxxx.vod2.myqcloud.com/xxxxx/aaaaaa/hhh.m3u8
&StartTimeOffset=2
&EndTimeOffset=10
&<Common request parameters>
{
"Response": {
"Url": "http://xxxxx.vod2.myqcloud.com/xxxxx/aaaaaa/10_50.m3u8",
"FileId": "",
"MetaData": {
"Size": 0,
"Container": "hls",
"Bitrate": 622014,
"Height": 480,
"Width": 640,
"Duration": 48,
"Rotate": 0,
"VideoStreamSet": [
{
"Bitrate": 592385,
"Height": 480,
"Width": 640,
"Codec": "h264",
"Fps": 25
}
],
"AudioStreamSet": [
{
"Bitrate": 29629,
"SamplingRate": 44100,
"Codec": "aac"
}
],
"VideoDuration": 0,
"AudioDuration": 0
},
"RequestId": "12ae8d8e-dce3-4151-9d4b-5594145287e1"
}
}
This example shows you how to clip a video from the 2nd second to the 10th second from the end.
https://vod.tencentcloudapi.com/?Action=SimpleHlsClip
&Url=http://xxxxx.vod2.myqcloud.com/xxxxx/aaaaaa/hhhh.m3u8
&StartTimeOffset=2.0
&EndTimeOffset=10.0
&<Common request parameters>
{
"Response": {
"Url": "http://xxxxx.vod2.myqcloud.com/xxxxx/aaaaaa/10_50.m3u8",
"FileId": "",
"MetaData": {
"Size": 0,
"Container": "hls",
"Bitrate": 622014,
"Height": 480,
"Width": 640,
"Duration": 48,
"Rotate": 0,
"VideoStreamSet": [
{
"Bitrate": 592385,
"Height": 480,
"Width": 640,
"Codec": "h264",
"Fps": 25
}
],
"AudioStreamSet": [
{
"Bitrate": 29629,
"SamplingRate": 44100,
"Codec": "aac"
}
],
"VideoDuration": 0,
"AudioDuration": 0
},
"RequestId": "12ae8d8e-dce3-4151-9d4b-5594145287e1"
}
}
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. |
InternalError | Internal error. |
InvalidParameterValue | Incorrect parameter value. |
InvalidParameterValue.EndTimeOffset | Incorrect parameter: the end time is invalid. |
InvalidParameterValue.StartTimeOffset | Incorrect parameter: the start time is invalid. |
InvalidParameterValue.Url | Incorrect parameter: the URL is invalid. |
ResourceUnavailable.MasterPlaylist | Incorrect parameter: M3U8 of MasterPlaylist is not supported. |
UnauthorizedOperation | Unauthorized operation. |
Was this page helpful?