Last active
January 11, 2018 20:27
-
-
Save alex-paterson/7757b4e8bc34f9adaea6a609e54e80de to your computer and use it in GitHub Desktop.
Meme generator
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
#!/bin/bash -l | |
hash brew 2>/dev/null || { | |
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
} | |
hash ffmpeg 2>/dev/null || { | |
brew install ffmpeg --with-libvpx | |
} | |
hash youtube-dl 2>/dev/null || { | |
brew install youtube-dl | |
} | |
BASE_MEME=https://www.youtube.com/watch?v=6JCy4MOhf7I; | |
echo 'Downloading intro...' | |
youtube-dl -q $BASE_MEME -f 'mp4' -o video_meme_intro.mp4 | |
echo 'Downloading input...' | |
youtube-dl -q -f 'mp4' $1 -o video_meme_input.mp4 | |
echo 'Cropping intro...' | |
ffmpeg -v 0 -ss 0 -t 6 -i video_meme_intro.mp4 -codec copy video_meme_intro0.mp4 | |
rm video_meme_intro.mp4 | |
if [ -z "$2" ] | |
then | |
mv video_meme_input.mp4 video_meme_input0.mp4; | |
else | |
if [ -z "$3" ] | |
then | |
echo "Input doesn't require cropping..."; | |
else | |
echo 'Cropping input...' | |
ffmpeg -v 0 -y -ss $2 -i video_meme_input.mp4 -t $3 -codec copy video_meme_input0.mp4; | |
rm video_meme_input.mp4; | |
fi | |
fi | |
echo 'Concatenating videos...' | |
ffmpeg -y -v 0 -i video_meme_intro0.mp4 -i video_meme_input0.mp4 -filter_complex "[0:v:0] [0:a:0] [1:v:0] [1:a:0] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" output.mp4; | |
echo 'Done!' | |
rm video_meme_input0.mp4; | |
rm video_meme_intro0.mp4; | |
open './output.mp4'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment