1

I want to implement such a function that enable users to make GIF directly from their camera.

In detail, I want to show users a camera view, and a record button. When the button is tapped, the camera starts to record video. In fact, however, behind the scene the camera is actually taking photos at constant speed, say 1 shot per 0.5 second. When the record ends, we got an array of images and then connect them into a GIF.

I think there might be 2 approaches:

1、Directly taking images: Use AVCaptureStillImageOutput's -captureStillImageAsynchronouslyFromConnection method. But it will block UI every time it is called.

2、Take a video and extract several images from it. I have checked video taking libraries such as PBJVision and SCRecorder, and noticed that taking video is typically writing data to a mp4 file locally. I cannot figure out how to extract images at specific time intervals from a video file. Also, is there a way to store the video in memory?

Could anyone help?

HanXu
  • 5,507
  • 6
  • 52
  • 76

2 Answers2

0

Creating Gif Create and and export an animated gif via iOS? Convert Images to gif using ios

Extract Images from Video Get a particular frame by time value using AVAssetReader

Similar here Creating a Movie from Images How do I export UIImage array as a movie?

Community
  • 1
  • 1
N0mi
  • 714
  • 7
  • 14
0

You can use a library called 'Regift' by Matthew Palmer, which will convert video to GIF.

Here it is: https://github.com/matthewpalmer/Regift

You can also check out the following answer here on SO:

https://stackoverflow.com/a/28150109/3288936

Hope this will help! :)

Community
  • 1
  • 1
Chinmay
  • 1,714
  • 2
  • 11
  • 5