HaishinKit.swift
HaishinKit.swift copied to clipboard
Local record audio desynchronization on camera switch
Describe the bug The audio becomes desynchronized for a local record if the camera is switched
To Reproduce Steps to reproduce the behavior:
- Modify the iOS example to enable local recordings (add
type: .localRecord
to publish method) - Start a stream
- Switch the camera from the rear to front camera
- Speak into the camera
- Switch back camera
- End stream
- Review local recording
Expected behavior The local recording's audio should not have any desynchronization
Smartphone (please complete the following information):
- Device: iPhone6s, iPhoneX
- OS: iOS 12, iOS 14
- Version: 1.1.5
This seems to happen because the selfie or back camera is not immediately available, so it loses some frames while audio is still being written to output. Audio becomes ahead of video. It seems AVCaptureAudioDataOutput hangs while you switch cameras.
By the way the iPhone Camera doesn't let you switch while recording (probably due to the same issue)
Any idea @shogo4405? Can the video be re-synchronized with audio after the switch?