【问题标题】:Is there any way to give fixed number of frames we can capture in 1 seconds using AVCaptureSession?有什么方法可以让我们使用 AVCaptureSession 在 1 秒内捕获固定数量的帧?
【发布时间】:2019-09-09 07:11:47
【问题描述】:

我在我的应用程序中创建 BOOMERANG 效果,所以我通过设置 1 秒计时器来捕捉图像。目前在 1 秒内,我大部分时间都在 24 到 30 帧左右。

但我想一直在 1 秒内只捕捉 28 帧。

谁能帮我实现这个目标?

提前致谢。

【问题讨论】:

  • 显示您的代码。

标签: ios avfoundation avcapturesession


【解决方案1】:

在您的 AVCaptureDeviceInput 上,您将有一个视频输入。

    let frameRate = 28
    let frameDuration = CMTimeMake(1, frameRate)

    do {
        try videoDevice.unlockForConfiguration()
        videoDevice.activeVideoMaxFrameDuration = frameDuration
        videoDevice.activeVideoMinFrameDuration = frameDuration
        videoDevice.lockForConfiguration()
    } catch {
        NSLog("videoDevice lockForConfiguration returned error \(error)")
    }

您可以尝试通过帧持续时间设置最小/最大 FPS。

【讨论】:

  • 我已经这样做了,但它不会每次都准确捕获 28,它总是捕获 24 到 30 帧。
  • 嗯,我不认为你能完全明白,你能在写作层面做到吗?这篇文章可能会有所帮助,stackoverflow.com/questions/43365266/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-23
  • 1970-01-01
  • 2012-08-27
  • 2012-05-09
  • 1970-01-01
相关资源
最近更新 更多