Last active
April 11, 2017 18:21
Star
You must be signed in to star a gist
This file contains 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
#!/bin/bash | |
# All GIFS and VIDEOS at: | |
# https://gist.github.com/goncalomb/0611db6ae883756c345a7802f2fdef85/f2f6e08b971884d4eca5d4ac9f5df13fb14fff1c | |
# Original Video: | |
# https://www.youtube.com/watch?v=BMYxImN6EBo | |
video="video_BMYxImN6EBo.mp4" # 720p | |
fontr="/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-R.ttf" | |
fontb="/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-B.ttf" | |
palette="/tmp/palette.png" | |
function resetfilters { | |
filters=${1:-"scale=-1:360:flags=lanczos"} | |
} | |
function addfilters { | |
if [[ -z "$filters" ]]; then filters=$1; else filters="$filters,$1"; fi | |
} | |
function addtxtsub { | |
addfilters "drawtext=enable='between(t,$1)':fontfile=$fontr:text=$2:fontcolor=white:fontsize=24:box=1:boxcolor=black@0.8:boxborderw=5:x=(w-text_w)/2:y=h-text_h-20" | |
} | |
function addtxtfree { | |
addfilters "drawtext=enable='between(t,$1)':fontfile=$fontb:text=$2:fontcolor=white:box=1:boxcolor=black@0.5:boxborderw=5:$3" | |
} | |
function mkgif { | |
# http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html | |
ffmpeg -v warning $params -i "$video" -vf "fps=15,$filters,palettegen" -y $palette | |
ffmpeg -v warning $params -i "$video" -i $palette -lavfi "fps=15,$filters [x]; [x][1:v] paletteuse=dither=sierra2" -y "$1" | |
} | |
function mkvideo { | |
ffmpeg -v warning $params -i "$video" -vf "$filters" -crf 18 -preset veryslow -y "$1" | |
} | |
echo "0-first" | |
resetfilters | |
addtxtfree "1.8,1.95" "FIRST" "fontsize=30:x=w*0.27:y=(h-text_h)*0.5" | |
addtxtfree "2.4,2.6" "FIRST" "fontsize=50:x=w*0.43:y=(h-text_h)*0.49" | |
addtxtfree "2.9,3.1" "FIRST" "fontsize=70:x=w*0.39:y=(h-text_h)*0.5" | |
params="-ss 4:19 -t 5" | |
mkgif "0-first.gif" | |
mkvideo "0-first.mp4" | |
echo "1-is-simon-dead" | |
resetfilters | |
addtxtfree "1.5,3.2" "Is Simon really dead?" "fontsize=40:x=w*0.35:y=h*0.31" | |
params="-ss 4:28 -t 4" | |
mkgif "1-is-simon-dead.gif" | |
mkvideo "1-is-simon-dead.mp4" | |
echo "2-daughter" | |
resetfilters | |
addtxtfree "2,4.5" "My seven year old daughter watches the Yogscast" "fontsize=24:x=(w-text_w)*0.5:y=(h-text_h)*0.52" | |
addtxtfree "4.6,5.9" "and you swore" "fontsize=24:x=w*0.31:y=(h-text_h)*0.54" | |
addtxtfree "6,6.4" "and now" "fontsize=24:x=w*0.34:y=(h-text_h)*0.56" | |
addtxtfree "6.5,8" "SHE\\\\\'S DEAD!" "fontsize=40:x=w*0.34:y=(h-text_h)*0.58" | |
params="-ss 4:50 -t 8" | |
mkgif "2-daughter.gif" | |
mkvideo "2-daughter.mp4" | |
echo "3-gg-youtube" | |
resetfilters | |
params="-ss 5:19 -t 14" | |
addtxtfree "2,3.9" "Why is there only 300 views" "fontsize=24:x=(w-text_w)*0.5:y=(h-text_h)*0.5" | |
addtxtfree "4,5.9" "but 4000 likes" "fontsize=24:x=(w-text_w)*0.5:y=(h-text_h)*0.4" | |
addtxtfree "6,7.5" "it doesn\\\\\'t make any sense!" "fontsize=24:x=(w-text_w)*0.5:y=(h-text_h)*0.4" | |
addtxtfree "8.2,9.2" "GG YouTube" "fontsize=30:x=(w-text_w)*0.8:y=(h-text_h)*0.2" | |
addtxtfree "10.5,11.2" "FIRST KILLZ" "fontsize=40:x=(w-text_w)*0.5:y=(h-text_h)*0.5" | |
mkgif "3-gg-youtube.gif" | |
mkvideo "3-gg-youtube.mp4" | |
echo "4-nice-people" | |
resetfilters "crop=720:720:0:0,scale=-1:480:flags=lanczos" | |
addtxtsub "0,3" "We basically just.. We are..." | |
addtxtsub "3.5,5.5" "We\\\\\'ll get rid of those people" | |
addtxtsub "6,8" "and replace them with nice people." | |
params="-ss 5:35 -t 8" | |
mkgif "4-nice-people.gif" | |
mkvideo "4-nice-people.mp4" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment