【问题标题】:Set AVCaptureDevice format range设置 AVCaptureDevice 格式范围
【发布时间】:2021-05-22 01:28:38
【问题描述】:

我能够查询和查找 240FPS 的慢动作格式。有两个,420v420f,每个都是全高清的(如果我错了,请纠正我,它们仅在像素值范围内有所不同)。我想知道我是否可以在运行时区分它们。

print(format.formatDescription.mediaSubType) // this prints "420v" and "420f" each

但是这不起作用:

    // always false
if format.formatDescription.mediaSubType == .init(string: "420f") {
    // ...
}

我一直在采用的一种解决方法是依靠 for 循环始终先找到 v,然后再为我的设备找到 f,但我不确定这是否适用于所有设备。


以下是在此 iPad 上发现的一些慢动作格式: (其他慢动作格式适用于 1280x720 尺寸等)

<AVCaptureDeviceFormat: 0x280b58ec0 'vide'/'420v' 1920x1080, { 2-240 fps}, fov:64.717, binned, supports vis, max zoom:67.50 (upscales @1.00), AF System:1, ISO:18.0-720.0, SS:0.000016-0.500000> <CMVideoFormatDescription 0x2807d95c0 [0x1ff615860]> {
    mediaType:'vide' 
    mediaSubType:'420v' 
    mediaSpecific: {
        codecType: '420v'       dimensions: 1920 x 1080 
    } 
    extensions: {(null)}
}
<AVCaptureDeviceFormat: 0x280b58eb0 'vide'/'420f' 1920x1080, { 2-240 fps}, fov:64.717, binned, supports vis, max zoom:67.50 (upscales @1.00), AF System:1, ISO:18.0-720.0, SS:0.000016-0.500000, supports wide color> <CMVideoFormatDescription 0x280731770 [0x1ff615860]> {
    mediaType:'vide' 
    mediaSubType:'420f' 
    mediaSpecific: {
        codecType: '420f'       dimensions: 1920 x 1080 
    } 
    extensions: {(null)}
}

【问题讨论】:

    标签: ios swift camera avfoundation avcapturedevice


    【解决方案1】:

    MediaSubType 上已经定义了一些像素类型常量,例如 CMFormatDescription.MediaSubType.pixelFormat_422YpCbCr8_yuvs,但遗憾的是没有 4:2:0 变体。

    你可以用符号检查 420f 和 420v

    format.formatDescription.mediaSubType == .init(rawValue: kCVPixelFormatType_420YpCbCr8BiPlanarFullRange)
    

    format.formatDescription.mediaSubType == .init(rawValue: kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange)
    

    奇怪的是你的.init(string:"420f") 为我工作。

    【讨论】:

    • 谢谢,朋友。我不知道为什么,但再次检查后,它可以使用.init(string: "420f")。并感谢您提到使用原始值和系统常量启动!
    猜你喜欢
    • 2016-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多