'Issues while switching cameras during recording with AVFoundation

I am building a camera application similar to snapchat, and I need to be able to switch cameras while recording. I am able to switch cameras while NOT recording by removing the session inputs and reconfiguring the session. This also requires you to stopRunning() before the configuration and startRunning() after the config.

So far I am getting 2 different videos. One before the switch and one after. I could merge the two files together by following this post: Swift Merge audio and video files into one video

But I feel like there must be a built in way to do this with AVFoundation? I have searched the doc and could not find anything regarding how to switch cameras while recording.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source