Participant Track Recording - Android
VideoSDK provides participant track recording, creating separate audio or video files for participant.
New files are generated when a participant starts their audio or video again after turning it off (e.g., unmuting the microphone or restarting the camera). This ensures that each file represents a continuous segment of audio or video content.
Once track recording is complete, all audio files for a participant are consolidated into a single directory, as are the video files.
Start Participant Track Recording
To start a participant track recording, you will have to call /v2/recordings/participant/track/start
API with following body parameters.
roomId
: RoomId for which the participant track recording is to be startedparticipantId
: participantId of the participant to be recorder.kind
: The kind of tracks you want to record.- You can pass following values:
audio
|video
|screen_audio
|screen_video
- You can pass following values:
fileFormat
: Currently onlywebm
is supported as file format. We will add the support for other formats in future.webhookUrl
: The webhook URL where you would like to get the status updates of the recording. To learn more about webhooks refer here.bucketDirPath
: If you are using your own storage, you can provide the directory path where you want to store the recording. To configure the storage please refere this quide.
The usual recording path would look like ${sessionId}/${participantId}/${kind}/${filename}
.
- Kotlin
- Java
import org.json.JSONObject
import java.io.OutputStream
import java.net.HttpURLConnection
import java.net.URL
import java.io.IOException
fun StartTrackRecording() {
val roomId = "<YOUR ROOM ID>"
val participantId = "<PARTICIPANT ID>"
val kind = "<YOUR STREAM KIND>"
val fileFormat = "<YOUR FILE FORMAT>"
val bucketDirPath = "<YOUR CLOUD STORAGE BUCKET PATH>"
val webhookUrl = "<YOUR WEBHOOK URL>"
try {
val url = URL("https://api.videosdk.live/v2/recordings/participant/track/start")
val conn = url.openConnection() as HttpURLConnection
conn.requestMethod = "POST"
conn.setRequestProperty("Authorization", "$YOUR_TOKEN")
conn.setRequestProperty("Content-Type", "application/json")
conn.doOutput = true
val jsonBody = JSONObject()
jsonBody.put("roomId", roomId)
jsonBody.put("participantId", participantId)
jsonBody.put("kind", kind)
jsonBody.put("fileFormat", fileFormat)
jsonBody.put("bucketDirPath", bucketDirPath)
jsonBody.put("webhookUrl", webhookUrl)
conn.outputStream.use { os: OutputStream ->
val input = json.toString().toByteArray(Charsets.UTF_8)
os.write(input, 0, input.size)
}
val responseCode = conn.responseCode
if (responseCode == HttpURLConnection.HTTP_OK) {
println("Track Recording started successfully.")
} else {
println("Failed to start track recording.")
}
} catch (e: Exception) {
e.printStackTrace()
}
}
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import org.json.JSONObject;
public void StartTrackRecording() {
String roomId = "<YOUR ROOM ID>";
String participantId = "<PARTICIPANT ID>";
String kind = "<YOUR STREAM KIND>";
String fileFormat = "<YOUR FILE FORMAT>";
String bucketDirPath = "<YOUR CLOUD STORAGE BUCKET PATH>";
String webhookUrl = "<YOUR WEBHOOK URL>";
try {
URL url = new URL("https://api.videosdk.live/v2/recordings/participant/track/start");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Authorization", "$YOUR_TOKEN");
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);
JSONObject jsonBody = new JSONObject();
jsonBody.put("roomId", roomId);
jsonBody.put("participantId", participantId);
jsonBody.put("kind", kind);
jsonBody.put("fileFormat", fileFormat);
jsonBody.put("bucketDirPath", bucketDirPath);
jsonBody.put("webhookUrl", webhookUrl);
try (OutputStream os = conn.getOutputStream()) {
byte[] input = json.toString().getBytes("utf-8");
os.write(input, 0, input.length);
}
int responseCode = conn.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
System.out.println("Track Recording started successfully.");
} else {
System.out.println("Failed to start track recording.");
}
} catch (Exception e) {
e.printStackTrace();
}
}
Stop Participant Track Recording
To stop a participant track recording, you will have to call /v2/recordings/participant/track/stop
API with following body parameters.
roomId
: RoomId for which the participant track recording is to be stoppedparticipantId
: participantId for which the recording is to be stopped.kind
: The kind of track recording you want to stop for the given participant.- You can pass following values:
audio
|video
|screen_audio
|screen_video
- You can pass following values:
- Kotlin
- Java
import org.json.JSONObject
import java.io.OutputStream
import java.net.HttpURLConnection
import java.net.URL
fun StopTrackRecording() {
val roomId = "<YOUR ROOM ID>"
val participantId = "<PARTICIPANT ID>"
val kind = "<YOUR STREAM KIND>"
try {
val url = URL("https://api.videosdk.live/v2/recordings/participant/track/stop")
val conn = url.openConnection() as HttpURLConnection
conn.requestMethod = "POST"
conn.setRequestProperty("Authorization", "$YOUR_TOKEN")
conn.setRequestProperty("Content-Type", "application/json")
conn.doOutput = true
val jsonBody = JSONObject()
jsonBody.put("roomId", roomId)
jsonBody.put("participantId", participantId)
jsonBody.put("kind", kind)
conn.outputStream.use { os: OutputStream ->
val input = json.toString().toByteArray(Charsets.UTF_8)
os.write(input, 0, input.size)
}
val responseCode = conn.responseCode
if (responseCode == HttpURLConnection.HTTP_OK) {
println("Track Recording stopped successfully.")
} else {
println("Failed to stop track recording.")
}
} catch (e: Exception) {
e.printStackTrace()
}
}
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import org.json.JSONObject;
public void StopTrackRecording() {
String roomId = "<YOUR ROOM ID>";
String participantId = "<PARTICIPANT ID>";
String kind = "<YOUR STREAM KIND>";
try {
URL url = new URL("https://api.videosdk.live/v2/recordings/participant/track/stop");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Authorization", "$YOUR_TOKEN");
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);
JSONObject jsonBody = new JSONObject();
jsonBody.put("roomId", roomId);
jsonBody.put("participantId", participantId);
jsonBody.put("kind", kind);
try (OutputStream os = conn.getOutputStream()) {
byte[] input = json.toString().getBytes("utf-8");
os.write(input, 0, input.length);
}
int responseCode = conn.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
System.out.println("Track Recording stopped successfully.");
} else {
System.out.println("Failed to stop track recording.");
}
} catch (Exception e) {
e.printStackTrace();
}
}
Webhook associated with Participant Track Recording
participant-track-recording-starting
- A "Participant Track Recording Starting" webhook is triggered when the track recording process for a participant is initiated.
Example
{
"webhookType": "participant-track-recording-starting",
"data": {
"meetingId": "jvsg-8rjn-j304",
"sessionId": "613731342f27f56e4fc4b6d0",
"participantId": "abcd",
"kind": "audio",
},
}
participant-track-recording-started
- Participant Track Recording started webhook will be received when successfully track recording is started in meeting
Example
{
"webhookType": "participant-track-recording-started",
"data": {
"meetingId": "jvsg-8rjn-j304",
"sessionId": "613731342f27f56e4fc4b6d0",
"participantId": "abcd",
"kind": "audio",
},
}
participant-track-recording-stopping
- A "Participant Track Recording Stopping" webhook is triggered when the track recording end process for a participant is initiated.
Example
{
"webhookType": "participant-track-recording-stopping",
"data": {
"meetingId": "jvsg-8rjn-j304",
"sessionId": "613731342f27f56e4fc4b6d0",
"participantId": "abcd",
"kind": "audio",
},
}
participant-track-recording-stopped
- Participant Track Recording stopped webhook will be received when track recording is successfully stopped in meeting.
Example
{
"webhookType": "participant-track-recording-stopped",
"data": {
"meetingId": "jvsg-8rjn-j304",
"sessionId": "613731342f27f56e4fc4b6d0",
"participantId": "abcd",
"kind": "audio",
"fileDetails" : [
{
"filePath" : "/encoded/videos/62d148951a1eb20029fc9b05.mp4",
"fileUrl" : "https://cdn.videosdk.live/encoded/videos/62d148951a1eb20029fc9b05.mp4",
}
]
},
}
participant-track-recording-failed
- A "Participant Track Recording Failed" webhook is generated when the track recording process encounters an interruption or issue during either the starting or stopping phases.
Example
{
"webhookType": "participant-track-recording-failed",
"data": {
"meetingId": "jvsg-8rjn-j304",
"sessionId": "613731342f27f56e4fc4b6d0",
"participantId": "abcd",
"kind": "audio",
},
}
API Reference
The API references for all the methods utilized in this guide are provided below.
Got a Question? Ask us on discord