Combining two audio AVAssetWriterInput

Hello,


I am working with Replay Kit 2, to record the screen, the app output audio, and the phone input microphone.

This means I can have up to 3 AVAssetWriterInput instances:
- 1 for the app video (screen recording)
- 1 for app audio (stereo, 2 channels, 441000 sample rate, 64000 bit rate)

- 1 for microphone audio (mono, 1 channel, 441000 sample rate, 64000 bit rate)


I am using a AVAssetWriter to combine these three inputs. (using add: method)

This results in an mp4 with two different audio tracks, one with only the app audio, and another with the microphone audio. This means in some players like VLC only one track at a time is played.

Is there any specific way to combine both inputs into one in the final MP4?

Replies

LIUHAI

Did you ever figure this out? I have exactly the same problem.

I believe you need to mix audio before recording it in a file.
https://developer.apple.com/documentation/avfoundation/avaudiomix
This should give you a single audio track and you should be able to play it.