what’s the proper way to handle recordings for cal...
# ask-ai
r
what’s the proper way to handle recordings for call that cycle fast or are very short?I’m getting this error for this ones
Stop called before pipeline could start .
I wanna make sure that I don’t introduce slowdowns as we stop recordings before transfer so don’t want to introduce delays
✅ 1
t
Thanks for reaching out, luisa. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m replying about handling recordings for very short / fast-cycling calls and the “Stop called before pipeline could start” error. Short answer (what to do) • Avoid starting an egress for calls you expect to be extremely short. If recording isn’t required for sub-second or few-second calls, skip starting egress. • If you must record, only stop egress after you confirm it is actually running (don’t call stop immediately after start). • Use non-blocking logic (async stop) and status checks so stopping doesn’t add synchronous delay to your transfer flow. Concrete options to implement • Confirm egress started: ◦ Wait for the egress_started / EGRESS_ACTIVE event (webhook or API) before calling stop. ◦ Or poll the egress status (e.g., listEgress / status) and only stop when active. • Minimal delay fallback: ◦ If events aren’t available for your flow, add a very short non-blocking grace period (e.g., a few hundred ms) before calling stop to reduce race conditions. • Skip start for very short sessions: ◦ Detect short sessions (duration threshold) and don’t start egress at all. This prevents the start-stop race entirely. • Use backup/manifest recovery: ◦ If upload failures occur, rely on backup egress and the manifest location returned on egress_ended to recover recordings. Why this fixes the error and avoids slowdowns • The error happens because stop is called before the pipeline finishes initializing. Waiting for an active signal or using a tiny async delay prevents the race without blocking your transfer logic. • Use async patterns so the stop process doesn’t block transfer paths. If you want, tell me: • Which egress method you use (room composite vs track egress) and which SDK/language you’re calling from — I’ll give a short example (webhook or poll-based) you can drop into your flow. Sources: Backup Egress Recordings | server-sdk-js | livekit/livekit_composite | DeepWiki | Python SDKs | livekit/livekit_composite | DeepWiki | Why is my Agent insights data missing? | LiveKit | Why is my Agent insights data missing? | LiveKit, with interactive elements
r
how do I know that? Avoid starting an egress for calls you expect to be extremely short. If recording isn’t required for sub-second or few-second calls, skip starting egress
t
Good question — here are practical ways to decide when to skip starting egress for very short calls, and how to implement each approach without adding slowdown. Quick strategies • Threshold by elapsed time (simplest): only start egress if the call reaches a minimum duration (e.g., 2–5 seconds). Start a timer on call start and cancel starting egress if the call ends before the threshold. • Deferred start: begin the call immediately but delay starting egress until the call has been active for the threshold (start a non-blocking timer; if call ends first, never start). • Start-on-demand: don’t start egress at call start; start it only when a trigger occurs (e.g., user presses record, certain events happen, or media activity crosses a threshold). • Activity-based heuristics: start egress when you detect sustained media activity — e.g., X ms of continuous audio above a volume level, or reliable track subscription — rather than immediately on join. • Hybrid: start egress only for calls with N participants or when a participant role (moderator/agent) joins. Implementation notes to avoid slowdowns • Use non-blocking timers and async APIs so timers/checks don’t block transfer flows. • Rely on events (webhook or SDK events) rather than synchronous waits to confirm egress state. • If you must start egress immediately in some flows, implement a short grace period (e.g., 200–500 ms) before calling stop to avoid the “Stop called before pipeline could start” race. Suggested thresholds (examples to tune) • Very short calls: < 2 seconds — skip recording. • Short calls: 2–5 seconds — consider deferred start or start-on-demand. • Normal: > 5 seconds — start egress immediately. Questions so I can give exact code/examples • Which egress type do you use: room composite or track egress? • Which SDK / language or server environment are you implementing this in? • Do you want event-based (webhook/egress_started) or local-timer based logic? Tell me those and I’ll provide a minimal example you can drop into your flow. , with interactive elements
r
Room Composite Egress. how is it different?
t
Thanks — I’ll explain how Room Composite Egress differs and what that means for short/fast calls and the stop-before-start error. How Room Composite Egress differs • What it records: Room Composite captures the whole room as a single composite output (multiple tracks mixed into one file or stream), unlike Track Egress which records individual participant tracks separately. • Initialization: Composite pipelines do more work (mixing, layout, encoding) so they can take slightly longer to become fully active than a single track egress. • Use cases: Best when you want a single stitched recording or a specific visual layout (grid, spotlight, etc.). Not ideal when you only need one participant’s audio or separate per-track files for short interactions. Implications for short/fast calls • Higher chance of race: Because the composite pipeline needs to initialize (layout computation, mixers, encoders), stopping it very quickly after starting is more likely to trigger “Stop called before pipeline could start.” • Prefer deferred/start-on-demand: For very short sessions, skip starting composite egress until you know the call will last (timer threshold, sustained media, or explicit user action). • If you must start immediately: Wait for confirmation the composite egress is active (egress_started / EGRESS_ACTIVE webhook or poll listEgress) before calling stop, or use a small non-blocking grace period (hundreds of ms) to avoid the race. Practical recommendations • If you only need a single participant or per-track files for short calls, consider Track Egress instead — it initializes faster and reduces composite overhead. • For Room Composite: ◦ Use deferred start: start egress after N seconds of call duration or after detecting sustained media. ◦ Use event-based stop: only call stop after receiving
egress_started
(webhook) or confirming
active
via API. ◦ Make stop async/non-blocking so it won’t delay transfers. • Consider skipping recording entirely for calls under your chosen threshold. If you want, I can provide: • A small webhook-based flow example for Room Composite (start → wait for egress_started → stop), or • A timer-based snippet for your language/SDK. Which language are you using?, with interactive elements