tencent cloud

云点播

SimpleHlsClip

Download
聚焦模式
字号
最后更新时间: 2026-05-19 15:01:26

1. API Description

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

This API is used to crop an HLS video by time period and generate a new real-time HLS video. Developers can share it immediately or preserve it for long-term.

Tencent Cloud Video on Demand (VOD) supports two editing modes:
-Edit and save: Save the edited video as an independent video with a standalone FileId. Suitable for scenarios requiring long-term preservation of highlight clips.
-Editing is not solidified: The video obtained by editing is attached to the input file with no standalone FileId. It is suitable for scenarios where highlight clips are temporarily shared.

This API is used to crop based on input m3u8 files, with a minimum editing precision of a ts slice. Second-level or more precise editing precision cannot be achieved.

Edit solidification

Video clipping persistence refers to saving an edited video as an independent video (with an independent FileId). Its lifecycle is not subject to the original input video (even if the original input video is deleted, the clipping result will not have any impact). It can also be post-processed, such as transcoding or publishing on WeChat.

For example, a complete football match may last for over 2 hours. To save costs, the customer can store the original video for 2 months, but may choose to store the highlight reel for longer. You can also transcode the highlight reel, publish it on WeChat, and perform additional on-demand operations. In this case, you can choose the edit and save solution.

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

Note: If you specify solidification when editing, enable reception of editing solidification event notifications via the ModifyEventConfig API. After successful solidification, you will receive a PersistenceComplete event notification. Before receiving this event notification, you should not delete or downgrade the original input video, otherwise exceptions may occur during playback of the generated video.

Editing is not solidified

Non-solidified editing means 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 (it has 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, it will lead to the video clip being unable to play.

Editing is not solidified. Since the clipping result is not an independent video, it will not be included in video management of on-demand media assets (for example, the total number of videos in the console will not count this video clip) and cannot be targeted for any video processing operations such as transcoding or publishing on WeChat.

The advantage of editing not being solidified is that the editing operation is relatively lightweight and will not generate additional storage overhead. However, the shortcoming is that its lifecycle is the same as the original recorded video, and it is unable to further transcode or perform 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 this field with the app ID when accessing resources in on-demand applications (whether default or newly created).
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 start trimming from 10 seconds before the end.
EndTimeOffset No Float Crop end offset time in seconds. Default is 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 10 seconds before the end.
IsPersistence No Integer Whether solidified. 0: not solidified, 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) will be permanently deleted. Valid at that time only when IsPersistence is 1. The default video editing never expires.
Procedure No String Post-editing Solidified Video On-demand Task Flow Processing. For details, see upload specified task flow (https://www.tencentcloud.com/document/product/266/9759?from_cn_redirect=1). 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 via the create category API.
  • Default value: 0, indicating other categories.

  • Valid when IsPersistence is 1.
    SourceContext No String Source context, used to pass through user request information. The callback on upload completion will return the value of this field, up to 250 characters. Valid when IsPersistence is 1.
    SessionContext No String Session context, used to pass through user request information. When specifying the Procedure parameter, the task flow status change callback will return the value of this field, up to 1000 characters. Valid only when IsPersistence is 1.
    OutputMediaType No String Output video type. Valid values:
  • hls: Output hls file.
  • Default value hls.
    ExtInfo No String Reserved field, used when special purpose. 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 the 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 Trimming HLS Video (Time Offset Is a Negative Value)

    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.0,
        "EndTimeOffset": 10.0
    }
    

    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.0,
                "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.0,
                "AudioDuration": 0.0,
                "Md5": "Md5"
            },
            "RequestId": "12ae8d8e-dce3-4151-9d4b-5594145287e1"
        }
    }
    

    Example2 Trimming HLS Video (Time Offset Is Positive Number)

    Trim video from the 2nd 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.0,
        "EndTimeOffset": 10.0
    }
    

    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.0,
                "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.0,
                "AudioDuration": 0.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 Incorrect parameter: the end time is invalid.
    InvalidParameterValue.ExpireTime Incorrect parameter value: 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 Parameter value error: Incorrect Procedure.
    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.

    帮助和支持

    本页内容是否解决了您的问题?

    填写满意度调查问卷,共创更好文档体验。

    文档反馈