Last active
July 2, 2018 22:31
-
-
Save ndbeals/6ee7812563d22d3b60e97e8f573ef978 to your computer and use it in GitHub Desktop.
ffmpeg Recursive Encode script
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
#!/usr/bin/env bash | |
ffmpeg_parse_video () { | |
fullfilename=$(basename -- "$1") | |
extension="${fullfilename##*.}" | |
filename="${fullfilename%.*}" | |
dirpath=$(dirname "$1") | |
ffmpeg -i "$fullfilename" -i "$filename".eng.srt -c:s copy -c:a libfdk_aac -b:a 128k -c:v libx265 -preset veryslow -pix_fmt yuv420p10le -crf 22 "$dirpath/out/$filename.mkv" | |
} | |
ffmpeg_parse_directory () { | |
fullpath=$(readlink -f "$1") | |
echo "FFmpeg parsing directory $fullpath" | |
cd "$fullpath" | |
mkdir -p out | |
for file in "$fullpath"/*.mkv; do | |
filename=$(basename $file) | |
echo "Processing file $filename" | |
ffmpeg_parse_video "$fullpath/$filename" | |
done | |
} | |
if [[ -d $1 ]]; then | |
ffmpeg_parse_directory "$@" | |
else | |
echo "path not a directory, exiting" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment