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. :)
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.
Related
I am trying to display thumbnail images for the downloaded videos in one of my apps. I have shown the images along with the video title inside a table view. I'm using this code for getting the image:
NSURL *videoURL = [NSURL fileURLWithPath:myString];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc]
initWithContentURL:videoURL];
UIImage *thumbnail =
[player thumbnailImageAtTime:1.0
timeOption:MPMovieTimeOptionNearestKeyFrame];
cell.imageView.image = thumbnail;`
Images are showing for the files that are downloaded from YouTube, but I'm not getting the images from .flv video files. Can anyone suggest a solution? This is a sample of my video path
/Users/admin/Library/Application Support/iPhone Simulator/5.0/Applications/AA8DDEED-E91C-47BB-8F1E-C057D9E94B7C/Documents/downloads/qkycmzafawmk.flv
What is the value of thumbnail after the call to -thumbnailImageAtTime:timeOption:? Assuming that this UIImage is not nil, have you checked its alpha property?
If thumbnail is nil, have you checked into the numerous other SO questions regarding this? Here are a couple to get you started:
MPMoviePlayerControlle thumbnailImageAtTime: timeOption: giving
empty UIImage
MPMoviePlayerController
thumbnailImageAtTime:timeOption: simple case doesn't work
This is the tutorial i have followed to solve this issue.Hope this may help someone: http://www.codza.com/extracting-frames-from-movies-on-iphone.
I want to store large number of videos in my application's directory. Will it make my application slow? Or will it take time to launch the application. I am loading videos only when necessary.
It will make large size of your application which is not good...& it will also take time to launch in place of save all ur video u can make user to download that video from server and after that it will be saved in ur doc directory so ur app will be not of large size.............
Where is it located locally
NSURL *url = [NSURL URLWithString:[[NSBundle mainBundle] pathForResource:#"videoname" ofType:#"mov" inDirectory:#""]];
and play with that
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[[player view] setFrame:[self.view bounds]]; // Frame must match parent view
[self.view addSubview:[player view]];
[player play];
[player release];
EDIT:-
The exact answer to this question is NO, it will not make your App Slow,But yeah it ill take some time to load the videos in your App,Time will depend upon number of videos you are loading in your APP. The solution to this is you have to use blocks for ALAssetLibaries.
Have a look on this ALAssetLibary Apple's class reference.
It may help you if not do contact me. Thanks :)
i want to create a childrens book like this one:
http://www.youtube.com/watch?v=Sc1APRfP2o8
and i wanted to know, How do i create the animations? I have searched and all i can find are creating animations via putting together UIImages and then playing them. But i sure hope i do not have to do this with my whole book. I was wondering if there is another program i could use to create the animation in and then import it into Xcode and then just call it to play. Is this possible? Thanks a bunch!
Check out Cocoas2D.
I didn't watch the video but if you want to create an animation easily aybe you can try gif
NSData *gif = [NSData dataWithContentsOfFile:
[[NSBundle mainBundle] pathForResource:#"filename" ofType:#"gif"]];
UIWebView *view = [[UIWebView alloc] initWithFrame:frame];
[view loadData:gif MIMEType:#"image/gif" textEncodingName:nil baseURL:nil];
this might work
I'm just a beginner to iphone development.
Recently i'm doing a project in which images need to be swiped. Could any one help me with it?
The images are stored in a server whose link is given.
I'm need it badly. So please help me
thank you
There are two ways.
You could either look at using a Paging Scroll View
Or, You could look at getting a series of UIImageViews with the correct images in each and then setting up a UISwipeGestureRecogniser for both directions. On the swipe's event handler you can adjust the x and y positions of the imageViews.
This is basic stuff. You should read some of the How-to's on Apple's developer website to help you with the base knowledge.
Edit:
Regarding the Internet images, the code can be adapted into the paging scroll view example:
NSString *path = #"http://merrimusings.mu.nu/archives/images/groundhog2.jpg";
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data cache:NO];
Load the strings from an NSMutableArray instead and you're good to go!
Use Three20 photo Album. Your problem will be solved.
When I use my app (on the device), the actual volume works OK for a while, but after a few days it seems to get 'stuck' at a low level.
Adjusting the volume rocker has no effect - and it shows 'Ringer' text. I've noticed that other people's apps are similarly affected if they show the 'Ringer' text when adjusting the volume. But apps which don't show 'Ringer' text are not affected by this.
How would I remove the 'Ringer' text and get my app to respond properly to different volumes?
I found some code on Apple's forums which fixes it. You have to use the AVFoundation.framework and put a bit of code into your app delegate. And put an audio file called 'blank.aif' into your project. Basically, it's a hack which prepares a file to play, but then never plays it. This fools the system into thinking that sound is being played all the time, which allows the user to use the main volume control.
#import <AVFoundation/AVFoundation.h>
//...
-(void)applicationDidFinishLaunching:(UIApplication *)application {
//volume control hack
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:#"blanksound" ofType:#"aif"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:soundFilePath];
AVAudioPlayer *volumeHack = [[[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil]retain];
[fileURL release];
[volumeHack prepareToPlay];
// other applicationDidFinishLaunching stuff
}