Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert GIF to MP4 on device

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.

like image 766
Paul de Lange Avatar asked Oct 29 '12 15:10

Paul de Lange


People also ask

Can you turn a GIF into a MP4?

Can I convert a GIF into a video? Yes, this converter tool quickly and easily transforms GIFs into MP4 video files. Additionally, this convert to MP4 tool is powered by Adobe Premiere, which provides you with professional quality results in seconds.

How do I convert a GIF to a video on Android?

Whichever Android version you are using, download open Convertio app on your phone browser. Step 1: Search for GIF - Download and save GIF files on your Android phone. Step 2: Set output video format – Click the downward arrow on the MP4 and a drop-down menu will pop up.

Can VLC convert GIF to MP4?

Launch VLC. Click on the Media menu, and choose the Convert / Save option from the menu. Go to the File window, click on + Add to select the GIFs you want to convert from your device.


2 Answers

This wasn't so easy. There is a gist snippet here with the solution.

like image 165
Paul de Lange Avatar answered Sep 30 '22 11:09

Paul de Lange


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: { })
like image 45
PowHu Avatar answered Sep 30 '22 11:09

PowHu