Swift VTCompressionSession的输出回调未运行
我一直在使用VideoToolBox对视频数据进行编码,但我无法获得运行我正在运行的Swift VTCompressionSession的输出回调未运行,swift,compression,h.264,video-toolbox,Swift,Compression,H.264,Video Toolbox,我一直在使用VideoToolBox对视频数据进行编码,但我无法获得运行我正在运行的VTCompressionSession的回调 下面是我如何声明VTCompressionSession VTCompressionSessionCreate(allocator: nil, width: 1080, height: 1920, codecType: kCMVideoCodecType_H264, encoderSpecification: nil, imageBufferAttributes:
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)
}
但是日志显示回调没有运行,即使我为VTCompressionSession
指定了回调
我对Swift一般来说是新手,特别是对VideoToolBox,所以非常感谢大家在这方面的帮助