LVB Screencapturing

Last updated: 2020-05-08 16:57:04

    The LVB screencapturing feature takes screenshots of a real-time live stream at regular intervals and generates images. You can get the screenshot information through the callback notification. These screenshots have various uses, such as porn detection and thumbnails.

    LVB Screencapturing Process

    Overall process:

    1. Configure the LVB screencapturing feature in the console or through TencentCloud API.
    • Start an LVB push.
    • The screencapturing service generates screenshot data according to the configuration and stores it in COS.
    • Information about the generated screenshot is returned in a callback.

    LVB Screencapturing Configuration

    Screencapturing configuration method

    Screencapturing interval configuration

    You can specify the screencapturing frequency based on your business needs, i.e., the screencapturing interval (SnapshotInterval). The available range is between 5–300 seconds with a default interval of 10 seconds.

    Screenshot width and height configuration

    The screencapturing service supports taking screenshots by the specified width and height:

    If you do not need to specify the width and height, the default screenshot width and height (set to 0) will be the width and height of the pushed video stream, and you can ignore the configuration instructions below and skip to the next section.

    First, look at the following three concepts of width and height:

    • Push width and height, i.e., the width and height of the live streaming video, which are set to (X, Y) in this document.
    • Configured width and height, i.e., the width and height configured in the console/through the TencentCloud API, which are set to (W, H) in this document.
    • Screenshot width and height, i.e., the width and height of the screenshot generated by the screencapturing service, which are set to (N, M) in this document.

    The screencapturing service supports the following configurations:

    • If the width and height are not set, then (W, H) = (0, 0) is used by default. The screenshot width and height are the same as the push width and height, i.e., (N, M) = (X, Y).
    • If only the width W is set, then the screenshot width will be N = W, and the screenshot height is scaled proportionally, i.e., M = N / X * Y.
    • If only the height H is set, then the screenshot height will be M = H, and the screenshot width is scaled proportionally, i.e., N = M / Y * X.
    • If (W, H) are set at the same time, then the screenshot width and height are the same as the configured width and height, i.e., (N, M) = (W, H).

    The automatic swap of configured width and height is suitable for the following scenario:

    • If W is set to be smaller than H, both W and H are greater than 0, and X is set to be greater than Y during the push, then the configured width is smaller than the height, but the push width is greater than the height.

    In this case, if a screenshot is directly taken, it will be distorted. In order to avoid the distortion, the backend of the LVB screencapturing service will automatically swap the values of W and H to ensure that the configured aspect ratio is consistent with that of the live stream.

    Event Message Notification for LVB Screencapturing

    For event message notification configuration, please see Event Message Notification. The screencapturing callback notification is sent to the pre-configured receiving server through the HTTP POST protocol in JSON format.

    Screencapturing callback fields

    Field Name Type Description
    event_type int Callback information type, which is always 200 for screencapturing callback
    stream_id string Stream name
    channel_id string Same as the stream name
    create_time int64 UNIX timestamp when the screenshot is generated
    file_size int Screenshot file size in bytes
    width int Screenshot width in pixels
    height int Screenshot height in pixels
    pic_url string Screenshot file path /path/name.jpg. For more information, please see Field details below
    pic_full_url string Full screenshot URL. For more information, please see Field details below
    sign string Callback signature. For more information, please see Event Message Notification
    t int64 UNIX timestamp when the callback signature expires. For more information, please see Event Message Notification

    Field-details">

    Field details

    • pic_url details:

      • path: year-month-day
      • name: live stream name-screenshot-hour-minute-second-widthxheight.jpg
        Example:
        /2018-12-17/stream_name-screenshot-19-06-59-640x352.jpg
        This field can be used to put together a custom COS CDN domain name. If you do not need a CDN domain name, use pic_full_url directly.
    • pic_full_url details:

      • http://COS domain name+pic_url
        Example:
        http://testbucket-1234567890.cos.region.myqcloud.com/2018-12-17/stream_name-screenshot-19-06-59-640x352.jpg

    Sample screencapturing callback

    {
    
    "event_type":200,
    
    "stream_id":"stream_name",
    
    "channel_id":"stream_name",
    
    "create_time":1545030273,
    
    "file_size":7520,
    
    "width":640,
    
    "height":352,
    
    "pic_url":"/2018-12-17/stream_name-screenshot-19-06-59-640x352.jpg",
    
    "pic_full_url":"http://testbucket-1234567890.cos.region.myqcloud.com/2018-12-17/stream_name-screenshot-19-06-59-640x352.jpg",
    
    "sign":"ca3e25e5dc17a6f9909a9ae7281e300d",
    
    "t":1545030873
    
    }

    Was this page helpful?

    Was this page helpful?

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