gpt4 book ai didi

ios - 在 Swift 中设置 AVCaptureSession 中 AVCaptureDevice 的低帧率

转载 作者:行者123 更新时间:2023-12-03 03:56:30 30 4
gpt4 key购买 nike

在 Swift 中使用 AVCaptureDevice 进行捕获时,我尝试将帧速率设置为每秒 10 帧。

我相信这是通过设置 AVCaptureDevice 的 activeVideoMaxFrameDuration 来实现的,但也许我做错了,还有一种不同的方法。

这是我当前的代码,运行时没有错误,但对预览或捕获的视频中的帧速率没有任何影响,视频仍然看起来是全动态的。

    var devices = AVCaptureDevice.devicesWithMediaType(mediaType);
var captureDevice: AVCaptureDevice = devices[0] as AVCaptureDevice;

captureDevice.lockForConfiguration(&error)

captureDevice.activeVideoMinFrameDuration = CMTimeMake(1,10)
captureDevice.activeVideoMaxFrameDuration = CMTimeMake(1,10)

captureDevice.unlockForConfiguration()

我已经检查了 AVCaptureDeviceFormat videoSupportedFrameRateRanges minFrameRate 并应支持每秒 10 帧。

将 CMTime 更改为 videoSupportedFrameRateRanges 之外的内容确实会引发错误,因此我知道代码正在被使用,但它没有任何效果。

预先感谢您的帮助

最佳答案

我认为您应该在捕获 session 开始运行后更改设备配置才能生效。我希望这对你有用,就像对我一样。 干杯 =)

关于ios - 在 Swift 中设置 AVCaptureSession 中 AVCaptureDevice 的低帧率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27830371/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com