微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

VTCompessionSession的输出回调未运行

如何解决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 举报,一经查实,本站将立刻删除。