# ========================================================================= # File: dvd-backup_with-subtitles.txt # # Copyright (c) 2005 and onwards, Josh Glover # # LICENCE: # # This work is licensed under the Creative Commons Attribution-ShareAlike # License. To view a copy of this license, visit: # # http://creativecommons.org/licenses/by-sa/1.0/ # # or send a letter to: # # Creative Commons # 559 Nathan Abbott Way # Stanford, California 94305, USA. # # DESCRIPTION: # # Captain's Log for __DESCRIPTION__. # # USAGE: # # Read the Captain's Log, pasting bits into your terminal once you # have verified that all paths, settings and so on are right for your # environment, *OR*, copy the Captain's Log somewhere on your box, # edit it to fit your environment, and run it (possibly as root): # # bash dvd-backup_with-subtitles.txt # # MODIFICATIONS: # # Josh Glover (2005/02/12): Initial revision # ========================================================================= # 0. Configuration export DVD_DEV=/dev/dvd export DVD_MNT=/mnt/dvd export BURN_DIR=/scratch/burndvd export MASTER_DIR=/scratch/masterdvd export RIP_DIR=/scratch/ripdvd export SHRINK_DIR=/scratch/shrinkdvd # 1. Make all of the output directories for i in "${BURN_DIR}" "${MASTER_DIR}" "${RIP_DIR}" "${SHRINK_DIR}"; do mkdir "$i" done # 2. Copy the VOB files mount "${DVD_MNT}" vobcopy -i "${DVD_MNT}" -o "${RIP_DIR}" -n 1 -l -v export vob=`basename "${RIP_DIR}"/*.vob` # 3. Shrink the video track [optional]. If your VOB file is less than 4.8G, # skip ahead to step 5, substituting the name of your VOB file for the # shrunk movie file (.mpg file). export m2v="${vob}.m2v" export ac3="${vob}.ac3" export mpg="${vob}.mpg" tcextract -i "${RIP_DIR}/${vob}" -d 2 -t vob -x mpeg2 >"${RIP_DIR}/${m2v}" tcextract -i "${RIP_DIR}/${vob}" -d 2 -t vob -x ac3 -a 0 >"${RIP_DIR}/${ac3}" spuunmux -o "${SHRINK_DIR}/subtitles" -s 0 -v 1 "${RIP_DIR}/${vob}" export sub="${vob}.SUBTITLED.mpg" rm "${RIP_DIR}/${vob}" export m2vsize=`ls -s "${RIP_DIR}/${m2v}" | awk '{ print $1 }'` export ac3size=`ls -s "${RIP_DIR}/${ac3}" | awk '{ print $1 }'` export subsize=`du "${SHRINK_DIR}/" | tail -1 | awk '{ print $1 }'` export factor=`perl -e "print ((((${m2vsize} * 1024) / (4600000000 - (${ac3size} * 1024) - (${subsize} * 1024))) * 1.04) + 0.01);"` tcrequant -i "${RIP_DIR}/${m2v}" -o "${SHRINK_DIR}/${m2v}" -f ${factor} -d 2 rm "${RIP_DIR}/${m2v}" mplex -f 8 -S 0 -v 1 -o "${SHRINK_DIR}/${mpg}" \ "${SHRINK_DIR}/${m2v}" "${RIP_DIR}/${ac3}" rm "${SHRINK_DIR}/${m2v}" "${RIP_DIR}/${ac3}" spumux -m dvd -s 0 -v 1 -P "${SHRINK_DIR}/subtitles.xml" \ <"${SHRINK_DIR}/${mpg}" >"${SHRINK_DIR}/${sub}" rm "${SHRINK_DIR}/${mpg}" # 4. Author the DVD dvdauthor -o "${MASTER_DIR}/" "${SHRINK_DIR}/${sub}" dvdauthor -T -o "${MASTER_DIR}/" rm "${SHRINK_DIR}/${sub}" # 5. Burn the DVD export iso="${vob}.iso" export title=`echo "${vob}" | sed -e 's/\.vob$//'` mkisofs -dvd-video -V "${title}" -o "${BURN_DIR}/${iso}" "${MASTER_DIR}" sudo cdrecord-ProDVD -v dev=ATAPI:0,0,0 speed=4 -dao -eject "${BURN_DIR}/${iso}"