can we record using egress to other formats like m...
# ask-ai
d
can we record using egress to other formats like mp3 or wav?
t
Thanks for reaching out, Shivam. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! Just a quick heads-up—LiveKit’s standard egress pipeline doesn’t directly support recording in MP3 or WAV formats. Right now, it works with MP4 and OGG for room, participant, and track recordings. But don’t worry! You can still get WAV recordings by setting up a custom solution using our client-side SDKs. This means you’d handle raw audio streams, do some resampling, and write the PCM data into a file with a WAV header. For MP3, the easiest way is to convert existing recordings (like MP4 files) using external tools after the fact. If you’d like, I’m here to help walk you through setting up custom WAV recording or converting formats—just let me know! Sources: protobufs/livekit_egress.proto | README.md | Egress output types | LiveKit Docs | livekit-api/src/services/egress.rs | livekit-plugins/livekit-plugins-google/livekit/plugins/google/tts.py
I'd be happy to help you record audio in WAV format using LiveKit! You can achieve this by implementing a custom solution with client-side SDKs. Here’s a simple overview of how you can do it: 1. Subscribe to an Audio Track: Use the SDK to detect when an audio track becomes available and access its raw audio frames. 2. Create a WAV Header: You’ll need to construct a 44-byte RIFF-compliant WAV header using details like sample rate, bit depth, and number of channels. 3. Write Header and Audio Data: Start by writing the WAV header to a file, then append the raw PCM audio data from the track in little-endian format. 4. Finalize the WAV File: Once recording is finished, update the header with the final file size and data size so the file is properly formatted. There are helpful examples available for Rust and Node.js SDKs that show how to handle raw audio streams and save them as WAV files. If you’re working with other platforms like Swift or Android, the same principles apply, and I’d be more than happy to help you put together a reference implementation. Feel free to share which SDK or platform you’re using, and I can provide more tailored guidance or examples to support you! Sources: examples/receive-audio/index.ts | Processing raw media tracks | LiveKit Docs | examples/save_to_disk/src/main.rs | src/room/track/record.ts | Capturing the First Few Seconds of a Call for Processing