I have an application that records videos. I can start and stop recording, thus having various segments recording, much like TikTok. Recently, I implemented setting videoZoomFactor to AVCaptureDevice. It works normal while recording. But if I zoom before recording and press on record to start, the output video result's first frame is black. Also, if during the same AVCaptureSession I record with zoom, remove this recording and record again with zoom, the black frames do not appear. From this I conclude that calling startRecording on AVCaptureMovieFileOutput fixes something between first recording and second.
Can someone please advise me on solution? I am thinking of doing a workaround where I will remove first frame in case it was recorded with initial zoom, but I'd like to understand why this happens and have proper solution.
I have a pretty simple setup for camera recording. I was following steps in official guide from documentation. Here is the part of setting zoom factor.
self.sessionQueue.async {
do {
try device.lockForConfiguration()
device.videoZoomFactor = factor
device.unlockForConfiguration()
} catch {
print("\(error.localizedDescription)")
}
}