Do you support MP4 when passing the music?
# ask-ai
p
Do you support MP4 when passing the music?
✅ 1
t
Thanks for reaching out, Mario. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — good question. I'm answering whether MP4 is supported when you want to "pass" or play music into a LiveKit session. Short answer • MP4 is supported as an input file for playback/processing and as an output format for egress recordings. • You cannot publish an MP4 file URL directly as a WebRTC audio track; you must decode it (for example via the WebAudio API or a local player that produces a MediaStream) and then publish the resulting audio track into the room. What you can do (options) • Use the browser WebAudio approach: a. Load the MP4 into an HTMLAudioElement (or fetch + decode). b. Create a
MediaElementAudioSourceNode
and route it to a
MediaStreamAudioDestinationNode
. c. Take the
MediaStream
from the destination node and publish it to LiveKit as an audio track. ◦ This is the common method for streaming music files (including MP4) into a WebRTC session. • Use server-side/local playback (agents or background player): ◦ The BackgroundAudioPlayer can decode MP4 (FFmpeg-backed) and play it for publishing/processing. ◦ For recording/egress, LiveKit supports MP4 as an output container (e.g.,
startRoomCompositeEgress
,
startTrackCompositeEgress
,
startWebEgress
) — if you need to export sessions or tracks as MP4. If you want, tell me: • Are you trying to play an MP4 from a public URL in the browser, or from a file on the server/device? • Is your goal to stream live into a room, or to record/export the session as MP4? Tell me which case applies and I’ll give step-by-step guidance or code snippets for that path. Sources: server-sdk-js | livekit/livekit_composite | DeepWiki | Universal Egress | LiveKit | Stream music over WebRTC using React and WebAudio | LiveKit | Agent speech and audio | LiveKit Documentation, with interactive elements