Created
August 17, 2016 18:30
-
-
Save derak-kilgo/96d3d3e05058ad81d8d32c539248f00a to your computer and use it in GitHub Desktop.
Convert a mp4 clip into a gif with php, imagemagick and ffmpeg. From OSX, these are easy to install with homebrew.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$video = __DIR__ . '/video.mp4'; | |
$fps = 4; | |
# Convert an MP4 to a GIF - Requires ffmpeg | |
`ffmpeg -i "$video" -pix_fmt rgb24 -r $fps "$video.gif"` | |
# optimize the gif - Requires imagemagick | |
# via http://superuser.com/questions/436056/how-can-i-get-ffmpeg-to-convert-a-mov-to-a-gif | |
`convert -layers Optimize "$video.gif" "$video.gif"` |
Theres a way to do the reverse process (.gif to .mp4)?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on https://gist.github.com/seyhunak/a5ccc3693bb1aae1787c
Thanks for showing this is possible with ffmpeg.