I have a function that takes a CVImageBufferRef and passes it to my VTCompressionSession for processing.
The VTCompressionSession is started and my call to VTCompressionSessionCreate is successful.
I am retrieving a video URL from the photo library and processing it using the following:
- (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);
}
}
The block basically just calls
SInt32 status = VTCompressionSessionEncodeFrame(_compressionSession, imageBuffer, CMTimeMake(self.currentFrameNumber++, 30), kCMTimeInvalid, NULL, (__bridge void *)self, NULL);
and the status is -12902. I looked on this site for information about the status, and I can't find any other relevant information. The site says that the error is kVTParameterErr
.
My VTCompressionOutputCallback is not being called.
Can anyone explain this error code to me?