Rip chapters of a DVD to separate files
To extract the .VOB for Title 2, Chapter 3
Note that '-chapter 3' and '-chapter 3-' will copy from chapter 3 to the end, and if the chapter number you specify is invalid, the option is ignored, and will therefore copy the full title.
# physical DVD
mplayer dvd://2 -chapter 3-3 -dumpstream -dumpfile ~/3.VOB
# DVD .iso image
mplayer dvd://2 -dvd-device "$dvd_iso" -chapter 3-3 -dumpstream -dumpfile ~/3.VOB
You can use lsdvd
to list title, chapter, cell, audio, video, etc for a physical DVD. However, it doesn't seem(?) to have a way to process a .iso
. You could mount a .iso, if need be.
# count Titles, and count Cells per title.
# eg. ${cell[1]} is the Count of Cells for the first title
# ${cell[titles]} is the Count of Cells for the last title
eval $(lsdvd | sed -n 's/Title: \([0-9]\+\), .* Chapters: \([0-9]\+\), Cells: .*/cells[$((10#\1))]=$((10#\2));/p')
titles=${#cells[@]}
title_num=2
from_cell=1
to_cell=${cell[title_num]}
dvdxchap
, on the other hand, can process a .iso
, but it doesn't list title info. You can, however, specify the title from which you want chapter info.
title_num=2
from_cell=1
# physical DVD
to_cell="$(dvdxchap -t $title_num /dev/dvd | sed -n 's/^CHAPTER\([0-9]\+\).*/\1/p' | sed -n '$p')"
# DVD .iso image
to_cell="$(dvdxchap -t $title_num "$dvd_iso"| sed -n 's/^CHAPTER\([0-9]\+\).*/\1/p' | sed -n '$p')"
When you know the title number you want, and know the number of cells, you can dump them in a loop:
# physical DVD
for ((c=$from_cell; c<$to_cell; c++)) ;do
mplayer dvd://$title_num -chapter $c-$c -dumpstream -dumpfile ~/$c.VOB
done
# DVD .iso image
for ((c=$from_cell; c<$to_cell; c++)) ;do
mplayer dvd://$title_num -dvd-device "$dvd_iso" -chapter $c-$c -dumpstream -dumpfile ~/$c.VOB
done