cameronehrlich / cemoviemaker Goto Github PK
View Code? Open in Web Editor NEWCEMovieMaker is a quick and dirty way to create a movie from and array of UIImages.
License: MIT License
CEMovieMaker is a quick and dirty way to create a movie from and array of UIImages.
License: MIT License
Thanks for creating this library. Using it, I get the message that the video has been created, but I'm not able to save it to my library.
This is what I currently have:
[self.movieMaker createMovieFromImages:[_spinImages copy] withCompletion:^(NSURL *fileURL){
NSLog(@"movie at fileURL: %@", fileURL); // this gives me the log movie at fileURL: file:///var/mobile/Containers/Data/Application/7AF6F798-346B-4CE8-B5FA-88C7FB8D5BA0/Documents/export.mov
UISaveVideoAtPathToSavedPhotosAlbum ([fileURL absoluteString],self,nil, nil);
}];
Going into my photo album, I don't see the saved video.
Using your code, I'm able to export a video, but it seems to crop the images incorrectly.
Here is what my code looks like:
UIImage *resizedPhoto = [self imageWithImage:rotatedPhoto scaledToSize:CGSizeMake(704, 704)];
// save resizedPhoto to gallery for testing
// UIImageWriteToSavedPhotosAlbum(resizedPhoto, nil, nil, nil);
// add image to spin array
[_spinImages addObject:resizedPhoto];
imgUploadedCount++;
if(imgUploadedCount == SPIN_IMAGES){
NSLog(@"generating video");
NSDictionary *settings = [CEMovieMaker videoSettingsWithCodec:AVVideoCodecH264 withWidth:resizedPhoto.size.width andHeight:resizedPhoto.size.height];
self.movieMaker = [[CEMovieMaker alloc]
initWithSettings:settings];
[self.movieMaker createMovieFromImages:[_spinImages copy] withCompletion:^(NSURL *fileURL){
NSLog(@"movie at fileURL: %@", fileURL);
}];
}
These are the resulting images:
and the resulting video:
https://dl.dropboxusercontent.com/u/1000620/2015-07-10%2010.31.00-2.mov
CEMovieMaker
works perfectly in my app to generate a video from UIImages. But it use a lot of memory and sometimes too many.
My tests on an iPhone 6 show that you can pass about 350-400 images maximum. After this, the application crash because of memory excess.
I will try to use less memory but maybe you already have an idea ?
Hi, I'm doing something like that with your class
NSMutableArray * imageArray = [NSMutableArray new];
[imageArray addObject:[UIImage imageNamed:@"gif-anime.jpg"]];
[imageArray addObject:[UIImage imageNamed:@"gif-anime-2.jpg"]];
[imageArray addObject:[UIImage imageNamed:@"gif-anime-3.jpg"]];
UIImage * first = (UIImage *)imageArray[0];
NSDictionary *settings = [CEMovieMaker videoSettingsWithCodec:AVVideoCodecH264 withWidth:first.size.width andHeight:first.size.height];
self.movieMaker = [[CEMovieMaker alloc] initWithSettings:settings];
[self.movieMaker createMovieFromImages:[imageArray copy] withCompletion:^(NSURL *fileURL) {
NSLog(@"succes");
}];
And i'm getting this result :
https://drive.google.com/open?id=0B-M3INH9OA9VUjh2SGl0d1Fxd3M
Images :
https://drive.google.com/open?id=0B-M3INH9OA9VWmFteWpJWVdhX0k
https://drive.google.com/open?id=0B-M3INH9OA9VdHFyNW9OWkhXbWc
https://drive.google.com/open?id=0B-M3INH9OA9VMjZubVFmWjAxeHM
Thanks
Would be really helpful. Cheers!
let's say image width equals to 4800, then create a valid video failed.
When images show or disappear in video, I want there are animations or transition effects. Can iOS SDK do this?
I have an array of square images that are perfectly fine but when I create a movie from them, the images are turned 90 degrees counterclockwise. Any idea why this is happening?
Thanks!
is it possible to create a looping video? I want to have a similar effect as an animated GIF but with video files.
When I convert the image into video using you framework its alpha is disturbed. The Image gets a bit bright then the original one in the video. Can u please help me in this.
Hi!
I'm having a problem with changing the length of time that each image stays on the screen. For example I'd like the user to choose an amount of time, in seconds, and the image would be on the screen for that length of time. I've tried changing the _frameTime variable, but to no avail. It's set default to CMTimeMake(1,1) which places each image on the screen for 1 second. However if I change it to another number, such as _frameTime = CMTimeMake(10, 2); this should show each image for 5 seconds, however it only applies to the first image, then the rest of the images are shown for a minimal length of time.
Thanks
Kieran
Hello, I have an application which uses an array of images and a variable time per frame starting from 0.04 seconds to 2 seconds. So if the array has 20 images and the time per frame is 0.5 , the total video time should be 20 * 0.5 = 10 seconds.
Would it be possible to do something like this? I am trying to modify the self.movieMaker.frameTime = CMTimeMake(self.frameArray.count, 1.0 / speedPerFrame); but I get some unexpected video output.
Hi Cameron, just wanted to say that you've done a really nice job on this project! However, I'm having trouble with some Swift code. Whenever I call the MPMovieController, a black screen shows. Here is some code:
func makeMovie(){
let settings:NSDictionary = CEMovieMaker.videoSettingsWithCodec(AVVideoCodecH264, withWidth: images![0].size.width, andHeight: images![0].size.height)
let movieMaker = CEMovieMaker(settings: settings as [NSObject : AnyObject])
movieMaker.createMovieFromImages(self.images) { (fileURL:NSURL!) -> Void in
self.viewMovieAtURL(fileURL)
}
}
func viewMovieAtURL(fileURL:NSURL){
var moviePlayer : MPMoviePlayerController?
moviePlayer = MPMoviePlayerController(contentURL: fileURL)
if let player = moviePlayer {
player.view.frame = self.view.bounds
player.prepareToPlay()
player.scalingMode = .AspectFill
self.view.addSubview(player.view)
}
}
I think it may be a problem with the fileURL, though no errors are being thrown. The MPMoviePlayer just shows a black screen. Thoughts?
Hi!
I have a problem with generating a movie.
This is my method for creating a movie:
+ (NSURL *)processMovieWithPhotos:(NSArray *)photosArray
{
__block NSURL *finalMovieURL = nil;
NSMutableArray *frames = [[NSMutableArray alloc] init];
NSArray *resizedPhotosArray = [self resizedPhotosToCreateMovieFromArray:photosArray];
UIImage *onePhoto = resizedPhotosArray[0];
NSDictionary *settings = [CEMovieMaker videoSettingsWithCodec:AVVideoCodecH264 withWidth:onePhoto.size.width andHeight:onePhoto.size.height];
CEMovieMaker *movieMaker = [[CEMovieMaker alloc] initWithSettings:settings];
[frames addObjectsFromArray:resizedPhotosArray];
[movieMaker createMovieFromImages:[frames copy] withCompletion:^(BOOL success, NSURL *fileURL){
if (success) {
finalMovieURL = fileURL;
}
}];
return finalMovieURL;
}
Method resizedPhotosToCreateMovieFromArray: resizes photos proportion for height of 1920 and returns photos array.
The problem is that Movie file size is 0 kbytes and in method createMovieFromImages:withCompletion: success is equal to NO.
Any idea for this issue?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.