Converting DVD VOB Files to Smaller VOB and MKV with ffmpeg

Loading

cat *.VOB > output.vob

Now let's inspect the newly created file: we want to find what kind of stuff it contains. Use FFmpeg for that, as follows:

ffmpeg -i output.vob

For example, you might end up with something like:

Input #0, mpeg, from 'output.vob':
  Duration: 01:50:40.99, start: 0.287267, bitrate: 7581 kb/s
    Stream #0:0[0x1bf]: Data: dvd_nav_packet
    Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, top first), 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:2[0x80]: Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s
    Stream #0:3[0x89]: Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 768 kb/s
    Stream #0:4[0x82]: Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s

Mind the deep-buried streams!

Normally, while looking for streams, FFmpeg parses only few seconds of the input data as most formats have a global header there that describes everything present in the file. Unfortunately VOBs have no headers and it is likely to find movies that hold additional streams further down the VOB file.

Let FFmpeg scan it thoroughly by adding two more flags: -analyzeduration (in microseconds) and -probesize (in bytes). Honestly I'm not able to tell the difference between those options: put in there some fairly large numbers and tweak them until you are satisfied. For example:

ffmpeg -analyzeduration 100M -probesize 100M -i output.vob

And, not surprisingly, two more streams are found:

...
    Stream #0:5[0x21]: Subtitle: dvd_subtitle
    Stream #0:6[0x20]: Subtitle: dvd_subtitle

We are ready to pack our DVD into an .mkv/vob file. The command looks like:

ffmpeg \
  -analyzeduration 100M -probesize 100M \
  -i output.vob \
  -map 0:1 -map 0:3 -map 0:4 -map 0:5 -map 0:6 
  -codec:v libx264 -crf 21 \
  -codec:a libmp3lame -qscale:a 2 \
  -codec:s copy \
  -threads N
  output.mkv

Threads N is No. of CPU cores if CPU supports it.

ffmpeg -analyzeduration 100M -probesize 100M -i Aristocrats.vob -codec:v libx264 -crf 21 -codec:a libmp3lame -qscale:a 2 -codec:s copy -threads 2  AristocratsLive.vob