I would like to get all frames of a Video in iOS6 into NSArray
.
I use this code:
-(void) getAllImagesFromVideo
{
imagesArray = [[NSMutableArray alloc] init];
times = [[NSMutableArray alloc] init];
for (Float64 i = 0; i < 15; i += 0.033) // For 25 fps in 15 sec of Video
{
CMTime time = CMTimeMakeWithSeconds(i, 60);
[times addObject:[NSValue valueWithCMTime:time]];
}
[imageGenerator generateCGImagesAsynchronouslyForTimes:times completionHandler:^(CMTime requestedTime, CGImageRef image, CMTime actualTime, AVAssetImageGeneratorResult result, NSError *error) {
if (result == AVAssetImageGeneratorSucceeded)
{
UIImage *generatedImage = [[UIImage alloc] initWithCGImage:image];
[imagesArray addObject:generatedImage];
}
}];
}
On iPad simulator the delay is 90~100 seconds, on iPad device, recieved Memory Warnings and finally crash.
Any idea, solution? Using another more low-level Framework/Library? C++?
Is very important for me! Help me! :)
Thanks!!!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…