After you configure recording, you can determine whether to record live streams on demand.
You can implement on-demand recording by using one of the following methods:
-
Set ingest parameters. This method will be supported in the future.
-
Use an HTTP callback method.
To implement on-demand recording by using an HTTP callback method, you must specify a callback URL and a domain name, an application, or a live stream. When the recording service receives the specified live stream or a live stream from the specified domain name or application, the recording service sends a request to the callback URL to ask whether to record the live stream. The request contains the five parameters that are described in the following table.
Request parameters
Parameter | Type | Description |
---|---|---|
domain | String | The main streaming domain. |
app | String | The name of the application to which the live stream belongs. |
stream | String | The name of the live stream. |
codec | String | The encoding format. Valid values:
|
vbitrate | String | The bitrate of the video. Unit: Kbit/s. |
Response parameters
Parameter | Type | Required | Description |
---|---|---|---|
ApiVersion | String | No |
The version of the API. The default version is 1.0. |
NeedRecord | Bool | Yes | Indicates whether recording is required. |
Interval | Json Object | No | The duration of the recording in each format in each cycle. Valid values: 5 to 21600. Unit: seconds. |
Format | Array | No | The format of the recording. The recording can be in the MP4, FLV, or M3U8 format. |
Examples
GET /?app=seq_all&domain=example.com&stream=ondemand8&vbitrate=2000&codec=h264 HTTP/1.1
Host: example.aliyundoc.com
User-Agent: Go-http-client/1.1
Accept-Encoding: gzip
{
"ApiVersion" : "1.0",
"NeedRecord" : true,
"Interval" : {
"Mp4": 300,
"Flv": 120,
"M3U8": 180
},
"Format" : ["mp4","flv"]
}
Processing of response parameters
-
If a non-200 HTTP status code is returned, an error has occurred.
-
The request body cannot exceed 2,048 characters in length. Otherwise, the body is truncated to prevent malicious attacks.
Usage notes
- If a live stream is interrupted after you manually record it, the recording stops. In addition, if automatic recording is not configured for the live stream, ApsaraVideo Live does not automatically record the live stream after it is resumed.