Skip to content

Instantly share code, notes, and snippets.

@conrad784
Created February 22, 2018 21:11
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 conrad784/2787eb128a36ec4401b3a551c42891ae to your computer and use it in GitHub Desktop.
Save conrad784/2787eb128a36ec4401b3a551c42891ae to your computer and use it in GitHub Desktop.
convert mkv movie files to h264 compressed versions in 720p
#!/bin/bash
STOREDIR="smaller/"
OUTPUTFORMAT=".mkv"
SEARCHPATH="*"
mkdir -p ${STOREDIR}
if [ -z "$1" ]
then
echo "No arguments given"
else
args="$1"
if [ $args == "-r" ]; then
SEARCHPATH="*/*"
fi
fi
shopt -s nullglob
for i in $SEARCHPATH.mkv;
do name=`echo $i | cut -d'/' -f1 | rev | cut -d'.' -f2- | rev`;
echo $name;
FD="${STOREDIR}${name}${OUTPUTFORMAT}"
replace_with="720p"
FD="${FD/1080p/$replace_with}"
#echo $FD;
if [ ! -f "${FD}" ];
then ffmpeg -i "$i" -c:v h264 -map 0 -c:a libmp3lame -b:a 192k -s hd720 "${FD}";
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment