- run: bash build-docker.sh
This sample application works as a simple restful server to manage recording in an easy way.
-
Ubuntu 12.04+ x64 or CentOS 6.5+ x64 (CentOS 7+ recommended)
-
GCC 4.4+
-
ARS IP (public IP)
-
1MB+ bandwidth for each simultaneous recording channel
-
Server access for
qos.agoralab.co
-
NodeJS 8.9+
Note: If server access is denied, the Agora SDK may fail to transfer the required data.
This project presumes you have basic ideas of how Agora Recording SDK works, if not please read here carefully before start.
The Agora Recording SDK is not included in the repository. To make everything work, you need to do the following,
- Download the Agora Recording SDK for Linux.
- Unzip the downloaded SDK package.
- Copy the unziped folder to
record/src/sdk
folder - Run
npm install -g node-gyp
to install addon build tool - In terminal change to
record
folder, runbuild.sh
(runbuild_debug.sh
for debugging purpose), if everything goes smoothly, you should see a file namedagorasdk.node
underrecord
folder.
- Change to
record
folder - Ensure
agorasdk.node
has been properly compiled based on previous steps - Change the code in
sdkdemo.js
, replace the placeholder with the appid you registered from Agora Official Website
fs.mkdir(storageDir, {recursive: true}, err => {
//join channel
rec.joinChannel(null, "agoratest", 0, YOUR_APP_ID, storageDir);
})
- Start a Video/Audio conversation using your Agora Video SDK integration with your appid, change the channel name to
agoratest
- Run
node sdkdemo.js
, and you should see your recording files underoutput
folder
The Layout is controlled via function setMixedLayout
.
In this demo we layout user images from top-left to bottom-right.
The demo re-layout the images when new user arrives or existing user leaves.
rec.on("userjoin", function(uid) {
//rearrange layout when user leaves
console.log(`userleave ${uid}`);
layout.regions = layout.regions.filter(function(region){
return region.uid !== uid
})
rec.setMixLayout(layout);
});
rec.on("userleave", function(uid) {
//rearrange layout when user leaves
console.log(`userleave ${uid}`);
//... adding user to layout
rec.setMixLayout(layout);
});
- Ensure
agorasdk.node
inrecord
folder has been properly compiled based on previous steps - Change to
server
folder - Run
npm install
to install server dependencies - Run
node app.js
to start the restful server
http://localhost:3000/recorder/v1/start
Method:
- POST
Parameters:
Name | Mandatory | Type | Desc |
---|---|---|---|
appid | Y | string | agora appid |
channel | Y | string | channel name |
key | N | string | key if certificate is enabled for your appid |
Example:
curl -i -X POST -H "Content-type: application/json" --data '{"appid":"XXXXX","channel":"XXXX","key":"XXXX"}' 127.0.0.1:3000/recorder/v1/start
Sample Response:
{
"success": true,
"sid": "ec8711fb-cd98-4411-a430-a0e8de2c6e98"
}
Response Properties:
Name | Type | Desc |
---|---|---|
success | bool | operation result |
sid | string | sid of this operation, need this to stop recorder |
http://localhost:3000/recorder/v1/stop
Method:
- POST
Parameters:
Name | Mandatory | Type | Desc |
---|---|---|---|
sid | Y | string | sid when you start the recorder |
Sample Response:
{
"success": true
}
Response Properties:
Name | Type | Desc |
---|---|---|
success | bool | operation result |
- See full API documentation in the Document Center
- File bugs about this sample
- See detailed Agora Linux Recording guides
This software is licensed under the MIT License (MIT). View the license.