All Documents
Current Document

Content is empty

If you don't find the content you expect, please try another search term

Documentation

Live screenshots

Last updated:2023-05-16 18:14:18

Screenshot capture rules: Only I-frames are captured. After stream pushing starts, the first I-frame is captured as the first screenshot file. You can specify the capture frequency, that is, the minimum time interval between two consecutive screenshot capture operations. Assume that the capture frequency is set to 20 seconds. The first I-frame is captured as the first screenshot, the first I-frame that appears after 20 seconds (inclusive) is captured as the next screenshot file, and so on.

  • To use the screenshot service, you must apply for its activation in the KLS console, and specify the callback URL and the buckets used to store screenshot files. Original screenshot files are provided in .jpg format only.
  • Screenshot capture during live streaming is only available in Beijing region.

Storage rules

With screenshot overwrite disabled

Note: After you disable screenshot overwrite, the screenshot files are named in the format of {StreamName}-{UnixTimestamp}.jpg. All of the screenshot files are stored in Kingsoft Cloud Standard Storage Service (KS3).

Naming rule: {StreamName}-{UnixTimestamp}.jpg

Storage path: record/{App}/{StreamName}/picture/{UnixTimeMs}-{SessionId}/{StreamName}-{UnixTimestamp}.jpg

Example: record/myapp/mystream/picture/mystream-1587523655.jpg

Path description

Directory Description
record The root directory.
App The app name.
StreamName The stream name.
picture The identifier denoting that the directory contains screenshot files.
UnixTimeMs The timestamp in milliseconds denoting the creation time of the file directory.
SessionId A random number.
UnixTimeMs The timestamp in milliseconds denoting the start time of stream pushing.

With screenshot overwrite enabled

Note: After you enable screenshot overwrite, the screenshot files are named in the format of {StreamName}.jpg, and a new screenshot file automatically replaces the old one. Therefore, only the latest screenshot file is stored in KS3.

Naming rule: {StreamName}.jpg

Storage path: record/{App}/{StreamName}/picture/{StreamName}.jpg

Example: record/myapp/mystream/picture/mystream.jpg

Callback API

Configure the callback URL

You can configure in the KLS console the callback URL for when a screenshot file is generated. You are notified of the details about the screenshot through an HTTP POST request.

Sample callback

{
    "status":3,
    "taskid":"xxx",
    "type":"LiveSnapShotCallBack",
    "details":{
        "errnum":0,
        "errmsg":"",
        "uniqname":"myuniqname",
        "stream_name":"12345",
        "timestamp":1464765845,
        "srcWidth":1280,
        "srcHeight":720,
        "bucket":"myBucket",
        "items":[
            {
                "output_format":0,
                "width":480,
                "height":360,
                "setWidth":540,
                "setHeight":360,
                "intelligentSwitch":1,
                "quality":5,
                "dstpath":"upic/2016/05/11/live/1.jpg",
                "container":"webp",
                "suffix":"480"
            },
          // Historical fields, which can be ignored
             "itmes":[
        {
            "cmd":"tag=avop&f=mp4&res=1280x720&vbr=1500k&abr=128k|tag=saveas&bucket=xxx&object=cmVjb3JkL3VwbG9hZC9WMTQ1NTUwODQyNDExMjY3OC9WMTQ1NTUwODQyNDExMjY3OC5tcDQ=",
            "desc":"success",
            "keys":[
                "record/upload/V1455508424112678/xxx.mp4"
            ],
            "code":3
         }
         ]
        ]
    }
}

Parameter description

Parameter Example Description
status 3 The task execution status. Valid values: 3: succeeded; 4: failed.
taskid xxx The unique task ID of the current screenshot capture operation.
desc success The task execution result.
keys record/upload/V1455508424112678/xxx.jpg The storage path of the screenshot.
code 3 The code returned after the task execution is completed.
type LiveSnapShotCallBack The type of the callback.
errnum 0 The error code.
errmsg xxx The error description.
uniqname myuniqname The uniquename.
stream_name 123 The stream name.
timestamp 1464765845 The time point when the screenshot is captured.
bucket mybucket The bucket where the screenshot is stored.
width 480 The width of the screenshot.
height 360 The height of the screenshot.
shortside 360 The length of the short side specified by user. This field is not carried in the callback if it is not specified.
quality 5 The user-defined picture quality level. If the default value is used, the field is not carried in the callback.
dstpath upic/2016/05/11/live/1.jpg The storage path of the screenshot in the bucket. This value is empty if upload failed. You can download the screenshot by using alterurl during live streaming.
On this page
Pure ModeNormal Mode

Pure Mode

Click to preview the document content in full screen
Feedback