ios - AVCaptureVideoDataOutput 和 AVCaptureAudioDataOutput 相同队列

标签 ios avfoundation avcapturesession avcapturedevice avcapturevideodataoutput

Apple 最近的示例代码之一使用相同的串行队列从 AVCaptureVideoDataOutput 和 AVCaptureAudioDataOutput 委托(delegate)接收示例。我需要知道从性能的角度来看这是否是可以接受的做法。两个样本缓冲区委托(delegate)应该有不同的队列还是单个队列?特别是在多个摄像机输入/输出的设置中,这一点变得很重要。

 private let dataOutputQueue = DispatchQueue(label: "data output queue")
 ...
 ...
 videoDataOutput.setSampleBufferDelegate(self, queue: dataOutputQueue)
 audioDataOutput.setSampleBufferDelegate(self, queue: dataOutputQueue)

最佳答案

我想当谈到性能时:

  1. 这始终取决于您的情况。也许对于 Apple 的示例来说还可以,但也许在您的情况下它确实需要更多。
  2. 您可以亲自尝试一下。尝试在最慢的设备上获取尽可能多的输入,看看性能是否仍然足够好。

有一个类似的问题,由于串行队列导致性能不好,答案是使用并发队列,请参见此处: Performance issues when using AVCaptureVideoDataOutput and AVCaptureAudioDataOutput

但我再次建议您尝试一下,看看什么适合您:)

更新

这里的链接完美地解释了差异以及如何使用串行和并发队列: https://www.avanderlee.com/swift/concurrent-serial-dispatchqueue/

关于ios - AVCaptureVideoDataOutput 和 AVCaptureAudioDataOutput 相同队列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58921202/

相关文章:

iphone - 语义问题 : Use of undeclared identifier

ios - 如何使用 Objective-C 以 120 fps 或 240 fps 录制视频

swift - 改进 Swift 中的条码扫描器

swift - 使用 AVCaptureVideoDataOutput 正确录制视频

ios - 可以在启动相机应用程序时控制白平衡模式吗? (iOS)

ios - 如何将 AVCapture 中的图像裁剪为显示器上显示的矩形

iOS UIImage 转换为固定内存大小

ios - Mac 音频在 xcode 中的断点处停止时停止

ios - 如何更改 UITableViewCell 的高度?

ios - 在不在手机上播放媒体的情况下在锁定屏幕中显示 Nowplaying item meta