Search code examples
iphoneiosios5ios6ios4

Which method to use to extract frames from the video in iphone?


I am working on app where I am supposed to extract the frames of video.So after doing lot of R&D i found following methods.

1)Using iFrameExtractor which uses ffmpeg framework https://github.com/lajos/iFrameExtractor.

2)Using built in property of MPMoviePlayerController

MPMoviePlayerController *movie = [[MPMoviePlayerController alloc] initWithContentURL:  [NSURL   URLWithString:@"Video.mp4"]];
NSNumber t1 = 10;
NSNumber t2 = 11;
NSArray *TimeStamp = [NSArray arrayWithObjects:t1,t2,nil];
[movie requestThumbnailImagesAtTimes:TimeStamp timeOption:MPMovieTimeOptionExact];

3)Using AVAssetImageGenerator

So I am confused of using which method to choose.Any one please tell me the right method by listing demerits of other methods.

I have extract all the frames of video(which can be of maximum 2 minutes)

Thanks in Advance. :)


Solution

  • You are going to have some legal issues to deal with attempting to use ffmpeg compiled into an iOS application, see compatibility-between-the-iphone-app-store-and-the-lgpl for more on that. I had not heard of AVAssetImageGenerator before, but that copyCGImageAtTime method seems like exactly what you would want for small thumbnails, it should be easy to create a UIImage and pass in the returned CGImageRef and then save the result as a PNG. The requestThumbnailImagesAtTimes API likely just calls AVAssetImageGenerator anyway.