Enabling Recording

Enabling Recording

This page demonstrates how to enable recording.

Step 1: Prepare the Environments

  1. Ensure you have compiled the sample code for communication or live broadcast on the specific platform.
Communication Android, iOS , Windows , Mac or Web
Live Broadcast Android , iOS , Windows , Mac or Web
  1. Download the latest Agora Recording SDK for Linux. The package structure is listed as follows:
../_images/linux_structure.png

Where:

  • bin: applite application video_recorder
  • include: The required header files for developing the recording application
  • libs: The required libraries for developing the recording application
  • samples: Sample code main.cpp (required on this page) and one recording application to launch recording with the command line.
  • tools: Transcoding tools ffmeg.zip and video_convert.py
  1. Ensure your Linux server meets the following requirements: (Agora.io recommends that you upgrade your Linux kernal to 2.9.35 or later for kernal performance optimization.)

    • Ubuntu 12.04 x64 or later
    • CentOS 7 x64 or later
  2. Ensure that the following UDP ports are open: 4001 to 4030, 1080, 8000, and 25000 to communicate with the Agora.io servers.

  3. Ensure that the local ports are not limited by the firewalls. If there is any port conflict or firewall limitations/blocked, it is recommended that you enable ports 4000 to 41000 as the server receive ports and set –lowUdpPort 40000 –highUdpPort 41000 with the command line.

    Note

    Use the command line iptables -L to check the UDP port.

  4. Ensure that the following compiler requirement is satisfied: gcc 4.4 or later.

  5. Get an App ID

Step 2: Compile the Sample Code

Run the following command under the samples directory to compile the sample code:

make

After the compilation, a Record_local executable application is generated in the directory.

Step 3: Enable Recording

Run ./Record_local to check the related usage, for example,

./Recorder_local --appId STRING --uid UINTEGER32 --channel STRING --appliteDir STRING --channelKey STRING --channelProfile UINTEGER32 --isAudioOnly --isVideoOnly --isMixingEnabled --mixResolution STRING --mixedVideoAudio --decryptionMode STRING --secret STRING --idle INTEGER32 --recordFileRootDir STRING --lowUdpPort INTEGER32 --highUdpPort INTEGER32 --getAudioFrame UINTEGER32 --getVideoFrame UINTEGER32 --captureInterval INTEGER32 --cfgFilePath STRING --streamType UINTEGER32
                   --appId     (App Id/must)
                   --uid     (User Id default is 0/must)
                   --channel     (Channel Id/must)
                   --appliteDir     (directory of app lite 'video_recorder', Must pointer to 'Agora_Recording_SDK_for_Linux_FULL/bin/' folder/must)
                   --channelKey     (channelKey/option)
                   --channelProfile     (channel_profile:(0:COMMUNICATION),(1:broadcast) default is 0/option)
                   --isAudioOnly     (Default 0:A/V, 1:AudioOnly (0:1)/option)
                   --isVideoOnly     (Default 0:A/V, 1:VideoOnly (0:1)/option)
                   --isMixingEnabled     (Mixing Enable? (0:1)/option)
                   --mixResolution     (change default resolution for vdieo mix mode/option)
                   --mixedVideoAudio     (mixVideoAudio:(0:seperated Audio,Video) (1:mixed Audio & Video), default is 0 /option)
                   --decryptionMode     (decryption Mode, default is NULL/option)
                   --secret     (input secret when enable decryptionMode/option)
                   --idle     (Default 300s, should be above 3s/option)
                   --recordFileRootDir     (recording file root dir/option)
                   --lowUdpPort     (default is random value/option)
                   --highUdpPort     (default is random value/option)
                   --getAudioFrame     (default 0 (0:save as file, 1:aac frame, 2:pcm frame) /option)
                   --getVideoFrame     (default 0 (0:save as file, 1:h.264, 2:yuv, 3.jpg buffer, 4,jpg file) /option)
                   --captureInterval     (default 5 (Video snapshot interval (second)))
                   --cfgFilePath     (config file path / option)
                   --streamType     (remote video stream type(0:STREAM_HIGH,1:STREAM_LOW), default is 0/option)

Where:

