In individual recording mode, Agora Cloud Recording generates one audio and/or video file for each UID. If you want to merge each UID's audio and video files into one file, you can use our Audio & Video File Merging script.
Recommended systems for transcoding:
- Ubuntu 14.04 and later x64
- CentOS 6.5 and later (7.0 recommended) x64
To run the script, you need to install Python 2, version 2.7 or later.
- Use Agora Cloud Recording to generate the audio and/or video files. The transcoding will fail if any of the recorded files is missing.
- Ensure that the recorded files are stored in an accessible directory.
1. Get the merging script
Download the Agora Audio & Video File Merging script and decompress it. Find
ffmpeg.tar.gz, and make sure it is in the same directory as
2. Execute the Audio & Video File Merging script
You can start transcoding the files after you set the parameters.
You can get the options with the
python convert.py command.
Or you can refer to the following table to learn about the transcoding options:
||Specify the directory of the recorded files to be transcoded. If the directory contains files generated during several recording instances, the transcoding script transcodes all the files by the order of the recording instances.|
||Set the transcoding mode: See -m Options for details.
||Set whether or not to include the period when a user is absent from a channel. If you do not set
||Set the frame rate of the transcoded video. The default rate is 15 fps. The value range is from 5 fps to 120 fps. If
||Set the resolution of the transcoded video in the format of “width height”, for example,
Before introducing the
-m options, we'll first explain the concept of a recording segment. A recording segment starts when Agora Cloud Recording starts recording a UID and ends when Agora Cloud Recording stops recording a UID.
Agora Cloud Recording starts recording a UID only when all the following conditions are met:
- The UID joins the channel and starts sending audio or video streams.
- You start Agora Cloud Recording
Agora Cloud Recording stops recording a UID as long as one of the following conditions is met:
- The UID stops sending streams and does not send streams again within 15 seconds
- The UID leaves the channel and does not rejoin within 15 seconds
- You stop Agora Cloud Recording
See Example for more information about the recording segment.
Now, let's see the behaviors of different
We assume that each UID in the channel generates several audio files and video files.
0: Merge the audio and video files of the same UID based on the recording segment. One recording segment of one UID corresponds to one merged file, named as
UID_timestamp_av.mp4. In the filename,
timestampis the time when Agora Cloud Recording starts recording. If Agora Cloud Recording starts to record the audio and video at different times,
timestampis the earlier one of the two starting times. The time zone of
timestampis UTC+0. The
timestampparameter consists of the year, month, day, hour, minute, second, and millisecond. For example,
100_20190611073246073_av.mp4is a merged file for UID 100 and the start time of the recording is 07:32:46.073 a.m., June 11, 2019.
1: Merge the audio and video files of the same UID into one file. One UID corresponds to one file, named as
2: Merge the audio files of the same UID into one audio file. One UID corresponds to one file, named as
UID_0_merge.m4a. The file uses AAC encoding. You can use the Agora Format Converter script to transcode the file to other formats, such as MP3.
3: Merge the video files of the same UID into one video file (no audio). One UID corresponds to one file, named as
The following examples show different merged files with different
Suppose that two users, with UIDs 100 and 125, stay in the channel, and you start Agora Cloud Recording in individual recording mode. UID 100 leaves the channel and rejoins the channel in 30 seconds, thus causing two segments in this recording instance. When the recording ends, UID 100 has four recorded files: one audio file and one video file for each of the two segments. UID 123 has one audio file and one video file.
To merge the audio and video files of the same UID into one file, use the following command:
convert.py -f <directory of the files to be transcoded> -m 1 -s -p 30 -r 640 360
Two files are generated after transcoding:
123_0_merge_av.mp4. The 30 seconds when UID 100 is absent is not included in the merged file. To include the time interval, do not set
To merge the audio and video files of the same UID based on the recording segment, use the following command:
convert.py -f <directory of the files to be transcoded> -m 0 -p 30 -r 640 360
Three files are generated after transcoding:
convert-done.txt file is generated after the transcoding is complete. Once the transcoding script is used, a
convert.log file is generated in the same directory as the audio and video files upon completion of the transcoding.
The transcoded MP4 file supports most mainstream media players. See the following table for details:
|Operating System||Media Players|