Skip to content

Instantly share code, notes, and snippets.

@arthurprogramming
Last active March 24, 2017 20:48
Show Gist options
  • Save arthurprogramming/78197d892688a434ed8d071c39815602 to your computer and use it in GitHub Desktop.
Save arthurprogramming/78197d892688a434ed8d071c39815602 to your computer and use it in GitHub Desktop.
#!/bin/bash
mkdir -p ./{speedup,invert,upload,overlay,downloaded}
#find . -type f -name "*.mp4" -exec rm {} \;
PLAYLIST="$1"
START="$2"
END="$3"
if [[ ! -z $1 ]];
then
echo -e "Downloading videos"
youtube-dl $PLAYLIST --playlist-start $START --playlist-end $END --format mp4 >> ./log
echo -e "Done\n\n"
fi
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
echo -e "putting overlay"
#putting overlay
for file in `find ./downloaded/ -maxdepth 1 -type f -name "*.mp4"`;
do
filename=`basename $file`
if [[ ! -f ./overlay/$filename ]];
then
if [[ -z `lsof $file` ]];
then
ffmpeg -y -i $file -i back.png -filter_complex "[1]lut=a=val*0.3[a];[0][a]overlay=0:0" -strict -2 ./overlay/$filename -y >> ./log
rm -rf $file
fi
fi
done
echo -e "Done\n\n"
echo -e "Inverting videos"
#invert the video horizontaly
for file in `find ./overlay/ -maxdepth 1 -type f -name "*.mp4"`;
do
filename=`basename $file`
if [[ ! -f ./invert/$filename ]];
then
if [[ -z `lsof $file` ]];
then
ffmpeg -i $file -vf hflip -strict -2 ./invert/$filename -y >> ./log
rm -rf $file
fi
fi
done
echo -e "Done\n\n"
echo -e "Speeding up videos"
#speed up the video
for file in `find ./invert/ -maxdepth 1 -type f -name "*.mp4"`;
do
filename=`basename $file`
if [[ ! -f ./speedup/$filename ]];
then
if [[ -z `lsof $file` ]];
then
ffmpeg -i $file -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -strict -2 -map "[v]" -map "[a]" ./speedup/$filename -y >> ./log
rm -rf ./invert/$file
fi
fi
done
echo -e "Done\n\n"
echo -e "Croping videos"
#crop video
for file in `find ./speedup/ -maxdepth 1 -type f -name "*.mp4"`;
do
filename=`basename $file`
if [[ ! -f ./upload/$filename ]];
then
if [[ -z `lsof $file` ]];
then
#ffmpeg -i ./speedup/$file -filter:v "crop=in_w:in_h-210" -c:a copy ./upload/$file -y >> ./log
ffmpeg -i $file -filter_complex 'scale=578:462, pad=720:576:71:57' -c:a copy ./upload/$filename -y >> ./log
rm -rf $file
fi
fi
done
echo -e "Done\n\n"
echo -e "Uploading videos"
for file in `find ./upload -maxdepth 1 -type f -name "*.mp4"`;
do
if [[ -z `lsof $file` ]];
then
FILENAME=`basename $file`
VIDEO_NAME=`echo $FILENAME | sed 's/\([A-Za-z, ]\)_.*/\1/'`
python upload_video.py --file="$file" \
--title="$VIDEO_NAME" \
--description="Videos infantis para todas as idades" \
--keywords="vídeos infantis,galinha pintadinha,peppa pig,desenhos,Team Umizoomi,Bubble Guppies,pocoyo,desenho criança,desenho bebê,bebê,mamãe,filho" \
--category="24" \
--privacyStatus="public"
rm -rf $file
fi
done
echo -e "Done\n\n"
IFS=$SAVEIFS
@arthurprogramming
Copy link
Author

requires youtube-dl
chmod +x ./videouploader.sh
./videouploader.sh [playlisturl start end]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment