LVB Recording

Last updated: 2020-10-23 10:05:15

    LVB recording is a service that stores the files generated by encapsulating original streams (without modifying such information as audio and video data and corresponding timestamps) on the VOD platform.

    Notes

    • You can use one of the following methods to record: create a recording task or create a recording template. If you create both recording template and recording task for the same live stream, it will be recorded repeatedly.
    • As there is a short delay in starting a recording task after a stream is pushed, a very short push cannot generate recording files. For a better quality of recording files, the duration of each recorded push should be longer than 10s.

    Recording Storage

    As LVB recording files are stored on the VOD platform, you need to apply for activation of the VOD service first.

    Note:

    For more information about the recording filenames, see the VodFileName parameter in Data Types.

    Recording Format

    Supported recording formats include .aac (for audio recording), .flv, .hls, and .mp4.

    Recording Use Cases

    Use Case Description
    Multi-level recording by push domain name and stream name You can configure whether to record a stream at the push domain name and stream name levels.
    Recording within a specified time period You can set the start time and end time through APIs to record a stream within the specified time period.
    Real-time recording You can record any frame of a stream in real time through APIs.
    Audio recording You can configure audio recording in .acc format if the push is pure audio.

    Enabling Recording for All Live Streams Under Specified Push Domain Name

    Recording parameters are managed in the form of templates. You can create recording configuration templates for different scenarios and flexibly manage the recording configuration by associating the templates with different push domain names and stream names.
    After activating VOD, you can record live streams under a specified push domain name in two ways:

    LVB Console

    1. Select Feature Template > Recording Configuration to create a recording template.
    2. Select Domain Management to add a push domain name, and click Manage to associate it with the recording template. For more information, please see Recording Configuration.

    APIs

    1. Call CreateLiveRecordTemplate to set at least one recording format, such as FlvParam.
    2. Call CreateLiveRecordRule to set the DomainName (push domain name) and TemplateId (returned in step 1) parameters. Enter an empty string in AppName and StreamName as a wildcard to indicate all streams under the domain name.

    Likewise, you can associate the template with different stream names to record particular live streams.
    In addition, as one recording template can be associated with different push domain names and stream names, one stream may be matched with multiple templates. In this case, the template with the highest priority will prevail. The priority rule of template matching is as shown below (which is for complex cases only and can be ignored by most users).

    DomainName StreamName Priority
    0
    Empty string 1
    Empty string 2
    Empty string Empty string 3

    Here, Empty string is a wildcard, indicates exact match, and 0 represents the highest priority. Once a template with the highest priority is matched, the matching will be stopped and the corresponding template will be returned.

    Disabling Recording for Some Streams Under Specified Push Domain Name

    When you have already configured recording for a push domain name but some streams under it do not need to be recorded, you can:

    1. Call CreateLiveRecordTemplate without specifying any recording format.
      https://live.tencentcloudapi.com/?Action=CreateLiveRecordTemplate
      &TemplateName=norecord
      &Description=test
      &<Common request parameters>
    2. Set the DomainName and StreamName parameters in the console or through the CreateLiveRecordRule API and associate the above-mentioned recording template with the specified push domain name and stream name.

    Note:

    This scheme is applicable to scenarios where only a few streams do not need to be recorded. If there are too many of them, we recommend you use another push domain name to manage them, because:

    • The allowed maximum number of recording templates or recording rules is 50.
    • Management by push domain name is more flexible as recording templates and recording rules won't be affected in this mode even your business changes.

    Recording Within Specified Time Period

    For some streams, you can start and end recording at the specified points in time through APIs. Unlike configuring a recording template, the recording parameters need to be specified through APIs. This approach is generally adopted if no recording method has been set.

    APIs

    For more information on how to create a recording task through the API, please see CreateRecordTask.

    Recording sample

    • In the simple case, you just need to specify the following parameters: StreamName, DomainName, AppName, and EndTime.
      The following sample code creates a video recording task in .flv format for 8 AM to 10 AM, August 10, 2020 with 30-minute segments that will be retained permanently.
      Sample input:
      https://live.tencentcloudapi.com/?Action=CreateRecordTask
      &AppName=live
      &DomainName=mytest.live.push.com
      &StreamName=livetest
      &StartTime=1597017600
      &EndTime=1597024800
      &TemplateId=0
      &<Common request parameters>
    • The recording format, recording type, and storage parameters can also be specified.
      The following sample code creates a recording task in .mp4 format for 8 AM to 10 AM, August 10, 2020 with 1-hour segments that will be retained permanently.
      1. Call CreateLiveRecordTemplate to create a recording template.
        Sample input:
        https://live.tencentcloudapi.com/?Action=CreateLiveRecordTemplate
        &TemplateName=templat
        &Description=test
        &Mp4Param.Enable=1
        &Mp4Param.RecordInterval=3600
        &Mp4Param.StorageTime=0
        &<Common request parameters>
        Sample output:
        {
        "Response": {
        "RequestId": "839d12da-95a9-43b2-a9a0-03366d01b532",
        "TemplateId": 17016
        }
        }
      2. Call CreateRecordTask to create a recording task.
        Sample input:
        https://live.tencentcloudapi.com/?Action=CreateRecordTask
        &StreamName=livetest
        &AppName=live
        &DomainName=mytest.live.push.com
        &StartTime=1597017600
        &EndTime=1597024800
        &TemplateId=17016
        &<Common request parameters>

    Note:

    • For the same live stream, there is no conflict between scheduled tasks or between a scheduled task and a recording task of another type. In other words, the time periods of multiple scheduled tasks can overlap, and the API can be called to create a recording task in addition to enabling a recording configuration.
    • We recommend you create recording tasks in advance (e.g., one hour in advance or in the early morning for recording later on), and the task start time should be set to be a little earlier than the event start time.

    Real-Time Recording

    If you want to record any frames immediately in the process of live streaming to generate highlight clips for future use, you can call the API to enable real-time recording.

    https://live.tencentcloudapi.com/?Action=CreateRecordTask
    &StreamName=test
    &AppName=live
    &DomainName=mytest.live.push.com
    &EndTime=1597024800
    &<Common request parameters>

    The following notes on real-time recording need your attention:

    • Make sure that the push is ongoing when you create a recording task.
    • This is suitable for recording short clips of up to 30 minutes.
    • You can call the StopRecordTask API to stop a task prematurely.
    • This is supported for streams outside Mainland China.

    Stream Mix-based Recording

    First, please familiarize yourself with the stream mix service in On-cloud Stream Mix.

    For LVB scenarios where the On-Cloud MixTranscoding service is used, stream mix is divided into two types by the OutputStreamType parameter on the recording side:

    • If OutputStreamType = 0, the output stream is in the input stream list, meaning that no new stream has been generated.
    • If OutputStreamType = 1, the output stream is not in the input stream list, meaning that a new stream has been generated.

    Assume that streams A and B are output as stream C after stream mix:

    • If OutputStreamType = 0 and stream C has the same name as stream A with mixed video, after the recording is started, a recording file mixing stream A (mixed video) and stream B will be generated by default. Note that as the same stream ID is reused, the original stream A will not generate a recording file.
    • If OutputStreamType = 1, after the recording is started, a recording file mixing stream A, stream B, and stream C (mixed video) will be generated by default.

    To record a mixed stream only, you can call the CreateRecordTask API. It should be noted that if OutputStreamType =1, the StreamType parameter should be set to 1 when the above API is called.

    Auto-Spliced Recording (Multi-Stream Recording)

    If a push is interrupted multiple times because of network jitters, a number of recording files will be generated, causing inconvenience to continuous playback of the live stream. To solve this problem, LVB recording can auto-splice multiple recording files during the same push into one single file.

    This feature works by segmenting audio and video data by HLS' #EXT-X-DISCONTINUITY tag in HLS recording. This tag marks that the information such as timestamps of audio and video data, video encoding formats, audio encoding formats, and sample rates before and after it may be different. As such, the player needs to refresh the decoder for continuous playback. Therefore, to use this feature, the player must support the #EXT-X-DISCONTINUITY tag. Currently, the native player and Safari on iOS, ExoPlayer on Android, and hls.js player on the web support this tag, but VLC player does not support it.

    After this feature is enabled, you need to set the auto-splicing interval (up to 30 minutes, meaning that recording files in intervals of up to 30 minutes can be spliced into one file). After the last push ends, the recording files before and after the interruptions will be automatically spliced to generate an HLS recording file.

    Currently, auto-spliced recording is available only to the HLS format. You can set the auto-splicing timeout value in the recording configuration.

    Note:

    • This mode does not support live streams with no audio data.
    • The ComposeMedia API of VOD can be used to compose video files. For more information, please see ComposeMedia.

    Getting Recording File

    The generated recording files are automatically stored in the VOD system and can be obtained in the following ways:

    VOD Console

    Log in to the VOD Console and select a user rather than Admin. Select Media Assets > Video Management to browse all recording files.

    img

    Recording event notification

    The recording callback address can be set in the console or through API calls. A notification will be sent to the callback address after the recording files are generated. After that, you can refer to the callback event message notification for recording to take your next step.

    The event notification is an efficient, reliable, and real-time mechanism, so it is recommended to use the callback method to get recording files.

    VOD API query

    For detailed instructions, please see the VOD API documentation:

    • The SearchMedia API can be used to query recording files by live stream name and time range.
    • The DescribeVodPlayInfo API can be used to get video information by video name prefix.

    Notes on Configuration Update

    After the recording configuration is updated, you are recommended to restart the push and verify the configuration. The validity rules for the configuration are as follows:

    • It takes 10 minutes for the configuration to take effect by default.
    • The configuration is effective upon the start of the LVB push and will not be updated in the process of recording.
    • In scenarios where the push lasts for a long time such as surveillance recording, the push needs to be stopped and then restarted to make the configuration effective.

    Was this page helpful?

    Was this page helpful?

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