问题
Is it possible to take a remote (but I can download it first if needed) GIF sequence and make a MPMoviePlayerViewController playable mp4 on the device?
I have tried using http://api.online-convert.com/, but the API doesn't suit and the free version is too restricted for our needs.
Imagemagick for iOS also doesn't seem to include GIF support.
回答1:
This wasn't so easy. There is a gist snippet here with the solution.
回答2:
Swift 3.0 version.
https://gist.github.com/powhu/00acd9d34fa8d61d2ddf5652f19cafcf
Usage
let data = try! Data(contentsOf: Bundle.main.url(forResource: "gif", withExtension: "gif")!)
let tempUrl = URL(fileURLWithPath:NSTemporaryDirectory()).appendingPathComponent("temp.mp4")
GIF2MP4(data: data)?.convertAndExport(to: tempUrl, completion: { })
回答3:
1st - Separate all images from GIF . 2nd - Create video from that separate images.
Please check this one. i think you can solution which you want. With this Link you can easily convert GIF file to MP4. Click https://github.com/dennygajera/gifToMp4
来源:https://stackoverflow.com/questions/13124923/convert-gif-to-mp4-on-device