Skip to content

Instantly share code, notes, and snippets.

@benschw
Created March 25, 2014 13:49
Show Gist options
  • Save benschw/9762196 to your computer and use it in GitHub Desktop.
Save benschw/9762196 to your computer and use it in GitHub Desktop.
how to rip a dvd
==Get Utilities==
sudo apt-get install mplayer mencoder mpeg4ip-utils mpeg4ip-server subtitleripper ogmtools mkvtoolnix
==Prepare==
===Detect Cropping===
mplayer dvd://1 -frames 4 -vf cropdetect -sb 50000000 -nosound -vo null 2>/dev/null | grep CROP
[CROP] Crop area: X: 8..719 Y: 0..479 (-vf crop=704:480:12:0).
[CROP] Crop area: X: 7..719 Y: 0..479 (-vf crop=704:480:12:0).
*Skip first ~50mb, this is the title screen and is often a different size
===Choose a Bitrate===
2000
===Find Framerate===
$ mplayer -v dvd://1 -frames 4 -nosound -vo null 2>/dev/null | grep fps
VIDEO: MPEG2 720x480 (aspect 3) 29.970 fps 8000.0 kbps (1000.0 kbyte/s)
[V] filefmt:2 fourcc:0x10000002 size:720x480 fps:29.97 ftime:=0.0334
===Find Audio Track===
$ mplayer dvd://1 -frames 4 -nosound -vo null 2>/dev/null | grep "audio stream"
audio stream: 0 format: ac3 (stereo) language: ja aid: 128.
audio stream: 1 format: dts (5.1/6.1) language: ja aid: 137.
$ mplayer -aid 128 dvd://1 # double check
===Find Subtitles===
$ mplayer -v dvd://1 -frames 4 -nosound -vo null 2>/dev/null | grep subtitle
subtitle ( sid ): 0 language: da
subtitle ( sid ): 1 language: en
number of subtitles on disk: 2
==> Found subtitle: 0
==> Found subtitle: 1
==> Found subtitle: 2
$ mplayer -sid 1 dvd://1 # double check
==Extract==
===Video===
$ mplayer dvd://1 -dumpstream -dumpfile movie.vob
or
$ vobcopy -m
$ mkisofs -r -o movie.iso /NEW_FOLDER/
===Audio===
$ mplayer movie.vob -aid 128 -dumpaudio -dumpfile audio.ac3
===Chapters===
dvdxchap -t 1 /dev/dvd > chapters.txt
===Subtitles===
cp /mnt/dvd/video_ts/vts_01_0.ifo ./
==Encode==
===Video===
{|
| Description
| Encoding options
| speed (in fps)
| Relative PSNR loss (in dB)
|-
| Very high quality
| subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b
| 6fps
| 0dB
|-
| High quality
| subq=5:8x8dct:frameref=2:bframes=3:b_pyramid:weight_b
| 13fps
| -0.89dB
|-
| Fast
| subq=4:bframes=2:b_pyramid:weight_b
| 17fps
| -1.48dB
|}
*high
mencoder movie.vob \
-vf pullup,softskip,crop=704:480:12:0,harddup -nosound \
-ovc x264 -x264encopts \
bitrate=1500:subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b:threads=auto:pass=1 \
-of rawvideo -o /dev/null
mencoder movie.vob \
-vf pullup,softskip,crop=704:480:12:0,harddup -nosound \
-ovc x264 -x264encopts \
bitrate=1500:subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b:threads=auto:pass=1 \
-of rawvideo -o movie.high.264
*medium
mencoder movie.vob \
-vf pullup,softskip,crop=704:480:12:0,harddup -nosound \
-ovc x264 -x264encopts \
bitrate=1500:subq=5:8x8dct:frameref=2:bframes=3:b_pyramid:weight_b:threads=auto:pass=1 \
-of rawvideo -o /dev/null
mencoder movie.vob \
-vf pullup,softskip,crop=704:480:12:0,harddup -nosound \
-ovc x264 -x264encopts \
bitrate=1500:subq=5:8x8dct:frameref=2:bframes=3:b_pyramid:weight_b:threads=auto:pass=2 \
-of rawvideo -o movie.med.264
*low
mencoder movie.vob \
-vf pullup,softskip,crop=704:480:12:0,harddup -nosound \
-ovc x264 -x264encopts \
bitrate=1500:subq=4:bframes=2:b_pyramid:weight_b:threads=auto:pass=1 \
-of rawvideo -o /dev/null
mencoder movie.vob \
-vf pullup,softskip,crop=704:480:12:0,harddup -nosound \
-ovc x264 -x264encopts \
bitrate=1500:subq=4:bframes=2:b_pyramid:weight_b:threads=auto:pass=2 \
-of rawvideo -o movie.low.264
*other
mencoder movie.vob \
-vf pullup,softskip,crop=720:560:0:6,harddup -nosound \
-ovc x264 -x264encopts \
bitrate=2000:subq=5:bframes=3:b_pyramid:weight_b:turbo=1:threads=auto:pass=1 \
-of rawvideo -o /dev/null
mencoder movie.vob \
-vf pullup,softskip,crop=720:560:0:6,harddup -nosound \
-ovc x264 -x264encopts \
bitrate=2000:subq=5:8x8dct:frameref=2:bframes=3:b_pyramid:weight_b:threads=auto:pass=2 \
-of rawvideo -o movie.264
mencoder -nosound dvd:// -dvd-device file.iso
-vf crop=xxx:xxx:xx:xx,scale,harddup
-ovc x264 -x264encopts
bitrate=1000:frameref=6:analyse=all:me=umh:subme=7:trellis=2:bframes=1:subq=7:brdo:mixed_refs:weight_b:bime:no_fast_pskip:direct_pred=auto:mixed_refs:nr=200:threads=auto:turbo=2:pass=1
-noskip -of rawvideo -o /dev/null
mencoder -nosound dvd:// -dvd-device file.iso
-vf crop=xxx:xxx:xx:xx,scale,harddup
-ovc x264 -x264encopts
bitrate=1000:frameref=6:analyse=all:me=umh:subme=7:trellis=2:bframes=1:subq=7:brdo:mixed_refs:weight_b:bime:no_fast_pskip:direct_pred=auto:mixed_refs:nr=200:threads=auto:pass=2
-noskip -of rawvideo -o movie.264
===Subtitles===
tccat -i movie.vob -L | tcextract -x ps1 -t vob -a 0x21 > subs
subtitle2vobsub -o vobsubs -i vts_01_0.ifo -a 1 < ./subs
#double check
mkdir test
subtitle2pgm -o test/1 -c 255,0,0,255 < ./subs
*'''HEXSID''': For SIDs 0 to 9, this translates into HEXSID 0x20 to 0x29
==Wrap==
===Video in MP4===
mp4creator -c movie.264 -rate 29.97 movie.mp4
===All in MKV===
mkvmerge --title "Movie Title" -o movie.mkv --chapters chapters.txt movie.mp4 audio.ac3
==Links==
*[http://www.my-guides.net/en/content/view/77/26/ k9copy howto]
*[http://gentoo-wiki.com/HOWTO_DVD_to_Matroska HOWTO DVD to Matroska and H.264]
*[http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-x264.html x264 mencoder options]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment