Skip to content

Instantly share code, notes, and snippets.

/gif

Created July 26, 2016 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/20993ba3cc001c784731135e0b6e89a8 to your computer and use it in GitHub Desktop.
Save anonymous/20993ba3cc001c784731135e0b6e89a8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
## mac install
# brew install ffmpeg --with-fontconfig --with-freetype
fps=30
scale_w=640
## estimates
# 121mb 3min @ 30fps for 30sec
# 45mb 1:25min @ 10fps for 30sec
youtube-dl -f bestvideo[ext=mp4]+bestaudio[ext=m4a] 'https://www.youtube.com/watch?v=OS-hNRFyFzM' -o "input.mp4" --merge-output-format mp4
## draw text on video
# shadowcolor=0x000000EE:shadowx=2:shadowy=2:x=3:y=th,
#ffmpeg -y -i input.mp4 -vf drawtext="fontfile=Roboto-Bold.ttf: text='WIKILEAKS': fontcolor=white: fontsize=24: box=1: boxcolor=black@0.5: boxborderw=5: x=(w-text_w)/2: y=(h-text_h)/2" -c:a copy output.mp4
## generate palette
ffmpeg -y -i input.mp4 -vf fps=$fps,scale=$scale_w:-1:flags=lanczos,palettegen palette.png
# generate gif
# https://trac.ffmpeg.org/wiki/FilteringGuide
ffmpeg -y -i input.mp4 -i palette.png -filter_complex "fps=$fps,scale=$scale_w:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment