Last active
September 5, 2015 02:28
-
-
Save agrathwohl/ef9b9ec119a8a8e32a3b to your computer and use it in GitHub Desktop.
Class to create a decent-looking GIF from any video file
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
| # gifify.rb | |
| class Gifify | |
| def initialize(video,start,length) | |
| @video = video | |
| @start = start | |
| @length = length | |
| end | |
| def create_palette | |
| `ffmpeg -y -ss "#{@start}" -t "#{@length}" -i "#{@video}" -vf fps=10,scale=320:-1:flags=lanczos,palettegen palette.png` | |
| end | |
| def create_gif(name) | |
| `ffmpeg -ss "#{@start}" -t "#{@length}" -i "#{@video}" -i palette.png -filter_complex "fps=10,scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse" "#{name}.gif"` | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment