Last active
October 18, 2017 02:32
-
-
Save dorgan/0727f42d3b628169e554b5c02cb2c415 to your computer and use it in GitHub Desktop.
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
# Usage: rip-transcode.sh <deviceId> <finalPath> <tmpPath> <NAME_OF_DVD> <TRANSCODE> | |
dvdDevice=$1 | |
savePath=$2 | |
tmpPath=$3 | |
titleName=$4 | |
transcode=${5:-TRUE} | |
tmpFolder="${tmpPath}/${titleName}" | |
destFolder="${savePath}/${titleName}" | |
check_errs() | |
{ | |
# Function. Parameter 1 is the return code | |
# Para. 2 is text to display on failure | |
if [ "${1}" -ne "0" ]; then | |
echo "ERROR # ${1} : ${2}" | |
exit ${1} | |
fi | |
} | |
# This is for Linux installations - follow http://www.makemkv.com/forum2/viewtopic.php?f=3&t=224 for compilation | |
MAKEMKVCON=`which makemkvcon` | |
echo "Running: find \"${tmpFolder}\" -name *.mkv" | |
MKV=`find "${tmpFolder}" -name *.mkv` | |
if [ ! -f "${MKV}" ]; then | |
echo ":: Locating Main Track on Media" | |
echo " :: Scanning ${dvdDevice} for the primary title of ${titleName}, saving to ${tmpFolder}" | |
echo " :: Locating the longest title" | |
# this line runs makemkv on info which identifies all the titles (stripping our Copy Protected ones etc) | |
# perl then gets the times from the makemkvcon output of each identified title and then calculates the time | |
# it them prints out the title with the longest time | |
titleId=`$MAKEMKVCON info -r --decrypt disc:$dvdDevice \ | |
| perl -e '$g=0;while (<>) { if (/TINFO:(.*?),9,.*,\"(\d\d?):(\d\d?):(\d\d?)\"/) {$x=($2*3600)+($3*60)+$4;if($x>$g){$g=$x;$t=$1} } } print "$t"'` | |
check_errs $? "Problem extracting information with makemkvcon" | |
echo "" | |
echo ":: Starting MKV Extraction" | |
echo " :: Title $titleId will be extracted" | |
echo " :: Creating MKV Extraction directory" | |
mkdir -p "${tmpFolder}" | |
echo " :: Running - makemkvcon mkv dev:$dvdDevice ${titleId} \"${tmpFolder}\"" | |
$MAKEMKVCON --decrypt --directio=true --progress=-stdout mkv disc:$dvdDevice $titleId "${tmpFolder}" | |
check_errs $? "Problem while creating MKV with makemkvcon" | |
MKV=`find "${tmpFolder}" -name *.mkv` | |
else | |
echo "FOUND: ${MKV}" | |
fi | |
if [ "$transcode" == "TRUE" ]; then | |
echo "Transcoding ENABLED" | |
echo "" | |
echo ":: Transcoding video" | |
echo " :: Making directory ${savePath}/$titleName" | |
mkdir -p "${savePath}/${titleName}" | |
echo " :: Running transcode-video --quick \"${MKV}\" -o \"${destFolder}/${titleName}.mkv\"" | |
transcode-video --quick "${MKV}" -o "${destFolder}/${titleName}.mkv" | |
check_errs $? "Problem while transcoding file" | |
echo "" | |
echo ":: Cleaning Up" | |
rm -rf "${tmpFolder}" | |
else | |
echo "Transcoding DISABLED" | |
fi | |
echo "DONE!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment