tencent cloud

APIs

SimpleHlsClip

다운로드
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-09-18 15:59:32

1. API Description

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

Crop an HLS video by time period to generate a new HLS video in real time. Developers can share it immediately or save it for long-term preservation.

Tencent Cloud VOD supports two editing modes:
-Clip and save: Save the edited video as an independent video with a separate FileId. This is suitable for long-term preservation of highlights.
-Editing is not solidified: The edited video is attached to the input file with no standalone FileId, suitable for temporary sharing of highlight clips.

This API is used to crop an m3u8 file based on input. The minimum editing precision is one ts slice, so second-level or more precise editing precision cannot be achieved.

Edit solidification

Editing and solidification refers to saving an edited video as an independent video with an independent FileId. Its lifecycle is not subject to any impact from the original input video. Even if the original input video is deleted, the clipping result is not affected. You can also transcode it or publish it on WeChat.

For example, a complete football match raw video may last for over 2 hours. For cost savings, a customer can store this video for 2 months, but can specify longer storage for the edited "highlights" video. You can also separately transcode, publish on WeChat, and perform other additional on-demand operations on the "highlights" video. In this case, you can choose the edit and solidify solution.

The advantage of solidified edits is that their lifecycle is independent of the original input video, allowing separate management and long-term preservation.

Note: If solidification is specified when editing, enable reception of editing solidification event notifications through the ModifyEventConfig API. After successful solidification, you will receive a PersistenceComplete event notification. Before receiving this event notification, you should not delete or reduce the storage class of the original input video. Otherwise, playback of the generated video may be abnormal.

Editing is not solidified

Editing is not solidified, meaning the result of editing (m3u8 file) shares the same TS segments with the original input video. The generated video is not an independent and complete video (no standalone FileId, only a playback URL), and its valid period is consistent with that of the original input full video. Once the original input video is deleted, the clip will also become unplayable.

Editing is not solidified. Since the clipping result is not an independent video, it is not included in video management of on-demand media assets. For example, the total number of videos in the console does not include this video clip. You cannot separately perform any video processing operation on this clip, such as transcoding or publishing on WeChat.

The advantage of non-solidified editing is that the editing operation is relatively "lightweight" and will not generate additional storage overhead. However, its shortcoming is that the lifecycle is the same as the original recorded video, and it is unable to further transcode or perform other video processing.

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 Params. The value used for this API: SimpleHlsClip.
Version Yes String Common Params. The value used for this API: 2018-07-17.
Region No String Common Params. This parameter is not required.
Url Yes String

Tencent Cloud VOD HLS video URL that needs to be cropped.

SubAppId No Integer

On-demand application ID. Customers who activate on-demand services from December 25, 2023 must fill in this field with the app ID when accessing resources in on-demand applications (whether the default application or a newly created application).

StartTimeOffset No Float

Crop start offset time, in seconds. Default: 0, crop from the beginning of the video. Negative numbers indicate how many seconds from the end of the video to start cropping. For example, -10 means to start trimming from the 10th second from the end.

EndTimeOffset No Float

Crop end offset time, in seconds. Default: 0, which means crop to the end of the video. Negative numbers indicate how many seconds from the end of the video to end cropping. For example, -10 means end cropping at the 10th second from the end.

IsPersistence No Integer

Whether solidified. 0: non-permanent, 1: solidified. Default: non-permanent.

ExpireTime No String

Video storage expiry time after editing solidification. Format reference: ISO date format. Enter "9999-12-31T23:59:59Z" to indicate the video never expires. After expiry, the media file and its related resources (transcoding result, sprites, etc.) will be permanently deleted. Valid only when IsPersistence is 1. By default, the video after editing solidification never expires.

Procedure No String

Post-editing Solidified Video On-demand Task Flow Processing. For details, see upload specified task flow. Valid only when IsPersistence is 1.

ClassId No Integer

Category ID, used to categorize and manage media. You can create a category and obtain the category ID through the create category API.

  • Default value: 0, indicating other categories.
  • Valid only when IsPersistence is 1.
    SourceContext No String

    Source context. This is used to pass user request information. The upload completion callback returns the value of this field. The maximum length is 250 characters. Valid only when IsPersistence is 1.

    SessionContext No String

    Session context. This is used to pass user request information. After specifying the Procedure parameter, the task flow status change callback returns the value of this field. The maximum length is 1000 characters. Valid only when IsPersistence is 1.

    OutputMediaType No String

    Output video type. Valid values:

  • hls: output HLS file.
  • Default: hls.

    ExtInfo No String

    Reserved field, used when special usage. Example value: ""

    3. Output Parameters

    Parameter Name Type Description
    Url String

    Trimmed video address.

    MetaData MediaMetaData

    Cropped video metadata. Currently, the Size, Rotate, VideoDuration, and AudioDuration fields are temporarily default with no real data.

    FileId String

    Unique identifier of media file for post-editing solidified video.

    TaskId String

    Edited video task flow ID after solidification.

    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.

    4. Example

    Example1 Cropping HLS Video (Negative Time Offset)

    Trim from the 2nd second to the 10th second from the end

    Input Example

    POST / HTTP/1.1
    Host: vod.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: SimpleHlsClip
    <Common request parameters>
    
    {
        "Url": "http://example.com/xxxxx/aaaaaa/hhhh.m3u8",
        "StartTimeOffset": 2,
        "EndTimeOffset": 10
    }

    Output Example

    {
        "Response": {
            "Url": "http://example.com/xxxxx/aaaaaa/10_50.m3u8",
            "FileId": "",
            "TaskId": "",
            "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,
                        "CodecTag": "",
                        "DynamicRangeInfo": {
                            "Type": "",
                            "HDRType": ""
                        }
                    }
                ],
                "AudioStreamSet": [
                    {
                        "Bitrate": 29629,
                        "SamplingRate": 44100,
                        "Codec": "aac"
                    }
                ],
                "VideoDuration": 0,
                "AudioDuration": 0,
                "Md5": "Md5"
            },
            "RequestId": "12ae8d8e-dce3-4151-9d4b-5594145287e1"
        }
    }

    Example2 Crop an HLS Video (with Positive Time Offsets)

    Trim the video from the 2nd second to the 10th second.

    Input Example

    POST / HTTP/1.1
    Host: vod.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: SimpleHlsClip
    <Common request parameters>
    
    {
        "Url": "http://example.com/xxxxx/aaaaaa/hhh.m3u8",
        "StartTimeOffset": 2,
        "EndTimeOffset": 10
    }

    Output Example

    {
        "Response": {
            "Url": "http://example.com/xxxxx/aaaaaa/10_50.m3u8",
            "FileId": "",
            "TaskId": "",
            "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,
                        "CodecTag": "",
                        "DynamicRangeInfo": {
                            "Type": "",
                            "HDRType": ""
                        }
                    }
                ],
                "AudioStreamSet": [
                    {
                        "Bitrate": 29629,
                        "SamplingRate": 44100,
                        "Codec": "aac"
                    }
                ],
                "VideoDuration": 0,
                "AudioDuration": 0,
                "Md5": "Md5"
            },
            "RequestId": "12ae8d8e-dce3-4151-9d4b-5594145287e1"
        }
    }

    5. Developer Resources

    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 Operation failed.
    FailedOperation.InvalidVodUser The VOD service is not activated.
    InternalError Internal error.
    InvalidParameterValue Parameter value error.
    InvalidParameterValue.EndTimeOffset Parameter error: invalid end time.
    InvalidParameterValue.ExpireTime Parameter value error: Incorrect ExpireTime format.
    InvalidParameterValue.IsPersistence Parameter value error: incorrectly fixed parameters.
    InvalidParameterValue.OutputMediaType Parameter value error: Incorrect output media file type.
    InvalidParameterValue.Precision Parameter value error: incorrect precision parameter.
    InvalidParameterValue.Procedure Invalid parameter value: incorrect Procedure.
    InvalidParameterValue.StartTimeOffset Parameter error: invalid start time.
    InvalidParameterValue.Url Parameter error: Invalid Url.
    ResourceUnavailable.MasterPlaylist Parameter error: M3u8 of MasterPlaylist is not supported.
    UnauthorizedOperation Unauthorized operation.

    도움말 및 지원

    문제 해결에 도움이 되었나요?

    피드백