When is the best time to start an egress recording...
# ask-ai
s
When is the best time to start an egress recording when calling a new user? Right now, I have a about 5 seconds of empty recording at the beginning of each recording.
t
Thanks for reaching out, aric. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — that's a great question. You're seeing ~5 seconds of empty audio because the egress starts before the new participant is actually sending media. What to do • Start the egress after the participant has joined and begun publishing audio. • Best trigger: wait for the
participant_joined
webhook, and preferably the
track_published
webhook for the participant’s audio track before calling StartRoomCompositeEgress (or your egress start API). Why this helps • If egress starts before media is present, it will record silence until the track is published. Waiting for
track_published
ensures media is available and avoids the empty segment. If you want, tell me which events you currently listen for (or share a short snippet of your webhook logic) and I’ll suggest the exact place to call the egress start. Sources: Webhooks | LiveKit docs
s
Is there an ffmpeg command to remove the first silent part of an audio file ?
t
Yes — use ffmpeg's silenceremove filter. Example commands: 1) Remove leading silence only:
Copy code
ffmpeg -i input.wav -af "silenceremove=start_periods=1:start_threshold=-50dB:start_silence=0.5" -y output.wav
2) Remove leading and trailing silence:
Copy code
ffmpeg -i input.wav -af "silenceremove=start_periods=1:start_threshold=-50dB:start_silence=0.5:stop_periods=1:stop_threshold=-50dB:stop_silence=0.5" -y output.wav
Notes: • Adjust
-50dB
(threshold) and
0.5
(minimum silence duration in seconds) to match your audio. • If your input is compressed (mp3, m4a), use a lossless intermediate (e.g., WAV) to avoid artifacts, or add
-c:a pcm_s16le
when writing WAV. Sources: Enhanced noise cancellation | LiveKit docs
s
who is in charge of the recording when I start an egress ? Is it livekit cloud ? Or is it my livekit agent?
t
Good question — happy to clarify. You're asking whether LiveKit Cloud or your LiveKit agent is in charge of the recording when you start an egress. • The recording itself is performed by the LiveKit Egress service. ◦ If you use LiveKit Cloud, the Egress service in LiveKit Cloud captures, encodes, and exports the media. ◦ If you self-host, the Egress service runs on your infrastructure and you manage those instances. • Your LiveKit agent (or any server-side component) can trigger or manage egress (for example by calling
StartRoomCompositeEgress
), but it does not perform the actual media capture/encoding. If you want, tell me whether you’re on LiveKit Cloud or self-hosting and I’ll outline any operational responsibilities you should watch for. Sources: Universal Egress | Self-hosting the Egress Service | LiveKit docs | Rooms, participants, and tracks | LiveKit docs