Convert GIF to MP4 on device

落爺英雄遲暮 提交于 2020-01-23 00:31:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!