agents icon indicating copy to clipboard operation
agents copied to clipboard

audio_mixing parameter (DUAL_CHANNEL_AGENT / DUAL_CHANNEL_ALTERNATE) not working in RoomCompositeEgress - both channels contain identical mixed audio

Open sperdices opened this issue 10 months ago • 5 comments

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:

Image
  • 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_AGENT and AudioMixing.DUAL_CHANNEL_ALTERNATE - same issue
  • The EgressInfo response confirms the server received audio_mixing=1, so the parameter is being transmitted correctly
  • The agent's ParticipantKind is correctly set to 4 (AGENT)
  • The implementation in pkg/pipeline/builder/audio.go checks ParticipantKind == ParticipantAgent to 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

sperdices avatar Jan 07 '26 03:01 sperdices

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

khushalsonawat avatar Mar 06 '26 04:03 khushalsonawat

is this fixed now? edit: its sadly not fixed :(

pUrGe12 avatar Mar 13 '26 08:03 pUrGe12

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

davidzhao avatar Mar 13 '26 16:03 davidzhao

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.

pUrGe12 avatar Mar 13 '26 16:03 pUrGe12

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.

AlessandroMason avatar Mar 20 '26 21:03 AlessandroMason