audio_mixing parameter (DUAL_CHANNEL_AGENT / DUAL_CHANNEL_ALTERNATE) not working in RoomCompositeEgress - both channels contain identical mixed audio
Bug Description
Description
The audio_mixing parameter in RoomCompositeEgressRequest is not being applied by the egress service. When setting audio_mixing=DUAL_CHANNEL_AGENT or audio_mixing=DUAL_CHANNEL_ALTERNATE, the resulting recording still contains identical mixed audio in both L and R channels instead of separating the audio streams.
Code
from livekit.protocol.egress import (
RoomCompositeEgressRequest,
EncodedFileOutput,
EncodedFileType,
AudioMixing,
)
req = RoomCompositeEgressRequest(
room_name=room_name,
layout="speaker",
audio_only=True,
audio_mixing=AudioMixing.DUAL_CHANNEL_AGENT,
file_outputs=[file_output],
)
info = await api.egress.start_room_composite_egress(req)
Evidence
The server acknowledges receiving the audio_mixing parameter correctly.
Waveform analysis of the output file shows both channels contain identical audio:
- Top (Red) = Left channel
- Bottom (Green) = Right channel
- Both waveforms are identical, proving no channel separation occurred
Expected Behavior
According to the documentation and protocol definition:
DUAL_CHANNEL_AGENT:
- Left channel: Agent audio only
- Right channel: All other participants' audio
DUAL_CHANNEL_ALTERNATE:
- Each new audio track alternates between left and right channels
Actual Behavior
Both L and R channels contain the same mixed audio (all participants mixed together), regardless of which AudioMixing mode is set.
Additional Context
- Tested with both
AudioMixing.DUAL_CHANNEL_AGENTandAudioMixing.DUAL_CHANNEL_ALTERNATE- same issue - The
EgressInforesponse confirms the server receivedaudio_mixing=1, so the parameter is being transmitted correctly - The agent's
ParticipantKindis correctly set to4(AGENT) - The implementation in pkg/pipeline/builder/audio.go checks
ParticipantKind == ParticipantAgentto determine channel routing
Reproduction Steps
1. Start a room composite egress with `audio_mixing=DUAL_CHANNEL_AGENT` and `audio_only=True`
2. Have an agent (ParticipantKind=AGENT) and a regular participant in the room
3. Both participants speak
4. Stop the egress and examine the resulting audio file
Operating System
macOS
Models Used
No response
Package Versions
deployed in livekit cloud
livekit-agents: 1.3.10
Session/Room/Call IDs
No response
Proposed Solution
Additional Context
No response
Screenshots and Recordings
No response
Try adding enable_room_composite_sdk_source: true to your egress.yaml. I faced the same issue and added this to my egress.yaml. The recordings started to split correctly but some calls are receiving silence. I don't know if that is expected with this mode
is this fixed now? edit: its sadly not fixed :(
you should not pass in a layout for audio-only composite. passing in layout so will override the optimized path and defer to a chrome-based template to record
passing in layout so will override the optimized path and defer to a chrome-based template to record
I have run the code without passing in layout as well, with just audioMixing=AudioMixing.DUAL_CHANNEL_AGENT in TS, but the resulting recordings were still mixed. I had imported @livekit/protocol. Is there a real bug in this case? If you need I can help investigate.
you should not pass in a layout for audio-only composite. passing in layout so will override the optimized path and defer to a chrome-based template to record
Hi David,
This was helpful, thank you for your assistance.