You can set recording callback URLs and send requests to these URLs to query the recording status and results.

Restrictions and guidelines

You can only receive recording file generation event, after added a recording callback URL in the ApsaraVideo Live console. If you want recording status events, you should call AddLiveRecordNotifyConfig to set NeedStatusNotify = true first.

Both HTTP and HTTPS URLs are supported. POST requests in JSON format are sent to the user server to inform the user of the recording result and status in real time. The user server then returns a response with status code 200. If an HTTPS callback URL is used, you must make sure that the HTTPS certificate is a CA issued certificate. If the request times out, ApsaraVideo Live will resend the request. ApsaraVideo Live can attempt to resend the request for up to five times. The resending interval is a random number between 100 milliseconds and 10 seconds.

Procedure

You can add a recording callback URL in the ApsaraVideo Live console.

  1. Log on to the ApsaraVideo Live console.
  2. Click Domain Management.
  3. Select the target streaming domain name, and click Stream Settings.

  4. In the left-side navigation pane, click Recording Settings.

  5. Click Add to the right of Callback URL.
  6. In the Configure Callback URL dialog box, enter a callback URL.

    Note For security, you cannot set internal network addresses as callback URLs. Callback URLs must be valid public network addresses.

Example:

Callback URL: The body of the response returned from http:// 1.1.1.1/notify/record is as follows:

Sample callback for a recording file generation event

This callback indicates that the target recording file has been generated.
{
  "domain": "live.aliyunlive.com",
  "app": "live",
  "stream": "hello",
  "uri": "live/hello/0_2017-03-08-23:09:46_2017-03-08-23:10:40.flv",
  "duration": 69.403,
  "start_time": 1488985786,
  "stop_time": 1488985840
}
				

The domain, app, and stream parameters indicate the domain name, application name, and stream name, respectively. The URI parameter indicates the path of the OSS bucket that stores the target recording file. The duration, start_time, and stop_time parameters indicate the length of the recording, the recording start time, and the recording end time, respectively.

Sample callback of the recording status (triggered when NeedStatusNotify is set to true)
  • Callback indicating that the recording process has started.
    {
    "domain": "live.aliyunlive.com",
    "app": "live",
    "stream": "hello",
    "event": "record_started"
    }
    							

    The domain, app, and stream parameters indicate the domain name, application name, and stream name, respectively. The event parameter indicates the name of the event, which can be record_started/record_paused/record_resumed.

  • Callback indicating that the recording process has been paused.
    {
    "domain": "live.aliyunlive.com",
    "app": "gs_app",
    "stream": "gs_stream",
    "event": "record_paused"
    }
    							
  • Callback indicating that a recording error has occurred.
    {
    "domain": "gs_domain",
    "app": "gs_app",
    "stream": "gs_stream",
    "event": "record_error"
    
    }