We working on livit session recording . We deploye...
# ask-ai
m
We working on livit session recording . We deployed our egress and livekit in self hosted server. What is best way to record the session with less infra support. I choose track egress but mixing is not happening properly. Any repos who already did recording this way and succeeded. Can u guide me if we have any other ways
✅ 1
t
Thanks for reaching out, Sanath. 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 question about recording LiveKit sessions with minimal infra, and the mixing problems you hit with track egress. Short answer: use Room Composite egress instead of Track Egress for reliable mixed recordings with minimal post-processing. Why: • Track Egress exports separate raw tracks and does not do automatic audio/video mixing or sync, so you’ll need extra processing to combine tracks correctly. • Room Composite runs a headless Chrome compositor + GStreamer to render layouts, mix audio/video, and produce final MP4/WebM (or RTMP) output — which removes most infra and post-processing work. Practical recommendations: • Switch to Room Composite egress for session recordings when you want a single mixed file (MP4/WebM). • Use built-in layout templates (speaker, gallery, etc.) so you don’t need to build a compositor yourself. • Configure output to S3/GCS (or local disk) and consume egress webhooks (
egress_started
/
egress_ended
) to track status and cleanup. • If you must keep Track Egress (e.g., for per-track archival), run a lightweight post-processing step to mux/sync tracks (FFmpeg) — but this adds infra and complexity. Examples / references: • Look at the LiveKit composite examples and the /meet example that show production-ready egress flows and templates. • There are example repos demonstrating Composite/Room egress usage (see the LiveKit composite examples). Quick question to help next: • Do you need recorded output as a single mixed file (one MP4), or do you require individual tracks for later processing? If you say which output you want and where you want to store files (S3/local), I’ll give step-by-step egress configuration and a sample request you can run on your self-hosted setup. Sources: Universal Egress | LiveKit | server-sdk-js | livekit/livekit_composite | DeepWiki | examples/other | livekit/livekit_composite | DeepWiki | examples/voice_agents | livekit/livekit_composite | DeepWiki | Why is there extra audio at the end of my recordings of an agent session? |..., with interactive elements
m
I need both i.e one mp4 file and individual tracks for analysis.
t
Thanks — I’m responding to your need for both a single mixed MP4 and individual tracks. Recommended approach (minimal infra): • Start a Room Composite egress to produce the mixed MP4 (uses headless Chrome + GStreamer to handle layout, sync, and mixing). • Simultaneously start Track Egress (or Track Composite for per-participant synced AV) to capture individual raw tracks for analysis. Why this works: • Room Composite gives you a ready-to-use mixed file without building your own compositor or post-processing pipeline. • Track Egress preserves per-track data for analysis; pairing with Track Composite can give per-participant combined AV if you prefer that to fully separate files. How to implement (high level): 1. When the room/session starts (or on demand), trigger two egress jobs: a. Room Composite egress -> output MP4/WebM to S3/GCS or local disk. b. Track Egress (or Track Composite per participant) -> output per-track files to S3/GCS or local disk. 1. Use egress webhooks (
egress_started
,
egress_ended
) to monitor job status and store resulting file URLs. 2. If storing locally, move finished files to long-term storage (S3/GCS) for analysis and download. 3. Optionally kick off an analysis pipeline once track files are available. Practical tips: • Use Room Composite layout templates (speaker/gallery) to get a clean MP4 without building layouts. • If you need per-participant AV (audio+video together), use Track Composite per participant instead of raw Track Egress audio-only/video-only outputs. • Start both egress jobs nearly simultaneously to keep timing consistent. Room Composite handles final sync; track files may still need careful timestamp handling if you later correlate events. • For lower infra overhead: let LiveKit handle mixing (Room Composite) and push files straight to S3/GCS rather than storing/processing locally. Next step I can provide: • Sample API requests for Room Composite and Track/Track Composite egress tailored to self-hosted LiveKit. • Example webhook handling snippet and recommended storage configuration. Would you like the sample API requests and webhook example now? If so, tell me whether you prefer S3 or local storage and if you want per-participant
Track Composite
or raw
Track Egress
files. , with interactive elements
m
So u don't have any existing code for mixing the raw track egress files
t
Thanks — I’m replying about whether we have existing code to mix raw Track Egress files. Short answer: LiveKit does not provide any official code or repos that mix raw Track Egress outputs into a single file. Track Egress deliberately exports separate, unmixed tracks (audio/video) and does not perform synchronization/mixing. What I recommend (practical options): • Use Room Composite egress to produce the single mixed MP4 automatically, and run Track Egress (or Track Composite per participant) alongside it to keep individual track files for analysis. This avoids building your own mixer. • If you must mix raw track files yourself, do post-processing outside LiveKit (FFmpeg or GStreamer). LiveKit has no official mixing scripts — you’ll need to write a small pipeline to align timestamps and mux tracks into MP4. I can help next with whichever you prefer: • Provide sample API requests to start Room Composite + Track Egress together. • Provide an example FFmpeg command and guidance to mux/sync typical raw egress files into one MP4. Which would you like? (Room Composite + Track Egress samples or an FFmpeg mixing example?) Sources: Universal Egress | LiveKit | server-sdk-js | livekit/livekit_composite | DeepWiki, with interactive elements
m
Ffmpeg mixing example
t
Thanks — responding with an FFmpeg example to mix LiveKit raw track egress files into one MP4. Notes before running: • Track egress often gives audio as Opus in .ogg and video as VP8 in .ivf (or H.264 in .mp4). Commands below cover common combos. • Timestamps must be preserved; use the original files produced by egress. If codecs are already MP4-compatible (H.264 + AAC), you can remux; otherwise transcode. 1) If you have video as H.264 in MP4 and audio as Opus in OGG — transcode audio to AAC and mux:
Copy code
ffmpeg -i video.mp4 -i audio.ogg -c:v copy -c:a aac -b:a 128k -map 0:v:0 -map 1:a:0 -shortest output.mp4
2) If video is VP8 in IVF and audio is Opus in OGG — transcode video to H.264 and audio to AAC, then mux:
Copy code
ffmpeg -f ivf -i video.ivf -i audio.ogg -c:v libx264 -preset veryfast -crf 23 -c:a aac -b:a 128k -map 0:v:0 -map 1:a:0 -shortest output.mp4
3) If you have separate per-participant video and audio tracks (N participants), first align durations and then merge. Example for two participants (v1,a1) + (v2,a2) into a side-by-side gallery layout using filter_complex:
Copy code
ffmpeg \
  -i v1.mp4 -i a1.ogg \
  -i v2.mp4 -i a2.ogg \
  -filter_complex "
    [0:v]scale=640:360[pv1];
    [2:v]scale=640:360[pv2];
    [pv1][pv2]hstack=inputs=2[vout];
    [1:a][3:a]amerge=inputs=2[aout]
  " \
  -map "[vout]" -map "[aout]" -c:v libx264 -crf 23 -preset veryfast -c:a aac -ac 2 -shortest output.mp4
• amerge produces a multi-channel stream; use
-ac 2
to downmix to stereo if needed. • Adjust scales, layout, and codecs to match quality/CPU constraints. 4) If raw timestamps drift or files start at different times, use
-itsoffset
to shift inputs:
Copy code
ffmpeg -itsoffset 0.5 -i audio.ogg -i video.mp4 -c:v copy -c:a aac output.mp4
(positive value delays that input by 0.5s) Helpful flags: •
-shortest
stops at shortest stream length. •
-map
controls which streams to include. •
-async 1
or
-vsync 2
can help with A/V sync in tricky cases. If you want, tell me: • exact input file types you receive (extensions/codecs), and • whether you want a single speaker view, gallery, or picture-in-picture layout, and I’ll give a tailored FFmpeg command for your files. , with interactive elements