I am working on an iOS project that uses AVAssetWriter and AVAssetWriterInput to write audio and video to a file. Everything seemed to work fine when the video resolution was limited to 720x1280. Now I'm trying to use AVCaptureDeviceFormats for the higher resolutions available on new iOS devices.
The video continues to work fine using any AVCaptureDeviceFormats available on the device. However, the sound does not work.
I traced this to the active property of my AVCaptureConnection audio, which NO for the highest resolution formats, looks like this when I log it:
<AVCaptureConnection: 0x16f62130 [type:soun][enabled:1][active:0]>
Also, my didOutputSampleBuffer delegate callback is not called with audio data when the audio connection is inactive.
My questions:
- Why is AVCaptureConnection audio active for lower resolution formats, but not for higher resolution formats?
- Can I record audio when the video resolution is set to the highest? If so, how?
Example:
High Resolution AVCaptureFormats on iPhone6, Rear View Camera:
- 720x1280,30 FPS (Active Audio Connection)
- 720x1280, 240 FPS (active audio connection)
- 1080x1920, 30 FPS (active audio connection)
- 1080x1920, 60 FPS (active audio connection)
- 1936x2592, 30 FPS (audio connection inactive)
- 2448x3264, 30 FPS (audio connection inactive)
High Resolution AVCaptureFormats on iPhone6, front camera:
- 720x1280, 60 FPS (active audio connection)
- 960x1280, 60 FPS (audio connection inactive)
Here is the code that I use to set the active format:
if ([self.camera lockForConfiguration:nil]) { self.camera.activeFormat = format; [self.camera unlockForConfiguration]; }
source share