Hi,
I'm capturing Audio and Video using AVFoundation
's AVCaptureSession
using the AVCaptureVideoDataOutputSampleBufferDelegate
& AVCaptureAudioDataOutputSampleBufferDelegate
to collect CMSampleBuffer
s and write them to file using AVAssetWriter
.
The issues I'm facing is that while recording if the user goes to the background and returns, the CMSampleBuffer
's AudioFormat changes from:
this
-
FormatList Array: { Index: 0 ChannelLayoutTag: 0x640001 ASBD: { mSampleRate: 48000.000000 mFormatID: 'lpcm' mFormatFlags: 0xc mBytesPerPacket: 2 mFramesPerPacket: 1 mBytesPerFrame: 2 mChannelsPerFrame: 1 mBitsPerChannel: 16 }}
to this:
-
FormatList Array: { Index: 0 ChannelLayoutTag: 0x640001 ASBD: { mSampleRate: 48000.000000 mFormatID: 'lpcm' mFormatFlags: 0xc mBytesPerPacket: 8 mFramesPerPacket: 1 mBytesPerFrame: 8 mChannelsPerFrame: 4 mBitsPerChannel: 16 }}
This obviously creates an issue with the AudioInput in the AVAssetWriter
and fails the writing
Does anyone have an idea what going on?
As to the CaptureSession setup:
- Inputs:
Front / back camera & internal microphone
- outputs:
AVCaptureVideoDataOutput & AVCaptureAudioDataOutput
I am changing the active format in the videoInput's device when I start the session
Thanks, Yoav