metasmile / nsgif2 Goto Github PK
View Code? Open in Web Editor NEWThis project forked from nsrare/nsgif
Convert live photos and videos into animated GIFs in iOS, or extract frames from them.
License: MIT License
This project forked from nsrare/nsgif
Convert live photos and videos into animated GIFs in iOS, or extract frames from them.
License: MIT License
I'm encountered with playing video files in UICollectionViewCells, as the AVPlayer of AVPlayerLayer in a cell is slow and choppy, I've turned to use GIF and SDImageCache in UIImageView.
I'd like to know if the GIF could be the same time length of playing like the video, e.g. I'm going to get five seconds of video playing while the GIF is five seconds too?
How to adjust the framesPerSecond, delayTime or frameCount to get this. Thanks.
I have a 3.9 MB 60 second long mp4 video which I am trying to convert to GIF. Testing on iOS 9.3.
Even when I have set the request.framesPerSecond to 1 which should only have 60 total frames in the entire GIF, my app memory spikes to around 270 MB.
Looking further, the memory spike occurs at the if (!CGImageDestinationFinalize(destination)) {
line of the createGIFforTimePoints
method. Any clue what can be done to fix this?
NSURL *videoURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"clip" ofType:@"mp4"]];
NSString *destinationPath = [[self applicationDocumentsDirectory].path
stringByAppendingPathComponent:@"mygif.txt"];
NSGIFRequest * request = [NSGIFRequest requestWithSourceVideo:videoURL destination:[NSURL fileURLWithPath:destinationPath]];
request.framesPerSecond=1;
request.scalePreset=NSGIFScaleOptimize;
request.progressHandler = ^(double progress, NSUInteger position, NSUInteger length, CMTime time, BOOL *stop, NSDictionary *frameProperties) {
NSLog(@"%f - %lu - %lu - %lld - %@", progress, (unsigned long)position, (unsigned long)length, time.value, frameProperties);
};
[NSGIF create:request completion:^(NSURL *GifURL) {
//GifURL is to nil if it failed or stopped.
}];
request 1~5 + chunk size 3
job1 start
job2 start
job3 start
...
job2 finished
job1 finished
job3 finishedstart next chunk
job3 start
job4 start
....
job4 finished
job3 finishedall done.
Please add this line " CGImageRelease(sourceRef)" to release memory.
(UIImage*)imageByScalingToFill:(UIImage *)image size:(CGSize)fillSize rescaleTo:(CGFloat)scaleToRescale{
CGImageRef sourceRef = image.CGImage;
.
.
.
CGImageRelease(destRef);
CGImageRelease(sourceRef);
return destImage;
}
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.