Recording an AggregateDevice with 2 stereo audio inputs results in quadraphonic (4 channel) audio.

I need to record 2 stereo AVCaptureDevices into 1 audio track.

I can successfully create the aggregate device using AudioHardwareCreateAggregateDevice, but when I record that device, the resulting audio track has quadraphonic audio. The problem with this is that some players, such as VLC, won't play all the tracks.

So I tried forcing the file writer to use 2 channels with a stereo layout (see code below). This doesn't quite work because all 4 of the channels are mapped to both of the stereo channels. As in, they are not actually stereo. The left/right channels from the aggregate devices play in both channels of the resulting file.

code I used to make the track stereo:

var audioOutputSettings = movieFileOutput.outputSettings(for: audioConnection)

audioOutputSettings[AVNumberOfChannelsKey] = 2

var layout = AudioChannelLayout()
layout.mChannelLayoutTag = kAudioChannelLayoutTag_Stereo

audioOutputSettings[AVChannelLayoutKey] = NSData(bytes: &layout, length: MemoryLayout.size(ofValue: layout))

movieFileOutput.setOutputSettings(audioOutputSettings, for: audioConnection)

Can anyone help me with this so that both left channels from the 2 devices play in the left channel and same with both right channels?

Recording an AggregateDevice with 2 stereo audio inputs results in quadraphonic (4 channel) audio.
 
 
Q