diff --git a/services/discord-gateway/src/modules/voice-recording/videoReceiver.ts b/services/discord-gateway/src/modules/voice-recording/videoReceiver.ts index 2f7c0f64..5b46b398 100644 --- a/services/discord-gateway/src/modules/voice-recording/videoReceiver.ts +++ b/services/discord-gateway/src/modules/voice-recording/videoReceiver.ts @@ -336,6 +336,14 @@ export function hookVideoReceiver( // If a user's video SSRC disappears, close their burst after a short grace so // the tail flushes. + receiver.ssrcMap.on("delete", (data) => { + // data = the deleted VoiceUserData (userId + audioSSRC). Close any open + // video burst for that user so the mux starts as soon as they stop sharing. + if (data?.userId) { + setTimeout(() => closeBurst(data.userId), 500); + } + }); + setInterval(() => { const now = Date.now(); for (const [userId, burst] of bursts) {