Difference between revisions of "Extract DVD"

From Maze's wiki
Jump to: navigation, search
(OGG Video)
Line 31: Line 31:
 
==Video==
 
==Video==
 
Detect the amount to crop. Keep it running till it is stable for a while
 
Detect the amount to crop. Keep it running till it is stable for a while
<pre>
 
mplayer <title>.vob -vf cropdetect
 
</pre>
 
Use either OGG Video or x264
 
 
===OGG Video===
 
===OGG Video===
 
Convert the video stream to ogv
 
Convert the video stream to ogv
 
<pre>
 
<pre>
ffmpeg2theora --noaudio --nosubtitles --deinterlace -v 6 --optimize --speedlevel 0 --croptop <top> --cropbottom <bottom> --cropright <right> --cropleft <left> <title>.vob
+
avconv -i <title>.vob -f ogg -codec:v libtheora -b:v 1250k -an -sn <title>.video
</pre>
 
 
 
===x264===
 
Run the first pass on the video
 
<pre>
 
mencoder <title>.vob -vf crop=<cropvalues> -oac copy -ovc x264 -x264encopts pass=1:bitrate=<videobitrate> -nosub -of rawvideo -o <title>.264
 
</pre>
 
 
 
Run the second pass on the video
 
<pre>
 
mencoder <title>.vob -vf crop=<cropvalues> -oac copy -ovc x264 -x264encopts pass=2:bitrate=<videobitrate> -nosub -of rawvideo -o <title>.264
 
</pre>
 
 
 
Put the video in a MP4 container
 
<pre>
 
MP4Box -add <title>.264 <title>.mp4
 
 
</pre>
 
</pre>
  
 
==Audio==
 
==Audio==
 
===AC3===
 
===AC3===
Now extract audio from the stream. Just use AC3.
+
Now extract audio from the stream and convert to OGG
 
<pre>
 
<pre>
mplayer <title>.vob -aid <aid> -dumpaudio -dumpfile <title>.ac3
+
avconv -i <title>.vob -f ogg -c:a libvorbis -b:a 250k -vn -sn <title>.audio
</pre>
 
Optionally compress the AC3 stream
 
 
 
===OGG===
 
Convert the ac3 file to 6 channel wave
 
<pre>
 
mplayer <title>.ac3 -af resample=44100,channels=6:6:0:0:1:4:2:5:3:2:4:1:5:3 -channels 6 -ao pcm:nowaveheader:file=<title>.wav6
 
</pre>
 
 
 
Convert the 6 channel wave to a 6 channel ogg
 
<pre>
 
oggenc -r -B 16 -C 6 -R 44100 -b <audiobitrate> <title>.wav6
 
 
</pre>
 
</pre>
  
Line 81: Line 49:
 
mencoder <title>.vob -oac copy -nosound -ovc frameno -o /dev/null -sid <sid> -vobsubout <title> -vobsuboutindex <index> -vobsuboutid <langcode>
 
mencoder <title>.vob -oac copy -nosound -ovc frameno -o /dev/null -sid <sid> -vobsubout <title> -vobsuboutindex <index> -vobsuboutid <langcode>
 
</pre>
 
</pre>
 +
 
==Merging==
 
==Merging==
Combine everything in a mkv container
+
Combine everything in a ogg container
 
<pre>
 
<pre>
mkvmerge -o <title>.mkv <title>.ogg <title>.idx <title>.mp4
+
oggz-merge -o <title>.ogv <title>.video <title>.audio
 
</pre>
 
</pre>

Revision as of 13:35, 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 /dev/dvd

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

mplayer dvdnav://<stream> -dumpstream -dumpfile <title>.vob

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>.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

OGG Video

Convert the video stream to ogv

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

Audio

AC3

Now extract audio from the stream and convert to OGG

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

Subtitles

Extract the subtitles from the stream.

mencoder <title>.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