i'm using egress to record the room composit with ...
# ask-ai
s
i'm using egress to record the room composit with this code in next js, await egressClient.*startRoomCompositeEgress*( roomName, { file: fileOutput, }, { layout: "speaker", } ); i want the code to record the human audio track only, and one for human audio and video
t
Thanks for reaching out, Mostafa. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding to your request about recording (1) only a human’s audio, and (2) that human’s audio+video. You showed code using Room Composite Egress, so I’ll explain what you can and can’t do with that and show the approach that will work. Short answer • Room Composite Egress always records the room’s composed output (what a browser would render) and can’t selectively record only one participant’s track. • To record a single participant’s audio or that participant’s audio+video, use Track Composite Egress (or Track Egress for raw audio-only files). What to use and why • Room Composite Egress: captures the full composited room (all participants as laid out). Not suitable for “human-only” track capture. • Track Composite Egress: designed to produce a composite for a single participant — useful when you want audio-only for that participant or that participant’s audio+video. • Track Egress: exports an individual raw track (good for audio-only files like OGG when you don’t need a video stream). Example snippets (Next.js / JS SDK) 1) Record only the human audio (use Track Composite Egress or Track Egress) • Option A — Track Composite Egress (audio-only output):
Copy code
await egressClient.startTrackCompositeEgress(roomName, {
  audioTrackId: "audio-track-sid",   // the human's audio track SID
  videoTrackId: "",                  // empty/omitted for audio-only composite
  file: fileOutput,                  // e.g. { type: "file", url: "s3://..." }
});
• Option B — Track Egress (raw audio file, e.g. ogg):
Copy code
await egressClient.startTrackEgress(roomName, {
  trackId: "audio-track-sid",
  file: fileOutput, // produces raw audio file like .ogg
});
2) Record the human’s audio + video (Track Composite Egress)
Copy code
await egressClient.startTrackCompositeEgress(roomName, {
  audioTrackId: "audio-track-sid",
  videoTrackId: "video-track-sid",
  file: fileOutput,
});
How to get the track IDs (SIDs) • Use server-side APIs or webhooks that list participants and their published tracks (for example, list participants / track_published events) to obtain the correct
audioTrackId
/
videoTrackId
. Quick clarifying questions 1. How do you identify the “human” participant? By participant identity, metadata, or another method? 2. Can you access track SIDs server-side (e.g., via ListParticipants or webhooks)? 3. Which output format do you want for the audio-only case (composited audio file like mp4, or raw audio like ogg)? If you tell me how you identify the participant and whether you can fetch track SIDs, I’ll provide exact code you can drop into your Next.js server flow and the precise API call/parameters for your SDK version. Sources: Universal Egress | Live Conversations with AI using ChatGPT and WebRTC