HaishinKit.swift icon indicating copy to clipboard operation
HaishinKit.swift copied to clipboard

Local record audio desynchronization on camera switch

Open CubitSpeed opened this issue 3 years ago • 1 comments

Describe the bug The audio becomes desynchronized for a local record if the camera is switched

To Reproduce Steps to reproduce the behavior:

  1. Modify the iOS example to enable local recordings (add type: .localRecord to publish method)
  2. Start a stream
  3. Switch the camera from the rear to front camera
  4. Speak into the camera
  5. Switch back camera
  6. End stream
  7. 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

CubitSpeed avatar May 03 '21 21:05 CubitSpeed

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?

mkrn avatar Nov 03 '21 19:11 mkrn