The Recording SDK joins the channel like a dumb client, and it must join the same channel as the Agora Native SDK with the same App ID, but you have two ways to set the parameter uid:

  • Set it as 0, then the system will assign a UID randomly
  • Set it as a unique User ID different from any of the existing UIDs in the same channel
Parameter Mandatory Field Description
appId Yes App ID. See Get an App ID
uid Yes

The user ID: A 32-bit unsigned integer ranging from 1 to (2^32-1). It must be unique.

  • Set it as 0, then the system will assign a UID randomly
  • Set it as a unique User ID different from any of the existing UIDs in the same channel
channel Yes A string providing the unique channel name
channelKey Optional For users who have high security requirements, get a Channel Key according to Get a Channel Key
channelProfile Optional The channel mode: communication (default) or live broadcast
isAudioOnly [6] Optional

Whether only to record the voice content:

  • 0: Record voice and video (default)
  • 1: Record voice only
isVideoOnly [6] Optional

Whether only to record the video content. The parameter is disabled by default.

  • 0: Record voice and video (default)
  • 1: Record video only
isMixingEnabled Optional

Whether to record audio mixing or/and video mixing. The parameter is disabled by default.

  • If isAudioOnly is enabled, this parameter sets whether to enable the audio mixing function
  • If isAudioOnly is disabled, this parameter sets whether to enable audio mixing and video mixing respectively
mixResolution [1] Optional If you enabled the video mixing, with this parameter you can set the resolution in format: width, high, fps, kbps. Namely, the width, height, framerate, and bitrate of the video stream.
decryptionMode Optional Whether to enable the built-in decryption function. The parameter is disabled by default.
mixedVideoAudio Optional

Once you have set isMixingEnabled as true, this parameter allows you to mix audio and video in real time:

  • 0: Mix audio and video respectively (default)
  • 1: Mix audio and video in real time. The format of the mixed audio and video is in mp4.
secret Optional The decryption password after you enabled the decryption mode.
idle [2] Optional The channel idle duration. After this duration, the channel is automatically disconnected. If no user in the channel succeeds the predifined duration, the recording stops automatically. The default value is 300 seconds.
appliteDir Yes The directory that stores the Linux SDK built-in applite application video_recorder. The directory in the SDK is Agora_Recording_SDK_for_Linux_FULL/bin/.
recordFileRootDir [3] Optional The root directory that stores the recording file.
cfgFilePath [3] Optional

It sets the path of the configuration file. In this configuration file, you can set the absolute path of the recording file, and the content in the configuration file must be in Json format.

For example, “Recording_Dir” :”<recording path>”}, where Recording_Dir is fixed and cannot be modified.

lowUdpPort [4] Optional The lowest UDP port
highUdpPort [4] Optional The highest UDP port
getAudioFrame [5] Optional
  • AUDIO_FORMAT_DEFAULT_TYPE = 0: Default audio format
  • AUDIO_FORMAT_AAC_FRAME_TYPE = 1: AAC format
  • AUDIO_FORMAT_PCM_FRAME_TYPE = 2: PCM format
getVideoFrame [5] Optional
  • VIDEO_FORMAT_H264_FRAME_TYPE = 1: H.264 format
  • VIDEO_FORMAT_YUV_FRAME_TYPE = 2: YUV format
  • VIDEO_FORMAT_JPG_FRAME_TYPE = 3: JPG format
  • VIDEO_FORMAT_JPG_FILE_TYPE = 4: JPG format
captureInterval Optional The time intervel of the captured screenshot; one second minimum, five seconds maximum.
streamType Optional The setting will only take effect if the Agora Native SDK enabled the dual-stream mode (high stream by default), otherwise it directly uses the single stream type enabled by the Agora Native SDK.

Footnotes

[1]For mixed resolutions, refer to Join Channel (joinChannel).
[2]The default value for idleLimitSec is 300 seconds. Ensure the value is set no less than 3 seconds, and the idle time will also be billed.
[3](1, 2) Do not set recordFileRootDir and cfgFilePath at the same time.
[4](1, 2) All the ports being set must be positive integers, and the value of highUdpPort - lowUdpPort must be no less than 4.
[5](1, 2) When the raw data function is enabled, it does not support mixing video. The web currently only supports raw audio data, not raw video data.
[6](1, 2) Do not set isAudioOnly and isVideoOnly as 1 at the same time.