2

I'm building an iOS app which requires me to allow the users to record a 15sec clip (with UIImagePickerController for example) and then convert it into an animated GIF. How could I achieve this? Is there any library/framework available for such task?

Thanks!

lxt
  • 31,146
  • 5
  • 78
  • 83
Abhishek
  • 337
  • 3
  • 11
  • You can find it useful http://stackoverflow.com/questions/14915138/create-and-and-export-an-animated-gif-via-ios – voromax May 28 '13 at 12:47

3 Answers3

5

I don't believe there is any existing library that would do a straight conversion for you. There's a lot of libraries for displaying animated GIFs - far fewer native Objective-C libraries for creating them.

Fortunately, iOS does have support for saving as GIFs. There's an existing StackOverflow answer that covers how to create animated GIFs in-depth here:

Create and and export an animated gif via iOS?

...there's also a library on GitHub that abstracts the lower-level stuff away, although it's not been maintained for a while (link here).

All you'll need to do is create an array of the frames you want to convert into your GIF. I strongly recommend you don't try and convert every single frame in your 15 second video, if only because you'll end up with a very large GIF at a frame-rate that's too high. You would be better off picking every other, or even every 3/4 frames from your video sample. Capturing images from video is also pretty well documented on iOS.

Community
  • 1
  • 1
lxt
  • 31,146
  • 5
  • 78
  • 83
5

This gist code piece may help you.

https://gist.github.com/mayoff/4969104

It shows how to export frames into a gif image.

David Ng
  • 470
  • 4
  • 13
4

I recently created a library called Regift for converting videos to gifs on iOS. Hopefully it will help anyone coming to this in the future :)

matthewpalmer
  • 2,619
  • 3
  • 25
  • 27