VTCompessionSession的输出回调未运行

问题描述

我一直在使用VideoToolBox编码视频数据,但是我无法获取正在运行的VTCompressionSession的回调。

这是我声明VTCompressionSession

的方式
VTCompressionSessionCreate(allocator: nil,width: 1080,height: 1920,codecType: kCMVideoCodecType_H264,encoderSpecification: nil,imageBufferAttributes: nil,compressedDataAllocator: nil,outputCallback: compressionOutputCallback as? VTCompressionOutputCallback,refcon: nil,compressionSessionOut: sessionOut)

这是我的输出回调

func compressionOutputCallback(
        outputCallbackRefCon:UnsafeMutableRawPointer?,sourceFrameRefCon:UnsafeMutableRawPointer?,status:OSStatus,infoFlags:VTEncodeInfoFlags,sampleBuffer:CMSampleBuffer) {

        //Do stuff with CMSampleBuffer


        if status != noErr{
            NSLog("SBC: Error encoding video",status)

            print("SBC: Error encoding video",status)

            return

        }

        print("SBC: compressionOutputCallback dataBuffer",status)

    }

但是日志显示,即使我为VTCompessionSession指定了回调,也没有在运行它。

我是Swift的新手,特别是VideoToolBox的新手,因此,感谢大家的帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...