Ios VTCompressionSessionCodeFrame错误代码-12902
我有一个函数,它获取CVImageBufferRef并将其传递给VTCompressionSession进行处理 VTCompressionSession已启动,我对VTCompressionSessionCreate的调用已成功 我正在从照片库中检索视频URL,并使用以下方法进行处理:Ios VTCompressionSessionCodeFrame错误代码-12902,ios,h.264,video-toolbox,cvpixelbuffer,Ios,H.264,Video Toolbox,Cvpixelbuffer,我有一个函数,它获取CVImageBufferRef并将其传递给VTCompressionSession进行处理 VTCompressionSession已启动,我对VTCompressionSessionCreate的调用已成功 我正在从照片库中检索视频URL,并使用以下方法进行处理: - (void)processImageBuffersFromURL:(NSURL *)url withBlock:(void (^)(CVImageBufferRef bufferRef))block {
- (void)processImageBuffersFromURL:(NSURL *)url withBlock:(void (^)(CVImageBufferRef bufferRef))block {
AVAsset *asset = [AVAsset assetWithURL:url];
AVAssetTrack *track = [[asset
tracksWithMediaType:AVMediaTypeVideo]
objectAtIndex:0];
AVAssetReaderTrackOutput
*readerTrack = [AVAssetReaderTrackOutput
assetReaderTrackOutputWithTrack:track
outputSettings:@{(id)kCVPixelBufferPixelFormatTypeKey: @(kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange)}];
AVAssetReader *reader = [AVAssetReader assetReaderWithAsset:asset
error:nil];
[reader addOutput:readerTrack];
[reader startReading];
CMSampleBufferRef sample = NULL;
while ((sample = [readerTrack copyNextSampleBuffer])) {
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sample);
block(imageBuffer);
}
}
街区基本上只会呼叫
SInt32 status = VTCompressionSessionEncodeFrame(_compressionSession, imageBuffer, CMTimeMake(self.currentFrameNumber++, 30), kCMTimeInvalid, NULL, (__bridge void *)self, NULL);
状态是-12902。我查看了有关状态的信息,但找不到任何其他相关信息。该网站称错误为kVTParameterRR
未调用我的VTCompressionOutputCallback
有人能给我解释一下这个错误代码吗?原来我的压缩会话是空的,因此kVTParameterRR 中断VTCompressionSessionEncodeFrame将有助于找出哪个参数不正确,文档会告诉您哪些参数可以为空(除了会话和图像缓冲区外,几乎所有参数都可以为空)
在我的特殊情况下,我无意中在类方法而不是实例方法中使用VTCompressionSessionCreate,因此我发送imageBuffer的实例没有自己的压缩会话。结果是我的压缩会话为空,因此kvtParameterRR 中断VTCompressionSessionEncodeFrame将有助于找出哪个参数不正确,文档会告诉您哪些参数可以为空(除了会话和图像缓冲区外,几乎所有参数都可以为空) 在我的特殊情况下,我无意中在类方法而不是实例方法中使用VTCompressionSessionCreate,因此我发送imageBuffer的实例没有自己的压缩会话