Why is my audio AVCaptureConnection not active for highest-resolution formats?

情到浓时终转凉″ 提交于 2019-12-07 01:51:00

问题


I'm working on an iOS project which uses AVAssetWriter and AVAssetWriterInput to record audio and video to file. Everything seemed to work fine when the video resolution was limited to 720x1280. I'm now trying to take advantage of the AVCaptureDeviceFormats for higher resolutions available on newer iOS devices.

The video continues to work fine using any of the AVCaptureDeviceFormats available on the device. However, the audio does not work.

I've tracked this down to the active property of my audio AVCaptureConnection, which is NO for the highest-resolution formats, looking 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 not active.

My questions:

  • why is the audio AVCaptureConnection active for lower resolution formats, but not for the highest resolution formats?
  • is it possible to record audio when the video resolution is set to the highest? If so, how?

Example:

The highest-resolution AVCaptureFormats on an iPhone6, back camera:

  • 720x1280, 30 FPS (audio connection active)
  • 720x1280, 240 FPS (audio connection active)
  • 1080x1920, 30 FPS (audio connection active)
  • 1080x1920, 60 FPS (audio connection active)
  • 1936x2592, 30 FPS (audio connection not active)
  • 2448x3264, 30 FPS (audio connection not active)

The highest-resolution AVCaptureFormats on an iPhone6, front camera:

  • 720x1280, 60 FPS (audio connection active)
  • 960x1280, 60 FPS (audio connection not active)

Here's the code I'm using to set the active format:

if ([self.camera lockForConfiguration:nil])
{
    self.camera.activeFormat = format;
    [self.camera unlockForConfiguration];
}

来源:https://stackoverflow.com/questions/29241365/why-is-my-audio-avcaptureconnection-not-active-for-highest-resolution-formats

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!