Skip to main content
Linux C++
Linux Java

Record using the API

The Agora server recording SDK supports recording using the command line and calling the API. Choose a method based on your development use-case. This page shows you how to record by calling the API.

Prerequisites

Before proceeding, ensure that you have integrated the recording SDK and copied the following files to your project:

  • Compiled librecording.so files
  • Files in the bin folder of the AgoraCoreService SDK package.
  • Java files in the SDK package, located in the samples/java/src/io/agora/recording folder:
    • RecordingEventHandler.java
    • RecordingSDK.java
    • /common/Common.java
    • /common/RecordingConfig.java
    • /common/RecordingEngineProperties.java

For example, if the top-level directory of your project is ROOT_DIR, copy the librecording.so files to the ROOT_DIR/lib folder, AgoraCoreService to the ROOT_DIR/bin folder, and the Java files to the ROOT_DIR/src/io/agora/recording folder.

When running the Java program, set the -Djava.library.path=ROOT_DIR/lib parameter to specify the directory address of the dynamic library. Additionally, set the appliteDir parameter in RecordingConfig to ROOT_DIR/bin when you start recording.

Implement recording

Call the following methods to start and stop recording:

Join a channel and start recording

Call the createChannel method with the following parameters to create and join a channel, and then start recording.

  • appId: The App ID of the project. This must be the same as the App ID you passed to the Video SDK.
  • channelKey: If the channel to be recorded uses a token, pass the token in this parameter. See Secure authentication with tokens for details.
  • name: (required) The name of the channel to be recorded.
  • uid: (required) The user ID used for recording. A 32-bit unsigned integer, ranging from 1 to (232-1); must be unique.
  • config: (optional) Recording configuration parameters. If not filled in, the default configuration is used. See RecordingConfig for details.

By default, after the recording instance joins a channel, it starts recording when it detects users in the channel.

If triggerMode is set to MANUALLY_MODE in RecordingConfig, call startService to start recording. After you start recording, you can call stopService to stop recording.

info

Call startService and stopService after joining the channel.

Get the recording file path

After joining the channel, call getProperties to get the storage path of the recording file. The onUserJoined callback, triggered when a user joins the channel, also returns the storage path of the recording file.

End recording

After recording is complete, call leaveChannel to leave the channel and stop recording.

info

To start recording again after recording is complete, create and join the channel again.

By default, when the channel is idle (no user in the channel) for more than 300 seconds, the recording instance automatically exits the channel and stops recording. You can modify this time interval by setting the idleLimitSec parameter in RecordingConfig.

Reference

Refer to the following documents for additional information and troubleshooting:

vundefined