iOS:VideoToolBox解压缩h263视频异常

时间:2015-07-09 15:04:27

标签: ios video compression hardware-acceleration video-toolbox

我正在使用VideoToolBox进行H263解压缩。但是当解码4CIF视频流时,输出像素数据都是0值,并且没有错误信息。

我不知道为什么会这样,因为具有CIF分辨率的视频流被正确解压缩。

是否有人有同样的问题?

这是我的一段代码:

CMFormatDescriptionRef newFmtDesc = nil;
OSStatus status = CMVideoFormatDescriptionCreate(kCFAllocatorDefault,
                                                 kCMVideoCodecType_H263,
                                                 width,
                                                 height,
                                                 NULL,
                                                 &_videoFormatDescription);
if (status)
{
   return -1;
}
CFMutableDictionaryRef dpba = CFDictionaryCreateMutable(kCFAllocatorDefault,
                                                        2,
                                                        &kCFTypeDictionaryKeyCallBacks,
                                                        &kCFTypeDictionaryValueCallBacks);
CFDictionarySetValue(dpba,
                     kCVPixelBufferOpenGLCompatibilityKey,
                     kCFBooleanFalse);
VTDictionarySetInt32(dpba,
                     kCVPixelBufferPixelFormatTypeKey,
                     kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange); // use NV12
VTDictionarySetInt32(dpba,
                     kCVPixelBufferWidthKey,
                     dimension.width);
VTDictionarySetInt32(dpba,
                     kCVPixelBufferHeightKey,
                     dimension.height);
VTDictionarySetInt32(dpba,
                     kCVPixelBufferBytesPerRowAlignmentKey,
                     dimension.width);// setup decoder callback record
VTDecompressionOutputCallbackRecord decoderCallbackRecord;
decoderCallbackRecord.decompressionOutputCallback = onDecodeCallback;
decoderCallbackRecord.decompressionOutputRefCon = this;// create decompression session
status = VTDecompressionSessionCreate(kCFAllocatorDefault,
                                      _videoFormatDescription,
                                      nil,
                                      dpba,
                                      &decoderCallbackRecord,
                                      &_session);
// Do Decode
CMSampleBufferRef sampleBuffer;
sampleBuffer = VTSampleBufferCreate(_videoFormatDescription, (void*)data_start, data_len, ts);
VTDecodeFrameFlags flags = 0;
VTDecodeInfoFlags flagOut = 0;
OSStatus decodeStatus = VTDecompressionSessionDecodeFrame(_session,
                                                              sampleBuffer,
                                                              flags,
                                                              nil,
                                                              &flagOut);

我尝试用VideoToolBox压缩H263,我在会话中分辨率为4CIF,并将4CIF NV12图像推送到压缩会话,但H263流的输出是CIF分辨率!

VideoToolBox在压缩和解压缩方面都不支持4CIF H263视频吗?

0 个答案:

没有答案