video.sh 1.79 KB
function dvdinfo() {
	local TRACK="${1:-1,-1,1}"
	tccat -i /dev/cdrom -T "${TRACK}" |ffprobe -i -
}

function dvdrip() {
	local OPT OPTARG OPTIND
	local OPTEND=0

	local TRACK="1,-1,1"
	local PRESET="veryslow"
	local TUNE="film"
	local OUTFILE="/home/ghopp/data/dvdrip.mp4"

	local USAGE="$(cat <<-EOT
		Usage: $0 [-T track] [-p preset] [-t tune] [-o outfile] [MAP]...
	EOT
	)"
	
	while getopts T:p:t:o:h- OPT
	do
		case $OPT in
			T) TRACK="${OPTARG:-${TRACK}}";;
			p) PRESET="${OPTARG:-${PRESET}}";;
			t) TUNE="${OPTARG:-${TUNE}}";;
			o) OUTFILE="${OPTARG:-${OUTFILE}}";;
			-) OPTEND=1;;
			h) echo ${USAGE} && return 0;;
			?) echo ${USAGE} && return 1;;
		esac
		[[ $OPTEND -eq 1 ]] && break
	done
	shift $((OPTIND - 1))

	tccat -i /dev/cdrom -T "${TRACK}" |\
		ffmpeg -i - -map "${*// / -map }" -c:v libx264 -vf format=yuv420p \
		-preset ${PRESET} -tune ${TUNE} -c:a mp3 -ac 1 ${OUTFILE}
}

function filmrip() {
	local OPT OPTARG OPTIND
	local OPTEND=0

	local USAGE="$(cat <<-EOT
		Usage: $0 [-T track] [-o outfile] [MAP]...
	EOT
	)"

	while getopts T:p:t:o:h- OPT
	do
		case $OPT in
			T) TRACK="${OPTARG}";;
			o) OUTFILE="${OPTARG}";;
			-) OPTEND=1;;
			h) echo ${USAGE} && return 0;;
			?) echo ${USAGE} && return 1;;
		esac
		[[ $OPTEND -eq 1 ]] && break
	done
	shift $((OPTIND - 1))

	dvdrip -T "${TRACK}" -o "${OUTFILE}" $@
}

function animationrip() {
	local OPT OPTARG OPTIND
	local OPTEND=0

	local USAGE="$(cat <<-EOT
		Usage: $0 [-T track] [-o outfile] [MAP]...
	EOT
	)"

	while getopts T:p:t:o:h- OPT
	do
		case $OPT in
			T) TRACK="${OPTARG}";;
			o) OUTFILE="${OPTARG}";;
			-) OPTEND=1;;
			h) echo ${USAGE} && return 0;;
			?) echo ${USAGE} && return 1;;
		esac
		[[ $OPTEND -eq 1 ]] && break
	done
	shift $((OPTIND - 1))

	dvdrip -T "${TRACK}" -o "${OUTFILE}" -t animation $@
}

# vim: set ts=4 sw=4: