Adds a recording configuration for an app or a live stream.

Note The recording feature supports the automatic recording, on-demand recording, and manual recording modes. You must call this operation to configure a recording template regardless of the recording mode used. You can configure information such as the format and duration of a recording in a recording template. The format of a recording can be M3U8, MP4, or FLV. You can specify multiple recording modes at the same time. For example, you can specify automatic recording for an application and manual recording for a specific live stream. However, a live stream can be recorded in only one mode. If you specify a recording mode for an application and another recording mode for a live stream under the application, the live stream is recorded in the mode specified for the live stream. Assume that you specify automatic recording for an application and manual recording for specific live streams under the application. In this case, the specific live streams are manually recorded. Take note that if you only configure a recording template but do not call the operations related to manual recording for the live streams, the live streams are not recorded.

If the permissions to write live stream recordings to the specified bucket is deleted, you must use the following methods to reconfigure the permissions:

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes AddLiveAppRecordConfig

The operation that you want to perform. Set the value to AddLiveAppRecordConfig.

AppName String Yes testApp

The name of the application to which the live stream belongs.

DomainName String Yes www.yourdomain.com

The main streaming domain.

OssBucket String Yes testBucket

The name of the OSS bucket in which the recording is stored.

OssEndpoint String Yes oss-cn-shanghai.aliyuncs.com

The endpoint of OSS.

RecordFormat.N.Format String No m3u8

The format of the recording. Valid values: m3u8, flv, and mp4.

RecordFormat.N.OssObjectPrefix String No record/{AppName}/{StreamName}/{Sequence}{EscapedStartTime}{EscapedEndTime}

The name of the recording that is stored in OSS.

  • The name must be less than 256 bytes in length and can contain the {AppName}, {StreamName}, {Sequence}, {StartTime}, {EndTime}, {EscapedStartTime}, and {EscapedEndTime} variables.
  • The name must contain the {StartTime} and {EndTime} variables or the {EscapedStartTime} and {EscapedEndTime} variables.
RecordFormat.N.SliceOssObjectPrefix String No record/{AppName}/{StreamName}/{UnixTimestamp}_{Sequence}

The name of the TS segment. This parameter is required if the RecordFormat.N.Format parameter is set to m3u8.

  • By default, the duration of a TS segment is 30 seconds. The name must be less than 256 bytes in length and can contain the {AppName}, {StreamName}, {UnixTimestamp}, and {Sequence} variables.
  • The name must contain the {UnixTimestamp} and {Sequence} variables.
RecordFormat.N.CycleDuration Integer No 1

The recording period. Unit: seconds. The default recording period is 6 hours.

Note
  • If a live stream is interrupted during a recording period but is resumed within 3 minutes, the stream is recorded in the same recording before and after the interruption.
  • No new recording is generated for a live stream after the live stream is interrupted for more than 3 minutes. To change the default stream interruption time, submit a ticket to change it in the background.
StreamName String No teststream

The name of the live stream.

StartTime String No 2018-04-10T09:57:21Z

The time when the recording starts. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC.

Note The start time must be within seven days after the stream ingest starts. This parameter takes effect only on the live stream specified by the StreamName parameter. If the StreamName parameter is not specified, this parameter does not take effect.
EndTime String No 2018-04-16T09:57:21Z

The time when the recording ends. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC.

Note The difference between EndTime and StartTime must be within seven days. If the difference exceeds seven days, ApsaraVideo Live considers seven days as the difference. This parameter takes effect only on the live stream specified by the StreamName parameter. If the StreamName parameter is not specified, this parameter does not take effect.
OnDemand Integer No 1

Specifies whether to enable on-demand recording. Valid values:

  • 0: On-demand recording is disabled.
  • 1: ApsaraVideo Live uses an HTTP callback method to determine whether to record a live stream.
  • 2: ApsaraVideo Live parses ingest parameters and performs on-demand recording based on the ingest parameters.
  • 7: By default, ApsaraVideo Live does not automatically record live streams. You can call the RealTimeRecordCommand operation to manually start or stop recording.~~85907~~
Note ~~51831~~If you set the OnDemand parameter to 1, you must call the AddLiveRecordNotifyConfig operation to configure the OnDemandUrl parameter. Otherwise, ApsaraVideo Live does not perform on-demand recording.

Response parameters

Parameter Type Example Description
RequestId String 16A96B9A-F203-4EC5-8E43-CB92E68F4CD8

The ID of the request.

Examples

Sample requests

http(s)://live.aliyuncs.com/? Action=AddLiveAppRecordConfig
&AppName=testApp
&DomainName=www.yourdomain.com
&OssBucket=testBucket
&OssEndpoint=oss-cn-shanghai.aliyuncs.com
&<Common request parameters>

Sample success responses

XML format

<AddLiveAppRecordConfigResponse>
      <RequestId>16A96B9A-F203-4EC5-8E43-CB92E68F4CD8</RequestId>
</AddLiveAppRecordConfigResponse>

JSON format

{
    "RequestId":"16A96B9A-F203-4EC5-8E43-CB92E68F4CD8"
}

Error codes

HttpCode Error code Error message Description
400 InvalidOssBucket.Malformed Specified parameter OssBucket is not valid. The error message returned because the format of the OSS bucket name is invalid. Check whether the value of the OssBucket parameter is correct.
400 InvalidOssBucket.NotFound The parameter OssBucket does not exist. The error message returned because the OSS bucket does not exist. Check whether the value of the OssBucket parameter is correct.
400 InvalidFormat.Malformed Specified parameter Format is not valid. The error message returned because the format specified for the recording is invalid. Check whether the value of the RecordFormat.N.Format parameter is correct.
400 InvalidCycleDuration.Malformed Specified CycleDuration Format is not valid. The error message returned because the format of the recording period is invalid. Check whether the value of the RecordFormat.N.CycleDuration parameter is correct.
400 MissingOssObjectPrefix OssObjectPrefix is mandatory for this action. The error message returned because the name of the recording is not specified. Check whether the value of the RecordFormat.N.OssObjectPrefix parameter is correct.
400 InvalidOssObjectPrefix.Malformed Specified parameter OssObjectPrefix is not valid. The error message returned because the name of the recording is invalid. Check whether the value of the RecordFormat.N.OssObjectPrefix parameter is correct.
400 InvalidSliceOssObjectPrefix.Malformed Specified parameter SliceOssObjectPrefix is not valid. The error message returned because the name of the TS segment is invalid. Check whether the value of the RecordFormat.N.SliceOssObjectPrefix parameter is correct.
400 ConfigAlreadyExists Config has already exist. The error message returned because an existing recording configuration is found.
400 InvalidStartTime.Malformed Specified StartTime is malformed. The error message returned because the format of the start time is invalid. Check whether the value of the StartTime parameter is correct.
400 InvalidEndTime.Malformed Specified EndTime is malformed. The error message returned because the format of the end time is invalid. Check whether the value of the EndTime parameter is correct.

For a list of error codes, visit the API Error Center.