Content is empty
If you don't find the content you expect, please try another search term
Last updated:2020-11-26 20:11:46
Prerequisites
To use live stream recording, you must contact Kingsoft Cloud sales team to activate Kingsoft Cloud Live Service (KLS), Content Delivery Network (CDN), and VoD Transcoding.
Concepts
Service activation
Note
rtmp://uniquename.uplive.ks-cdn.com/live/stream?vdoid=1477402932
Recording generation rules: Recording files of push streams with the same name are spliced if stream pushing resumes within 3 minutes (which can be configured) after interruption. A recording file is sliced after it reaches 6 hours (which can be configured) in length.
Path: /record/{App}/{StreamName}/hls/
Naming rule: [stream name]-[file start time]-[file end time].m3u8
Format: {StreamName}-{StartTime}-{EndTime}.m3u8
Example:
mystream-1585829187-1585829324.m3u8
Path description
Directory | Description |
---|---|
record | The root directory for ease of management. |
App | The app name that comes with the push stream. Default value: live. |
StreamName | The name of the push stream. |
hls | The directory where .m3u8 files are stored. |
Vdoid | The unique identifier. This field will be deprecated soon. |
Note: If a push stream does not carry the vdoid parameter and its path is empty, the MP4 file cannot be generated.
Recording generation rules: Recording files of push streams with the same name are spliced if stream pushing resumes within 3 minutes (which can be configured) after interruption. A recording file is sliced after it reaches 6 hours (which can be configured) in length.
Path: /record/{App}/{StreamName}/mp4/
Naming rule: [stream name]-[file start time]-[file end time].mp4
Format: {StreamName}-{StartTime}-{EndTime}.mp4
Example:
mystream-1585829187-1585829324.mp4
Recording generation rules: Recording files of push streams with the same name are spliced if stream pushing resumes within 3 minutes (which can be configured) after interruption. A recording file is sliced after it reaches 6 hours (which can be configured) in length.
Path:/record/{App}/{StreamName}/flv/
Naming rule: [stream name]-[file start time]-[file end time].flv
Format: {StreamName}-{StartTime}-{EndTime}.flv
Example:
mystream-1585829187-1585829324.flv
Callback URL configuration
You can configure a callback URL for recording files in the KLS console. When a recording file is generated, you are informed through a callback in the form of HTTP POST.
Sample callback
The default callback information is as follows:
{
"status":3,
"taskid":"xxxxx",
"itmes":[
{
"cmd":"",
"desc":"success",
"keys":[
"record/live/NEWLIVE4q665314vdoid6683676M2W3/hls/filename.m3u8"
],
"vdoid":"",
"code":3
}
],
"mediaSize":0
}
If you want to add a start time and end time in the callback information, please contact technical support to enable it.
Parameter description
Parameter | Example | Description |
---|---|---|
status | 3 | The task execution status. Valid values: 3: succeeded; 4: failed. |
taskid | 00PNwad2wdoO | The unique task ID of the current live recording operation. |
desc | success | The task execution result. |
keys | /streamname/11111.m3u8 | The name of the .m3u8 VoD file generated. |
code | 3 | The code returned after the task execution is completed. |
Callback URL configuration
You can configure a callback URL for recording files in the KLS console. When a recording file is generated, you are informed through a callback in the form of HTTP POST.
Sample callback
{
"taskid":"xxxxx",
"status":3,
"type":"avtrans",
"details":{
"errnum":0,
"bucket":"xxxx",
"starttime":"1456800010",
"endtime":"1456800020",
"stream":"xxxx",
"throughParams":"xxxx",
"items":[
{
"dstpath":"xxxxx.mp4",
"ETag":"cb1b99f6657c91dac6c1913cd99131a1",
"outMediainfo":"{\"metadata\":{},\"format\":{\"format_name\":\"mp4\",\"size\":1027254935,\"duration\":\"5241\",\"bit_rate\":1568024},\"streams\":[{\"codec_name\":\"h264\",\"codec_type\":\"video\",\"width\":1280,\"height\":720,\"r_frame_rate\":\"25/1\"},{\"index\":1,\"codec_name\":\"aac\",\"codec_type\":\"audio\",\"channels\":2,\"sample_rate\":32000}]}"
}
]
},
// Historical fields, which can be ignored
"itmes":[
{
"cmd":"tag=avtranstag=saveas&bucket=media-kslive&object=YTMwNGQzNzQzZTdhNGRmNmE1NzAwZjkxNDJhY2RjZTlfdmRvaWQyMDE3MDkwNC5tcDQ=",
"desc":"success",
"keys":[
"xxxxx.mp4"
],
"code":3
}
]
}
Parameter description
Field name | Type | Required | Description |
---|---|---|---|
taskid | String | Yes | The task ID. |
status | Int | Yes | The status of the task. Valid values: 3: succeeded; 4: failed. |
type | String | Yes | The type of the task, same as the type of the template used at task creation. |
details | JSON object | Yes | More detailed information. |
Field name | Type | Required | Description | |
---|---|---|---|---|
errnum | Int | Yes | The video information. | |
errmsg | String | Yes | The video metadata. | |
bucket | String | Yes | The video stream information list. | |
stream | String | No | The stream name. | |
starttime | String | No | The start time of the stream. | |
endtime | String | No | The end time of the stream. | |
throughParams | String | No | The pass-through parameters. | |
items | JSON array | Yes | The custom callback information, such as output file information. |
Field name | Type | Required | Description |
---|---|---|---|
dstpath | Int | Yes | The relative path of the output file in KS3. |
ETag | String | Yes | The MD5 value of the video content. |
outMediainfo | String | Yes | The callback field for avtrans tasks that store information about the output video. The value is a string in JSON format. |
Field name | Type | Required | Description |
---|---|---|---|
metadata | JSON object | Yes | The video metadata. |
streams | JSON array | Yes | The video stream information list. |
format | JSON object | Yes | The video file information. |
Description of the metadata field
Field name | Type | Required | Description |
---|---|---|---|
rotate | String | No | The rotation information. |
Description of the streams field
Field name | Type | Required | Description |
---|---|---|---|
index | Int | Yes | The index number. |
codec_type | String | Yes | The stream type. |
codec_name | String | Yes | The encoding format. |
bit_rate | Int | Yes | The bitrate, in bps. |
width | Int | No | The width. |
height | Int | No | The height. |
r_frame_rate | String | No | The frame rate. |
channels | Int | No | The number of audio channels. |
sample_rate | Int | No | The audio sampling rate. |
Description of the format field
Field name | Type | Required | Description |
---|---|---|---|
duration | String | Yes | The file length, in seconds. |
format_name | String | Yes | The container format of the file. |
size | Int | Yes | The file size, in bytes. |
Pure Mode