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 | JSONObject | No | The duration of the recording in each format in each cycle. Valid values: 5 to 21600. Unit: seconds. |
Format | JSONArray | No | The format of the recording. The recording can be in the MP4, FLV, or M3U8 format. |
Examples
GET /?app=seq_all&domain=demo.aliyundoc.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, the operation failed to be called.
The request body cannot exceed 2,048 characters in length. Otherwise, the body is truncated to prevent malicious attacks.
Usage notes
- ApsaraVideo Live supports triggered stream pulling. If the streaming URL for a domain name is used for playback, ApsaraVideo Live is automatically triggered to pull live streams. If no live streams are played, ApsaraVideo Live does not pull live streams from the origin. In this case, automatic recording, on-demand recording, and manual recording are also disabled.