Last active
January 1, 2016 20:09
-
-
Save Jpunt/8194971 to your computer and use it in GitHub Desktop.
A tiny bit of ZSH and Handbrake-magic to encode DVD's into mp4's
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 zsh | |
# | |
# Turns ISO-files and VIDEO_TS-directories from $encode_path into decent H264-encoded mp4's (audio/subtitle-tracks are included). | |
# | |
# Requirements: | |
# - ZSH | |
# - HandBrakeCLI | |
encode_path=~/Desktop/Encode | |
handbrake_path=/usr/bin/HandBrakeCLI | |
function encode () { | |
echo "---------------------------" | |
from=$1 | |
to=$2 | |
echo "Encode \"$from\" to \"$to\"" | |
if [ -f $to ] | |
then | |
echo "Encoded file already exists" | |
else | |
$handbrake_path -i "$from" -o "$to" --main-feature --min-duration 1800 --audio 1,2,3,4,5 --subtitle 1,2,3,4,5 --crop 0:0:0:0 --preset 'High Profile' --x264-tune film | |
fi | |
} | |
set -o extended_glob | |
iso_files=($encode_path/**/*.(#i)iso(N)) | |
video_ts_dirs=($encode_path/**/VIDEO_TS(N)) | |
for iso_file in "${iso_files[@]}" | |
do | |
encode $iso_file ${iso_file/.(#i)iso/.mp4} | |
done | |
for video_ts_dir in "${video_ts_dirs[@]}" | |
do | |
encode $video_ts_dir ${video_ts_dir/\/VIDEO_TS/.mp4} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment