AVAssetReaderTrackOutput< copyNextSampleBuffer返回错误大小的CMSampleBufferRef

时间:2016-03-18 10:00:49

标签: ios objective-c avfoundation

我有一段代码可以读取视频AVAssetTrack的sampleBuffer:

GET http://mytfsserver:8080/tfs/defaultcollection/_apis/git/repositories 

上述代码几乎适用于所有视频,但视频总是崩溃。经过检查,我发现AVAssetTrack *videoTrack = [[asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]; NSDictionary *pixelBufferAttributes = @{ (id)kCVPixelBufferPixelFormatTypeKey: @(kCVPixelFormatType_32BGRA) }; AVAssetReaderTrackOutput *assetReaderTrackOutput = [[AVAssetReaderTrackOutput alloc] initWithTrack:videoTrack outputSettings:pixelBufferAttributes]; NSError *assetReaderCreationError = nil; AVAssetReader *assetReader = [[AVAssetReader alloc] initWithAsset:asset error:&assetReaderCreationError]; [assetReader addOutput:assetReaderTrackOutput]; [assetReader startReading]; while (assetReader.status == AVAssetReaderStatusReading) { CMSampleBufferRef sampleBuffer = [assetReaderTrackOutput copyNextSampleBuffer]; // Some OpenGL operations here } // and other operations here, too 结果的大小与实际资产不同。

从调试器中打印出来时,CMSampleBufferRef的维度为sampleBuffer,而实际资产的维度为848 x 480

我试图搜索这个问题的原因,但没有找到。你们有没有对此有任何见解?非常感谢任何评论或意见。

谢谢!

1 个答案:

答案 0 :(得分:0)

"真实资产"报告视频的缩放尺寸,其中视频从像素宽度848水平拉伸。