SimpleHlsClip

Last updated: 2020-08-14 09:41:57

1. API Description

Domain name for API request: vod.tencentcloudapi.com.

This API is used to clip an HLS video by time period.

Note: the clipped video shares the same ts segments with the source video, and only a new m3u8 file will be generated. Deleting the source video will also delete the clipped video.

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: 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.
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
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.
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example

Example1 Clipping an HLS video (with time offset being negative)

This example shows you how to clip a video from the 2nd second to the 10th second from the end.

Input Example

https://vod.tencentcloudapi.com/?Action=SimpleHlsClip
&Url=http://xxxxx.vod2.myqcloud.com/xxxxx/aaaaaa/hhhh.m3u8
&StartTimeOffset=2
&EndTimeOffset=-10
&<Common request parameters>

Output Example

{
  "Response": {
    "Url": "http://xxxxx.vod2.myqcloud.com/xxxxx/aaaaaa/10_50.m3u8",
    "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"
  }
}

Example2 Clipping an HLS video (with time offset being positive)

This example shows you how to clip the 2nd to 10th seconds of a video.

Input Example

https://vod.tencentcloudapi.com/?Action=SimpleHlsClip
&Url=http://xxxxx.vod2.myqcloud.com/xxxxx/aaaaaa/hhh.m3u8
&StartTimeOffset=2
&EndTimeOffset=10
&<Common request parameters>

Output Example

{
  "Response": {
    "Url": "http://xxxxx.vod2.myqcloud.com/xxxxx/aaaaaa/10_50.m3u8",
    "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"
  }
}

5. Developer Resources

API Explorer

This tool allows online call, signature authentication, SDK code generation and quick search of APIs to greatly improve the efficiency of using TencentCloud APIs.

SDK

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.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?

Was this page helpful?

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