【发布时间】:2016-02-16 14:12:15
【问题描述】:
我正在显示来自 IP 摄像机的 RTSP 流。我想用 VideoToolbox 框架替换这个方法avcodec_decode_video2。我对视频数据处理有点陌生,所以我有点迷茫......
我已经测试了here 和here 的两种解决方案,但我最终以这种方法VTDecompressionSessionDecodeFrame 失败。
Error Domain=NSOSStatusErrorDomain Code=-12909 "The operation couldn’t be completed. (OSStatus error -12909.)" - -12909
我怀疑这是来自会话,因为如果我在创建会话后立即调用 VTDecompressionSessionCanAcceptFormatDescription,结果是 NO。
这是我的会话的创建方式:
VTDecompressionOutputCallbackRecord callback;
callback.decompressionOutputCallback = decompressionSessionDecodeFrameCallback;
callback.decompressionOutputRefCon = (__bridge void *)self;
NSDictionary *destinationImageBufferAttributes =[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES],(id)kCVPixelBufferOpenGLESCompatibilityKey,[NSNumber numberWithInt:kCVPixelFormatType_32RGBA],(id)kCVPixelBufferPixelFormatTypeKey,nil];
OSStatus status = VTDecompressionSessionCreate(kCFAllocatorDefault, _formatDesc, NULL,
(__bridge CFDictionaryRef)destinationImageBufferAttributes,
&callback, &_decompressionSession);
我也不确定要使用的数据。我可以在 AVPacket.data、AVCodecContext.extradata、AVPacket.buf->data 之间进行选择。谁能告诉我应该使用哪一个(也许还有一个)?
提前谢谢,
PS.: 这是我的第一篇文章;如果没有正确呈现/解释,请告诉我。
【问题讨论】:
标签: ios h.264 video-toolbox