I am trying to grab the individual frames from a video file (7 seconds long) and running into huge memory issues.
I am loading up an asset with AVURLAsset then creating an AVAssetReader and an accompanying AVAssetReaderTrackOutput (with pixel format kCVPixelFormatType_32BGRA). Ev开发者_开发百科erything seems to work just fine except for the massive memory hit that ends up getting my app shutdown by the OS almost instantly.
As soon as I call [myAVAssetReader startReading] memory spikes up 25 megs and it only gets worse from there.
Even if I just call [myAVAssetReader startReading] then [myAVAssetReader cancelReading] and [myAVAssetReader release] the 25 megs is never released. It only gets worse once I go into a loop gathering frames:
CMSampleBufferRef sample = [output copyNextSampleBuffer];
while( sample != NULL )
{
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer( sample );
// Lock the image buffer
CVPixelBufferLockBaseAddress( imageBuffer, 0 );
// Do stuff with the imageBuffer
// We unlock the image buffer
CVPixelBufferUnlockBaseAddress( imageBuffer, 0 );
// done with the sample
CFRelease( sample );
sample = [output copyNextSampleBuffer];
}
Any clues as to how to free the memory that the AVAssetReader is using?
加载中,请稍侯......
精彩评论