How to Record In-game audio and microphone audio together?

I am pleased to announce I cracked how to do it, it was actually very simple in the end. Make sure you are using Natcorder, use an older version that still has the MixerDevice.cs, make sure to incorporate the fix from here if you are on IOS: NatCorder - Video Recording API page-69#post-6493429

[Additional fix]
Further searching fixed an issue with iOS. NatDevice - Media Device API page-50
Destination array was not long enough. Check destIndex and length, and the array’s lower bounds
Edit MixerDevice.cs to increase buffer size .
var copyBuffer = new float[16384];

Then use the same code as them (see link above or use below)

var query = new MediaDeviceQuery(MediaDeviceQuery.Criteria.AudioDevice);
        var microphone = query.currentDevice as IAudioDevice;
        audioDevice = new MixerDevice(microphone, Camera.main.gameObject.GetComponent<AudioListener>());
        Debug.Log("SampleRate: Device: "+audioDevice.sampleRate);
        Debug.Log("SampleRate: AudioSettings: "+AudioSettings.outputSampleRate);
        // Recorder setyop
        var clock = new RealtimeClock();
        recorder = new MP4Recorder((int) prod.x, (int) prod.y, 30, AudioSettings.outputSampleRate, 2);
        cameraInput = new CameraInput(recorder, clock, Camera.main);
        /// Game + Mic Audio
        //_audioInput = new AudioInput(recorder, clock, Camera.main.gameObject.GetComponent<AudioListener>());
        audioDevice.StartRunning((sampleBuffer, timestamp) => recorder.CommitSamples(sampleBuffer, clock.timestamp));

Now you are able to record the screen, the device microphone and any game audio received by the audiolistener in your scene!

1 Like