Skip to content

Instantly share code, notes, and snippets.

@agrathwohl
Last active September 5, 2015 02:28
Show Gist options
  • Select an option

  • Save agrathwohl/ef9b9ec119a8a8e32a3b to your computer and use it in GitHub Desktop.

Select an option

Save agrathwohl/ef9b9ec119a8a8e32a3b to your computer and use it in GitHub Desktop.
Class to create a decent-looking GIF from any video file
# 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