Convert Video DVD or ISO to VOB using MPlayer

My custom iso2vob bash shell script to convert video DVD to VOB editable by Avidemux using MPlayer.

#!/bin/bash
info=`mplayer -ao null -vo null -frames 1 -identify -dvd-device "$1" dvd://`
 
if [ "$2" ]; then
 
	titles="$2"
	titles_num=`echo "$titles" | wc -w`
 
else 
 
	titles=`echo -e "$info" | egrep "ID_DVD_TITLE_[0-9]+_LEN" | cut -f 4 -d'_' | sort -n`
	titles_num=`echo -e "$titles" | wc -l`
 
fi
 
function dvdlabel() {
	dd if="$1" count=1 bs=1024 skip=32 2>/dev/null | cut -b 41-72 | sed 's/[^[:alnum:]]._ -]+//g' | sed 's/^ *//g' | rev | sed 's/^ *//g' | rev
}
 
tmp=`mktemp -d`
mkfifo $tmp/fifo
 
if [ -b "$1" ]; then
  echo "source type: block device"
  label=`dvdlabel "$1"`
  of="dvd.$label."`date +%s`
elif [ -f "$1" ]; then
  echo "source type: file"
  label=`dvdlabel "$1"`
  filename=`basename "$1"`
  of="$filename.$label.iso2vob"
else
  echo "error: source type unknown"
  exit 0
fi
 
echo "output dir: $of"
mkdir -p "$of"
 
mkdir -p "$tmp/mnt"
if [ -b "$1" ]; then
  echo "mounting source: block device"
  sudo mount -t iso9660 "$1" "$tmp/mnt" 
elif [ -f "$1" ]; then
  echo "mounting source: file"
  sudo mount -o loop -t iso9660 "$1" "$tmp/mnt" 
else
  echo "error: source type unknown"
  exit 0
fi
find "$tmp/mnt" | egrep -vi 'VOB$' | while read file; do cp -v "$file" "$of"; done
sudo umount "$tmp/mnt"
rm -f "$tmp/mnt"
 
echo "grabbing $titles_num titles..."
 
of="$of/$of"
 
for x in $titles; do
 
    num=`printf '%02i' $x`
    echo "dumping track $x..."
    mplayer $2 $3 $4 $5 $6 $7 $8 $9 -ao null -vo null -dvd-device "$1" dvd://$x -dumpfile $tmp/fifo -dumpstream 2>/dev/null 1>/dev/null &
    pv $tmp/fifo > "$of".$num.vob
 
done
 
rm -rf $tmp

Linkbacks

Use the following URL for manually sending trackbacks: http://rigo.info/lib/plugins/linkback/exe/trackback.php/en:blog:convert_video_dvd_or_iso_to_vob_using_mplayer
en/blog/convert_video_dvd_or_iso_to_vob_using_mplayer.txt · Utolsó módosítás: 2009-04-14 00:00 (külső szerkesztés)
CC Attribution-Noncommercial-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0