Difference between revisions of "Extract DVD"

From Maze's wiki
Jump to: navigation, search
Line 18: Line 18:
 
Use lsdvd to see what's on DVD. Determine the stream you would like to extract as well as the aid for audio and the sid for subtitles.
 
Use lsdvd to see what's on DVD. Determine the stream you would like to extract as well as the aid for audio and the sid for subtitles.
 
<pre>
 
<pre>
lsdvd -x /dev/dvd
+
lsdvd -x
 
</pre>
 
</pre>
 
Write the stream to the harddrive so the next steps will go faster.
 
Write the stream to the harddrive so the next steps will go faster.
 
<pre>
 
<pre>
mplayer dvdnav://<stream> -dumpstream -dumpfile <title>.vob
+
vobcopy -l -n 1 -t <title>
 
</pre>
 
</pre>
 
As I find it acceptable to have my DVDs compressed to 25% of its size I use the follow calculations to get the bitrate for video and audio.
 
As I find it acceptable to have my DVDs compressed to 25% of its size I use the follow calculations to get the bitrate for video and audio.
 
<pre>
 
<pre>
length=`lsdvd -t <stream> -Ox 2>/dev/null | grep length | sed 's/^[^>]*>//' | sed 's/\..*//'`;vobsize=`find <title>.vob -printf '%s\n'`; bitrate=$(($vobsize*8/$length/4/5)); echo "audio bitrate = $(($bitrate/1000)) kb/s";echo "video bitrate = $(($bitrate*4/1000)) kb/s"
+
length=`lsdvd -t <stream> -Ox 2>/dev/null | grep length | sed 's/^[^>]*>//' | sed 's/\..*//'`;vobsize=`find <title>1.vob -printf '%s\n'`; bitrate=$(($vobsize*8/$length/4/5)); echo "audio bitrate = $(($bitrate/1000)) kb/s";echo "video bitrate = $(($bitrate*4/1000)) kb/s"
 
</pre>
 
</pre>
  
Line 33: Line 33:
 
Convert the video stream to ogv
 
Convert the video stream to ogv
 
<pre>
 
<pre>
avconv -i <title>.vob -f ogg -codec:v libtheora -b:v 1250k -an -sn <title>.video
+
avconv -i <title>1.vob -pass1 -f ogg -codec:v libtheora -b:v 1250k -an -sn <title>.video
 +
avconv -i <title>1.vob -pass2 -f ogg -codec:v libtheora -b:v 1250k -an -sn <title>.video
 
</pre>
 
</pre>
  
Line 39: Line 40:
 
Now extract audio from the stream and convert to OGG
 
Now extract audio from the stream and convert to OGG
 
<pre>
 
<pre>
avconv -i <title>.vob -f ogg -c:a libvorbis -b:a 250k -vn -sn <title>.audio
+
avconv -i <title>1.vob -f ogg -c:a libvorbis -b:a 250k -vn -sn <title>.audio
 
</pre>
 
</pre>
  
Line 45: Line 46:
 
Extract the subtitles from the stream.
 
Extract the subtitles from the stream.
 
<pre>
 
<pre>
mencoder <title>.vob -oac copy -nosound -ovc frameno -o /dev/null -sid <sid> -vobsubout <title> -vobsuboutindex <index> -vobsuboutid <langcode>
+
mencoder <title>1.vob -oac copy -nosound -ovc frameno -o /dev/null -sid <sid> -vobsubout <title> -vobsuboutindex <index> -vobsuboutid <langcode>
 
</pre>
 
</pre>
  

Revision as of 13:43, 23 March 2012

This describes how to convert a DVD to mkv using:

  • x264 for video
  • ac3 for audio
  • any subtitles

Installation

Install the packages

apt-get install mencoder mplayer gpac mkvtoolnix lsdvd

For using encrypted DVDs build and install libdvdcss from http://download.videolan.org/pub/libdvdcss/last

./configure --prefix=/usr
make
make install

Prepare

Use lsdvd to see what's on DVD. Determine the stream you would like to extract as well as the aid for audio and the sid for subtitles.

lsdvd -x

Write the stream to the harddrive so the next steps will go faster.

vobcopy -l -n 1 -t <title>

As I find it acceptable to have my DVDs compressed to 25% of its size I use the follow calculations to get the bitrate for video and audio.

length=`lsdvd -t <stream> -Ox 2>/dev/null | grep length | sed 's/^[^>]*>//' | sed 's/\..*//'`;vobsize=`find <title>1.vob -printf '%s\n'`; bitrate=$(($vobsize*8/$length/4/5)); echo "audio bitrate = $(($bitrate/1000)) kb/s";echo "video bitrate = $(($bitrate*4/1000)) kb/s"

Video

Detect the amount to crop. Keep it running till it is stable for a while Convert the video stream to ogv

avconv -i <title>1.vob -pass1 -f ogg -codec:v libtheora -b:v 1250k -an -sn <title>.video
avconv -i <title>1.vob -pass2 -f ogg -codec:v libtheora -b:v 1250k -an -sn <title>.video

Audio

Now extract audio from the stream and convert to OGG

avconv -i <title>1.vob -f ogg -c:a libvorbis -b:a 250k -vn -sn <title>.audio

Subtitles

Extract the subtitles from the stream.

mencoder <title>1.vob -oac copy -nosound -ovc frameno -o /dev/null -sid <sid> -vobsubout <title> -vobsuboutindex <index> -vobsuboutid <langcode>

Merging

Combine everything in a ogg container

oggz-merge -o <title>.ogv <title>.video <title>.audio