Help Center/ SparkRTC/ User Guide/ Cloud Recording Management/ Configuring a Recording Rule
Updated on 2023-10-16 GMT+08:00

Configuring a Recording Rule

SparkRTC records real-time communication content and stores the recordings in OBS buckets. You can download and share the recordings in OBS. Figure 1 shows the operation process.

Figure 1 Recording process
  1. Create an OBS bucket for storing recordings. If you already have one, go to 2.
  2. Authorize SparkRTC to store recordings in the bucket.
  3. Configure a recording rule for real-time communication. Then you can use the recording rule ID to start a recording task. The recording will be stored in OBS based on the recording settings. You can set a callback URL to obtain notifications about the recording status.
  4. Record content of real-time communication. You can call SparkRTC APIs to start, query, and control cloud recording tasks. SparkRTC performs single-stream recording on images based on the recording rule ID in the API calling request.
  5. View recordings. After the recording is complete, you can receive the callback message of the recording task in the configured callback URL. You can obtain the basic information about the recordings and manage the recordings in OBS, such as downloading, sharing, and deleting them.

    The resolution of recordings is the same as that of the pushed streams.

Notes

  • Only one recording rule can be configured for an app in each region.
  • Recording will fail if OBS is suspended due to arrears. Ensure that OBS is running properly before starting the recording.
  • Ensure that OBS is not suspended due to arrears. Otherwise, recording will fail. You are advised to buy an OBS package.

Prerequisites

Billing

  • Recording is a billing item based on the total duration of recordings. For details, see SparkRTC Pricing Details.
  • Recordings are stored in OBS buckets. Therefore, OBS charges you for the storage. For details, see OBS Pricing Details.

Step 1: Create an OBS Bucket

If you do not have an OBS bucket for storing recording files, create a bucket by referring to OBS Documentation. If you already have one, go to Step 2: Authorize Access to the OBS Bucket.

Currently, recordings can be stored only in OBS buckets in CN North-Beijing4.

Step 2: Authorize Access to the OBS Bucket

Authorize SparkRTC to store recordings in OBS buckets. For details, see OBS Authorization.

Step 3: Configure a Recording Rule

  1. Log in to the SparkRTC console.
  2. In the navigation pane, choose Apps.
  3. Click Configure in the row of the app for which a recording callback needs to be created.

    The Configuration page is displayed.

  4. In the Recording Rule area, click Add. The Add Recording Rule page is displayed.

    Only one recording rule can be configured for an app in each region.

  5. Configure recording parameters according to Table 1.
    Table 1 Recording parameters

    Parameter

    Description

    Storage Bucket

    OBS bucket where the recording is stored.

    Currently, recorded files can be stored only in OBS buckets of CN North-Beijing4.

    Region

    Region where the OBS bucket is deployed.

    Storage Path

    Path of the OBS bucket where the recording is stored.

    Record As

    Recording format, which can be HLS and MP4.

    HLS

    File Naming

    Storage path and filename prefix of M3U8 files.

    Default format:
    {app_id}/{record_format}/{stream}_{file_start_time}/{stream}_{file_start_time}

    The meanings of the preceding variables are as follows:

    • app_id: app ID
    • record_format: recording format
    • stream: stream name
    • file_start_time: file generation time

    Recording Length

    The recording length can be 0 or 1 to 720 minutes (12 hours). If a stream has been recorded for more than 12 hours, another file will be created based on the naming rule. If the recording length is 0, the entire stream is recorded as a file.

    Max Stream Pause Length

    Values:

    • Generate a new file when a stream is paused
    • Do not generate a new file when a stream is paused: The maximum stream pause length is 30 days.
    • Other: If the stream pause length is within the specified range, the system does not generate a new file. Otherwise, a new file is generated.

    MP4

    File Naming

    Storage path and filename prefix of MP4 files.

    Default format:
    {app_id}/{record_format}/{stream}_{file_start_time}/{stream}_{file_start_time}

    The meanings of the preceding variables are as follows:

    • app_id: app ID
    • record_format: recording format
    • stream: stream name
    • file_start_time: file generation time

    Recording Length

    The recording length ranges from 1 to 180 minutes (3 hours). If a stream has been recorded for more than 3 hours, another file will be created based on the naming rule.

    Max Stream Pause Length

    Values:

    • Generate a new file when a stream is paused
    • Other: If the stream pause length is within the specified range, the system does not generate a new file. Otherwise, a new file is generated.
  6. Click OK.

  7. In the recording rule list, enable automatic recording as required. When automatic recording is enabled, if a new room is created under the app, the system automatically performs single-stream recording during real-time communication in the room based on the configured recording rule.

    Automatic recording takes effect only for rooms created under the app after you enable it.

Step 4: Record Content

After the recording rule is configured, call the SparkRTC APIs to start a cloud recording task. SparkRTC records real-time audio and video content based on the recording rule ID in the API calling request.

Step 5: View Recordings

When the recording is complete, view recordings on the OBS console or through callback messages.

  • Viewing recordings on the OBS console
    1. In the navigation pane of the OBS console, choose Object Storage.
    2. In the bucket list, click the bucket that stores SparkRTC recordings.

      The Overview page is displayed.

    3. In the navigation pane, choose Objects to view the recording information.
    4. Download and share the recordings as required. For details, see OBS Documentation.
  • Viewing recordings through callback messages

    If you configure a recording callback URL, you will receive a recording callback message each time a recording is generated. For details about the configuration method and message fields, see Configuring Recording Callback.