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