CMVideoFormatDescriptionGetCleanAperture()快速错误 [英] CMVideoFormatDescriptionGetCleanAperture() swift error

查看:75
本文介绍了CMVideoFormatDescriptionGetCleanAperture()快速错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用CMVideoFormatDescriptionGetCleanAperture()函数.使用

var videoDescriptionRef = port.formatDescription as CMVideoFormatDescriptionRef
var cleanAperture = CMVideoFormatDescriptionGetCleanAperture(videoDescriptionRef, true)

var cleanAperture = CMVideoFormatDescriptionGetCleanAperture(port.formatDescription, true)

分别给我以下错误:

Cannot convert expression's type 'CMVideoFormatDescriptionRef' to type 'CMVideoFormatDescriptionRef'

第二个是

Could not find an overlad for '__conversion' that accepts the supplied arguments

有人知道如何解决这些问题,或者有人指出在获取清洁光圈格式说明时出现任何错误吗?

Does anyone know how to fix these or can anyone point out any errors in getting the format description for retrieving the clean aperture?

推荐答案

CMFormatDescription本身没有成员takeUnretainedValue.它是Unmanaged<T>的成员.您需要先定义一个非托管变量,获取一个值,然后再保留它.

CMFormatDescription itself does not have a member takeUnretainedValue. It is a member of Unmanaged<T>. You need to define an unmanaged variable first, get a value into it and then you retain it.

由于我不知道您是如何创建port.formatDescription的,下面是一个示例,其中formatDescription是通过AVC视频的PPS/SPS创建的.

As I do not know how you created port.formatDescription, here is an example where formatDescription is created from PPS/SPS from an AVC video.

// create the receiving unmanaged variable
var formatDescription: Unmanaged<CMVideoFormatDescription>?

// call the not annotated method, this method will fill in formatDescription which is Unmanaged<T>
let result = CMVideoFormatDescriptionCreateFromH264ParameterSets(nil, UInt(parameterSets.count), parameterSets, parameterSetSizes, 4, &formatDescription)

// check result, yada yada yada before continuing

// now we can actually retain the value
let formatDescriptionRef = formatDescription!.takeUnretainedValue() as CMVideoFormatDescriptionRef

// and we can do what ever we want with it in Swift without caring anymore. 
var cleanAperture = CMVideoFormatDescriptionGetCleanAperture(formatDescriptionRef, 1)

  1. 创建非托管类型
  2. 在未注释的方法中使用此非托管类型
  3. 保留值
  4. 使用它而不用考虑如何创建它.

因此,请调整代码,在将port.formatDescription创建为非托管代码的地方,您应该会很好.

So adjust your code where you create the port.formatDescription as a Unmanaged and you should be good.

这篇关于CMVideoFormatDescriptionGetCleanAperture()快速错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