I am working on an application that features a camera view similar to that of snapchat/instagram in that it should be able to record and take videos at the same time without having to switch between the two modes. (I.e., the user should be able to tap a button to take a picture, and hold the button to record a video). I have much of this already setup using an AVCaptureSession, preview layers and am using AVAssetWriter and AVCaptureVideoDataOutput for recording the videos.
However, I cannot get switching the camera to work *while* recording a video. Switching the camera between front/rear works fine, however if I do that whilest recording a video, frames are lost and the audio (from AVCaptureAudioDataOutput) is out of sync. I have tried to fix this by myself but no solution seems to work. So I need someone who is able to fix this specific bug: switching cameras while recording using AVCaptureVideoDataOutput makes the audio go out of sync with the video.
Ideally, the task should be completed so that switching cameras is instant, and can be seen instantly in the AVCaptureSession, and does not lose sync with the audio in the recorded video. More explanation can be given through chat, and some example code can be given that I have already written, however a clean solution is preferred.