tencent cloud

文档反馈

LiveRealTimeClip

最后更新时间:2024-03-27 16:08:24

    1. API Description

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

    Live broadcast real-time editing means that during the live broadcast process (that is, before the live broadcast has ended), customers can select a section of past live broadcast content to generate a new video (HLS format) in real time. Developers can share it immediately, or permanently Save it.

    Tencent Cloud VOD supports two real-time editing modes:

    • Editing and solidification: Save the edited video as an independent video with an independent FileId; suitable for scenes where the highlight clips are saved for a long time;
    • Editing is not solidified: the edited video is attached to the live broadcast recording file and does not have an independent FileId; it is suitable for scenarios where highlight clips are temporarily shared.

    Notice:

    • The prerequisite for using the live broadcast real-time editing function is that the target live stream has the Time Shift Replay function enabled.
    • Live broadcast real-time editing is based on the m3u8 file generated by live broadcast recording, so its minimum editing accuracy is one ts slice, and it is impossible to achieve second-level or more precise editing accuracy.
    • Since the stream may be interrupted during the live broadcast, the actual video duration generated by editing may be inconsistent with expectations. For example, the time interval for editing a live stream is from 2018-09-20T10:30:00Z to 2018-09-20T10:40:00Z. If the stream is interrupted during this time interval, the duration of the returned media asset file will be Less than 10 minutes, in which case it can be sensed via the output parameter SegmentSet.

    Clip solidification

    Clip solidification means saving the clipped video into an independent video (with an independent FileId). Its life cycle is not affected by the original live broadcast recording video (even if the original recording video is deleted, the editing results will not be affected in any way); it can also be subjected to secondary processing such as transcoding.

    For example: for a complete football match, the original video recorded live may be as long as 2 hours. To save costs, the customer can store this video for 2 months, but for the "highlight moment" video that is edited in real time during the live broadcast However, you can specify a longer storage period, and at the same time, you can separately transcode the "highlight moments" video and other on-demand operations. At this time, you can choose the solution of real-time editing and solidification of the live broadcast.

    The advantage of editing and curing is that its life cycle is independent of the original recorded video, and can be managed independently and stored for a long time.

    Clips are not solidified

    The editing is not solidified, which means that the result of editing (m3u8 file) and the live recording video share the same ts fragment. The newly generated video is not an independent and complete video (no independent FileId, only playback URL), and its validity period is the same as the live broadcast. The validity period of the complete recorded video is the same. Once the video recorded during the live broadcast is deleted, the clip will also become unplayable.

    The clip is not solidified. Because the clip result is not an independent video, it will not be included in on-demand media asset video management (for example, the total number of videos in the console will not count this clip), and this clip cannot be transcoded separately. Video processing operations.

    The advantage of not solidifying editing is that its editing operation is very "lightweight" and does not generate additional storage overhead. However, its disadvantage is that the life cycle is the same as the original recorded video, and further video processing such as transcoding cannot be performed.

    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: LiveRealTimeClip.
    Version Yes String Common Params. The value used for this API: 2018-07-17.
    Region No String Common Params. This parameter is not required.
    StreamId Yes String The live stream code.
    StartTime Yes String Start time of stream clipping in ISO date format.
    EndTime Yes String End time of stream clipping in ISO date format.
    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.
    IsPersistence No Integer Whether to clip persistently. 0: no, 1: yes. Default: no.
    ExpireTime No String Storage expiration time of video generated by persistent clipping in ISO date format. 9999-12-31T23:59:59Z means never expire. After the expiration, the media file and its related resources (such as transcoding results and image sprites) will be permanently deleted. This parameter will be valid only when IsPersistence is 1. By default, the video will never expire.
    Procedure No String VOD task flow processing for video generated by persistent clipping. For more information, please see Specifying Task Flow After Upload. This parameter will be valid only when IsPersistence is 1.
    ClassId No Integer The ID of the media file's category. You can use the CreateClass API to create a category and get the category ID.
  • The default value is 0, which means the "Other" category.

  • This parameter is valid only if IsPersistence is 1.
    SourceContext No String The source context, which is used to pass through user request information. The NewFileUpload callback will return the value of this parameter. It can contain up to 250 characters and is valid only if IsPersistence is 1.
    SessionContext No String The session context, which is used to pass through user request information. If the Procedure parameter is specified, the ProcedureStateChanged callback will return the value of this parameter. It can contain up to 1,000 characters and is valid only if IsPersistence is 1.
    MetaDataRequired No Integer Whether the metadata of clipped video needs to be returned. 0: no, 1: yes. Default value: no.
    Host No String Domain name used for live clipping. Time shifting must be enabled in LVB.
    StreamInfo No LiveRealTimeClipStreamInfo The information of the live stream to clip.
  • The video clip is cut from the original stream by default.
  • If Type of StreamInfo is set to Transcoding, the video clip will be cut from the output stream of the transcoding template specified by TemplateId.
  • ExtInfo No String Reserved field. Do not enter a value for it.

    3. Output Parameters

    Parameter Name Type Description
    Url String Playback URL of clipped video.
    FileId String Unique media file ID of video generated by persistent clipping.
    Note: this field may return null, indicating that no valid values can be obtained.
    VodTaskId String Task flow ID of video generated by persistent clipping.
    Note: this field may return null, indicating that no valid values can be obtained.
    MetaData MediaMetaData
    Note: This field may return null, indicating that no valid value can be obtained.
    SegmentSet Array of LiveRealTimeClipMediaSegmentInfo Cliped media segment info.
    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 Clipping a live video for temporary sharing

    This example shows you how to cut out a video clip from a live stream (live stream code: record-stream; domain name: example.com) from 2018-09-20T10:00:00Z to 2018-09-20T11:00:00Z for temporary sharing. The live stream was interrupted for 10 minutes from 2018-09-20T10:30:00Z to 2018-09-20T10:40:00Z, so the output parameter SegmentSet contains the information of two segments, and the actual duration of the video clip is 50 minutes.

    Input Example

    POST / HTTP/1.1
    Host: vod.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: LiveRealTimeClip
    <Common request parameters>
    
    {
        "Host": "example.com",
        "EndTime": "2018-09-20T11:00:00Z",
        "StartTime": "2018-09-20T10:00:00Z",
        "StreamId": "record-stream"
    }
    

    Output Example

    {
        "Response": {
            "Url": "http://example.com/playlist.m3u8",
            "FileId": "",
            "VodTaskId": "",
            "MetaData": null,
            "SegmentSet": [
                {
                    "StartTime": "2018-09-20T10:00:00Z",
                    "EndTime": "2018-09-20T10:30:00Z"
                },
                {
                    "StartTime": "2018-09-20T10:40:00Z",
                    "EndTime": "2018-09-20T11:00:00Z"
                }
            ],
            "RequestId": "6ca31e3a-6b8e-xxxx-9256-fdc700064ef3"
        }
    }
    

    Example2 Clipping a live video for persistent storage

    This example shows you how to cut out a video clip from a live stream (live stream code: record-stream; domain name: example.com) from 2018-09-20T12:00:00Z to 2018-09-20T13:00:00Z for persistent storage, and initiate a task flow on the video.

    Input Example

    POST / HTTP/1.1
    Host: vod.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: LiveRealTimeClip
    <Common request parameters>
    
    {
        "IsPersistence": "1",
        "Host": "example.com",
        "StartTime": "2018-09-20T12:00:00Z",
        "StreamId": "record-stream",
        "EndTime": "2018-09-20T13:00:00Z",
        "Procedure": "SomeProcedure"
    }
    

    Output Example

    {
        "Response": {
            "Url": "http://example.com/playlist.m3u8",
            "FileId": "5285890xxxxxx199336",
            "VodTaskId": "125xxxx65-procedurev2-bffb15f07530b57bc1aabb01fac74bca",
            "MetaData": null,
            "SegmentSet": [
                {
                    "StartTime": "2018-09-20T12:00:00Z",
                    "EndTime": "2018-09-20T13:00:00Z"
                }
            ],
            "RequestId": "6ca31e3a-6b8e-xxxx-9256-fdc700064ef3"
        }
    }
    

    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.
    InternalError Internal error.
    InvalidParameterValue Incorrect parameter value.
    InvalidParameterValue.ClipDuration Incorrect parameter value: the clipping duration is too long.
    InvalidParameterValue.EndTime Incorrect parameter value: invalid EndTime.
    InvalidParameterValue.ExpireTime Incorrect parameter value: incorrect ExpireTime format.
    InvalidParameterValue.StartTime Incorrect parameter value: invalid StartTime.
    InvalidParameterValue.StreamIdInvalid Incorrect parameter value: invalid StreamId.
    UnauthorizedOperation Unauthorized operation.
    UnsupportedOperation Unsupported operation.