Skip to content

Instantly share code, notes, and snippets.

@alex-paterson
Last active January 11, 2018 20:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alex-paterson/7757b4e8bc34f9adaea6a609e54e80de to your computer and use it in GitHub Desktop.
Save alex-paterson/7757b4e8bc34f9adaea6a609e54e80de to your computer and use it in GitHub Desktop.
Meme generator
#!/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