2016-08-03 50 views
1

我得到错误-12910(kVTVideoDecoderUnsupportedDataFormatErr)。我使用Avios积分(https://github.com/tidwall/Avios),这是相关的部分:解码H264:VTDecompressionSessionCreate失败,在SIM</strong>在我的iPad,<strong>运行的代码,但不使用时错误VTDecompressionSessionCreate代码-12910(kVTVideoDecoderUnsupportedDataFormatErr)

private func initVideoSession() throws { 
    formatDescription = nil 
    var _formatDescription : CMFormatDescription? 
    let parameterSetPointers : [UnsafePointer<UInt8>] = [ pps!.buffer.baseAddress, sps!.buffer.baseAddress ] 
    let parameterSetSizes : [Int] = [ pps!.buffer.count, sps!.buffer.count ] 
    var status = CMVideoFormatDescriptionCreateFromH264ParameterSets(kCFAllocatorDefault, 2, parameterSetPointers, parameterSetSizes, 4, &_formatDescription); 
    if status != noErr { 
     throw H264Error.CMVideoFormatDescriptionCreateFromH264ParameterSets(status) 
    } 
    formatDescription = _formatDescription! 

    if videoSession != nil { 
     VTDecompressionSessionInvalidate(videoSession) 
     videoSession = nil 
    } 
    var videoSessionM : VTDecompressionSession? 

    let decoderParameters = NSMutableDictionary() 
    let destinationPixelBufferAttributes = NSMutableDictionary() 
    destinationPixelBufferAttributes.setValue(NSNumber(unsignedInt: kCVPixelFormatType_32BGRA), forKey: kCVPixelBufferPixelFormatTypeKey as String) 

    var outputCallback = VTDecompressionOutputCallbackRecord() 
    outputCallback.decompressionOutputCallback = callback 
    outputCallback.decompressionOutputRefCon = UnsafeMutablePointer<Void>(unsafeAddressOf(self)) 

    status = VTDecompressionSessionCreate(nil, formatDescription, decoderParameters, destinationPixelBufferAttributes, &outputCallback, &videoSessionM) 
    if status != noErr { 
     throw H264Error.VTDecompressionSessionCreate(status) 
    } 
    self.videoSession = videoSessionM; 
} 

这里ppssps是含有PPS和SPS帧缓冲器。

如上所述,奇怪的是,它在模拟器上完全正常工作,但不是在实际设备上。两者都在iOS 9.3上,我正在模拟与设备相同的硬​​件。

什么可能导致此错误?

而且,更一般地说,我可以在哪里找到VideoToolbox的API参考和错误文档?真正无法在Apple网站上找到任何相关内容。

回答

2

答案的结果是流分辨率大于1920x1080,这是iPad支持的最大值。这与支持超出该分辨率的模拟器明显不同(也许它只是使用Mac VideoToolbox库而不是模拟iOS的)。

将流减少为比1080p更少的像素解决了问题。

这是来自苹果员工中的一员,其向我指出了正确的方向响应:https://forums.developer.apple.com/thread/11637

至于正确VideoToolbox参考 - 仍然一无所获的价值存在,这是一个巨大的劣势。人们不禁要问,这些辅导作者是如何得到他们的信息的。

编辑: iOS 10现在似乎支持大于1080p的数据流。