首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >VTDecompressionSessionDecodeFrame错误-12916 (kVTFormatDescriptionChangeNotSupportedErr)

问VTDecompressionSessionDecodeFrame错误-12916 (kVTFormatDescriptionChangeNotSupportedErr)
EN

Stack Overflow用户
提问于 2015-01-12 23:35:45
回答 1查看 1.8K关注 0票数 0

我有个问题我想不通了。

首先,我创建了一个VTCompressionSessionCreate (h264),然后在我的压缩回调中,当我开始输入图像时,我得到了一个预期的CMSampleBufferRef sampleBuffer。

为了调试代码流,我创建了一个VTDecompressionSessionCreate,并将包含H264流的'sampleBuffer‘提供给一个VTDecompressionSessionDecodeFrame,我希望在我的解压回调中会有一个CVImageBufferRef imageBuffer。

现在来看问题:

如果我使用压缩回调中的'sampleBuffer‘创建VTDecompressionSessionCreate,如下所示:

代码语言:javascript
复制
CMFormatDescriptionRef format = CMSampleBufferGetFormatDescription(sampleBuffer);

一切都按预期运行,我在解压回调中得到了CVImageBufferRef's。

但是,我的目的是通过网络发送数据,因此我需要从流中的SPS和PPS信息中获取格式描述。

因此,我必须“伪造”获取SPS和PPS,首先提取它们,然后像这样使用它们:

代码语言:javascript
复制
CMFormatDescriptionRef format = CMSampleBufferGetFormatDescription(sampleBuffer);
size_t spsSize, ppsSize;
size_t parmCount;
const uint8_t* sps, *pps;

CMVideoFormatDescriptionGetH264ParameterSetAtIndex(format, 0, &sps, &spsSize, &parmCount, NULL );
CMVideoFormatDescriptionGetH264ParameterSetAtIndex(format, 1, &pps, &ppsSize, &parmCount, NULL );
const uint8_t* const parameterSetPointers[2] = {sps, pps};
const size_t parameterSetSizes[2] = {spsSize, ppsSize};
CMFormatDescriptionRef format2;
status = CMVideoFormatDescriptionCreateFromH264ParameterSets(kCFAllocatorDefault, 2, parameterSetPointers, parameterSetSizes, 4, &format2);

我希望format和format2包含相同的信息,但是:

代码语言:javascript
复制
format = <CMVideoFormatDescription 0x17004fd50 [0x19483ac80]> {
    mediaType:'vide' 
    mediaSubType:'avc1' 
    mediaSpecific: {
        codecType: 'avc1'       dimensions: 1280 x 720 
    } 
    extensions: {<CFBasicHash 0x170270cc0 [0x19483ac80]>{type = immutable dict, count = 2,
entries =>
    0 : <CFString 0x194935fa0 [0x19483ac80]>{contents = "SampleDescriptionExtensionAtoms"} = <CFBasicHash 0x170270c40 [0x19483ac80]>{type = immutable dict, count = 1,
entries =>
    2 : <CFString 0x194939fa0 [0x19483ac80]>{contents = "avcC"} = <CFData 0x1700c9920 [0x19483ac80]>{length = 35, capacity = 35, bytes = 0x0164001fffe100106764001fac56c050 ... 28ee3cb0fdf8f800}
}

    2 : <CFString 0x194936000 [0x19483ac80]>{contents = "FormatName"} = <CFString 0x17003a160 [0x19483ac80]>{contents = "H.264"}
}
}
}

format2:

代码语言:javascript
复制
format2 = <CMVideoFormatDescription 0x174051c70 [0x19483ac80]> {
    mediaType:'vide' 
    mediaSubType:'avc1' 
    mediaSpecific: {
        codecType: 'avc1'       dimensions: 1280 x 720 
    } 
    extensions: {<CFBasicHash 0x17426f9c0 [0x19483ac80]>{type = immutable dict, count = 5,
entries =>
    0 : <CFString 0x19499a608 [0x19483ac80]>{contents = "CVImageBufferChromaLocationBottomField"} = <CFString 0x19499a648 [0x19483ac80]>{contents = "Center"}
    1 : <CFString 0x19499a328 [0x19483ac80]>{contents = "CVFieldCount"} = <CFNumber 0xb000000000000012 [0x19483ac80]>{value = +1, type = kCFNumberSInt32Type}
    3 : <CFString 0x194935fa0 [0x19483ac80]>{contents = "SampleDescriptionExtensionAtoms"} = <CFBasicHash 0x17426b100 [0x19483ac80]>{type = immutable dict, count = 1,
entries =>
    2 : <CFString 0x174031560 [0x19483ac80]>{contents = "avcC"} = <CFData 0x1740c4910 [0x19483ac80]>{length = 35, capacity = 35, bytes = 0x0164001fffe100106764001fac56c050 ... 28ee3cb0fdf8f800}
}

    5 : <CFString 0x19499a5e8 [0x19483ac80]>{contents = "CVImageBufferChromaLocationTopField"} = <CFString 0x19499a648 [0x19483ac80]>{contents = "Center"}
    6 : <CFString 0x1949360e0 [0x19483ac80]>{contents = "FullRangeVideo"} = <CFBoolean 0x19483b030 [0x19483ac80]>{value = false}
}
}
}

format works forma2 don't VTDecompressionSessionDecodeFrame抛出错误-12916。

谢谢你的帮助。

。

EN

回答 1

Stack Overflow用户

发布于 2015-01-23 06:45:19

解决了它。这是我创建包含导致错误的代码流的CMFormatDescriptionRef的方式。

SPS和PPS取自CFSampleBuffer。然后我创建了一个到目前为止还不错的CMVideoFormatDescriptionCreateFromH264ParameterSets。但在同一个应用程序中,我将流转过来,并使用相同的CFSampleBuffer对图片进行解码。这是不起作用的,并导致了错误。我必须首先将有效负载转换为NSData,然后从NSData创建一个新的CFSampleBuffer。然后它就能工作了

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27905518

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档