Page 1 of 1

mp4 to animated gif using ImageMagick

Posted: 2018-08-02T16:49:23-07:00
by tedriley
Hi friends, have any of you encountered this use case? Using Rails 5 on a project to do this and wasn't able to find anything on StackOverflow. Hoping to convert an mp4 to an animated gif using ImageMagick. Any help is greatly appreciated, or just a point to a tutorial or the right direction. Many thanks! 8)

Re: mp4 to animated gif using ImageMagick

Posted: 2018-08-02T16:59:19-07:00
by fmw42
I believe to be able to convert mp4, you need ffmpeg loaded where ImageMagick could find it. If that is available, then the following should work in the command line. Sorry I do not know Rails.

Code: Select all

convert -delay X image.mp4 -loop 0 animation.gif
If that does not work, then try

Code: Select all

convert -delay X image.mp4 -coalesce -layers optimize -loop 0 animation.gif
Where X is the desired frame delay in ticks (1/100 s)

See also https://www.imagemagick.org/Usage/video/




Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620

If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli


For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown