#!/bin/bash
# /usr/local/bin/dvd2ogv
# http://crystalfaeries.net/posix/bin/dvd2ogv
# celeste:crystalfaery 2015-11-12 21:11:37+00:00
# rip a DVD to .ogv format files locally, and then move them to file server
# the required first argument is the name/title of the DVD
# WE SHOULD HAVE CODE RIGHT HERE WHICH VERIFIES THAT THE RAID IS sshfs MOUNTED!
mkdir -p /home/raid/video/dvd # ultimate destination directory
cd /home/raid/video/dvd || exit -1
mkdir -p /home/video/dvd # local directory for transcoding
cd /home/video/dvd || exit -2
if [ $# == 0 ]
then
echo "$0: required single argument is name of dvd sans spaces." 1>&2
exit -3
else
name="`echo $1 | tr '[A-Z]' '[a-z]' | sed 's/ /_/'`"
mount /dev/sr0 \
|| sudo mount /dev/sr0
cd /media/cdrom/VIDEO_TS \
&& for f in *.VOB;do
ffmpeg2theora --optimize -o /home/video/dvd/$( echo "$f" | sed 's/VOB/ogv/' ) "$f"
done \
|| echo "$0: unable to mount dvd" 1>&2
cd /home/video/dvd \
&& eject /dev/sr0 \
|| sudo eject /dev/sr0
rsync -auvzH /home/video/dvd/sr0.webm /home/raid/video/dvd/$name.webm
rm /home/video/dvd/sr0.webm
rsync -auvzH /home/video/dvd/VIDEO_TS.ogv /home/raid/video/dvd/$name.00_0.ogv \
&& rm /home/video/dvd/VIDEO_TS.ogv
for f in $(ls VTS_* | sed 's/^VTS_//g' );do
rsync -auvzH /home/video/dvd/VTS_$f /home/raid/video/dvd/$name.$f \
&& rm /home/video/dvd/VTS_$f
done
cd /home/raid/video/dvd || exit -3
name_tidy
find . -type f -size 0 -exec rm {} \;
fi
exit
syntax highlighted by Code2HTML, v. 0.9.1