How to convert a VOB file to avi?

23,791

Solution 1

To get rid of the subtitles I believe you can add the -nosub switch, right after the .VOB file's name.

Example

$ mencoder Videos/Test/VIDEO_TS/VTS_01_1.VOB -nosub -nosound -ovc x264 \
-x264encopts direct=auto:pass=2:bitrate=900:frameref=5:bframes=1:\
me=umh:partitions=all:trellis=1:qp_step=4:qcomp=0.7:direct_pred=auto:keyint=300 \
-vf scale=-1:-10,harddup -o video.avi

Details

These incantations are often very dense so to break this one down a bit

  • input file: Videos/Test/VIDEO_TS/VTS_01_1.VOB
  • output file: -o video.avi
  • no subtitles: -nosub
  • don't encode sound: -nosound
  • encode with given codec: -ovc x264

list of other codecs

$ mencoder -ovc help
MEncoder SVN-r36171-4.8.1 (C) 2000-2013 MPlayer Team

Available codecs:
   copy     - frame copy, without re-encoding. Doesn't work with filters.
   frameno  - special audio-only file for 3-pass encoding, see DOCS.
   raw      - uncompressed video. Use fourcc option to set format explicitly.
   nuv      - nuppel video
   lavc     - libavcodec codecs - best quality!
   libdv    - DV encoding with libdv v0.9.5
   xvid     - XviD encoding
   x264     - H.264 encoding
  • x264 encode options: x264encopts
  • set mode for direct motion vectors: direct=auto
  • number of passes: pass=2
  • target encoding bitrate: bitrate=900
  • pre. frames used as predictors in B- and P-frames (def: 3): frameref=5
  • concurrent # of B-frames: bframes=1
  • fullpixel motion estimation alg.: me=umh

    NOTE: umh - uneven multi-hexagon search (slow)

  • enable all macroblock types: partitions=all

  • rate-distortion optimal quantization: trellis=1

    NOTE: 2 - enabled during all mode decisions (slow, requires subq>=6)

  • quantizer increment/decerement value: qp_step=4

    NOTE: maximum value by which the quantizer may be incremented/decremented between frames (default: 4)

  • quantizer compression (default: 0.6): qcomp=0.7

  • motion prediction for macroblocks in B-frames: direct_pred=auto
  • maximum interval between keyframes in frames: keyint=300

  • options after this are video filters: -vf

NOTE: For the video filter switches, it's important that you use harddup as the last filter: it will force MEncoder to write every frame (even duplicate ones) in the output. Also, it is necessary to use scale=$WIDTH,-10 with $WIDTH as -1 to keep the original width or a new, usually smaller, width: it is necessary since the H.264 codec uses square pixels and DVDs instead use rectangular pixels.

  • scale=-1
  • -10
  • harddup

Solution 2

If you intend to use mplayer, then you should try mencoder (http://www.mplayerhq.hu). One of its best features is that the playback options you know from mplayer behave pretty much the same way when encoding. Also, there's a lot of documentation and email threads covering exactly what you're asking:

Share:
23,791

Related videos on Youtube

user3185306
Author by

user3185306

Updated on September 18, 2022

Comments

  • user3185306
    user3185306 over 1 year

    I am trying to convert a VOB file copied from a DVD into an avi in Ubuntu 13.10. I tried dvdrip, which failed due to a frame count error or something. I tried acidrip as well, but it always choose an audio track I did not want to use. I would prefer to have a command line solution to create an avi with the following features:

    • usable with mplayer (i.e. using the step functions)
    • with the subtitle as required (or no one at all)
    • with the correct audio track
    • with video and audio in sync

    I tried some ffmpeg and avconv commands and managed to create an avi, but the video and audio were completly out of sync. So what options should I use to have the VOB file converted to an avi file?

    I would appreciate some explanations on the suggested options!

    Additional information:

    1. The ffmpeg command gives the following output for the input file

      Input #0, mpeg, from 'Videos/Test/VIDEO_TS/VTS_01_1.VOB':
        Duration: 00:04:53.32, start: 0.045500, bitrate: 29284 kb/s
          Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [PAR 8:9 DAR 4:3], 7500 kb/s, 27.68 fps, 59.94 tbr, 90k tbn, 59.94 tbc
          Stream #0.1[0x82]: Audio: ac3, 48000 Hz, 5.1, s16, 384 kb/s
          Stream #0.2[0x80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
          Stream #0.3[0x81]: Audio: ac3, 0 channels
      [buffer @ 0x15ca6e0] w:720 h:480 pixfmt:yuv420p
      
    2. The following command

      ffmpeg -i Videos/Test/VIDEO_TS/VTS_01_1.VOB -ss 589 -t 274 -sameq -acodec copy -ab 320k output.avi
      

      for example resulted in a crash of my Ubuntu session.

    3. The following command

      avconv -i Videos/Test/VIDEO_TS/VTS_01_1.VOB -acodec copy -vcodec copy output.avi
      

      for example resulted in the following error:

      Application provided invalid, non monotonically increasing dts to muxer in stream 1: 374 >= 374
      av_interleaved_write_frame(): Invalid argument
      
    4. The following command

      avconv -i Videos/Test/VIDEO_TS/VTS_01_1.VOB -f avi -c:v mpeg4 -b:v 800k -g 300 -bf 2 -c:a libmp3lame -b:a 128k output.avi
      

      for example resulted in the following error:

      Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height
      
    5. The following command

      avconv -i Videos/Test/VIDEO_TS/VTS_01_1.VOB -f avi -c:v mpeg4 -b:v 800k -g 300 -bf 2 -c:a ac3 -b:a 128k output.avi
      

      for example seemed to work for some frames. But very soon I encountered many errors of the form

      [ac3 @ 0x120d480] frame sync error
      Error while decoding stream #0:1
      frame CRC mismatch
      
    6. The following command

      mencoder Videos/Test/VIDEO_TS/VTS_01_1.VOB -oac copy -ovc x264 -x264encopts bitrate=2500 -o output.avi
      

      did some converting, but is (i) using subtitles although I did not want to use them (ii) got the audio wrong (audio and video is terribly misplaced) and (iii) seems to be slower than the movie actually goes (might take 2 hours for a 90 minute movie).

    7. I tried to command given here (third post from Xeratul), but it stopped with the error

      FATAL: Cannot initialize video driver.
      
    8. I tried the suggestion made below to look at the mencoder page. This page suggests to use two passes:

      the first reads informations about the movie, the second uses that information to encode.

      but neither it is explained which information to extract nor how to use them in the second pass. So I used the following command:

      mencoder Videos/Test/VIDEO_TS/VTS_01_1.VOB -nosound -ovc x264 \
      -x264encopts direct=auto:pass=2:bitrate=900:frameref=5:bframes=1:\
      me=umh:partitions=all:trellis=1:qp_step=4:qcomp=0.7:direct_pred=auto:keyint=300 \
      -vf scale=-1:-10,harddup -o video.avi
      

      which did convert the video, but with an unwanted subtitle. It is not clear at all how I can avoid using a subtitle.

    • Admin
      Admin over 10 years
      ffmpeg is deprecated since long time ago, you are supposed to use its own successor: avconv.
    • Admin
      Admin over 10 years
      So how to use avconv then to convert VOB files to avi. The command avconv -i Videos/Test/VIDEO_TS/VTS_01_1.VOB -acodec copy -vcodec copy test.avi gave an error Application provided invalid, non monotonically increasing dts to muxer in stream 1: 374 >= 374 av_interleaved_write_frame(): Invalid argument...
    • Admin
      Admin over 10 years
      there is an example in the manpage for avconv, for decrypted VOB files avconv -i snatch_1.vob -f avi -c:v mpeg4 -b:v 800k -g 300 -bf 2 -c:a libmp3lame -b:a 128k snatch.avi try this
    • Admin
      Admin over 10 years
      This gives an error Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height
    • Admin
      Admin over 10 years
      Try mencoder yourvob -oac copy -ovc x264 -x264encopts pass=1:preset=veryslow:fast_pskip=0:tune=film:frameref=15:bi‌​trate=3000:threads=a‌​uto -nosub -o /dev/null then mencoder yourvob -oac copy -ovc x264 -x264encopts pass=2:preset=veryslow:fast_pskip=0:tune=film:frameref=15:bi‌​trate=3000:threads=a‌​uto -nosub -o video.avi - took that in part from the Arch doc @dg99 linked.
    • Admin
      Admin over 10 years
      Please see my trial #7: FATAL: Cannot initialize video driver.
  • user3185306
    user3185306 over 10 years
    The provided links contain dozen of different examples and hundreds of options. It is not a clear and precise answer to my question.
  • dg99
    dg99 over 10 years
    True, but I didn't write the answer to get reputation, I wrote it to help you. Do consider reading through some of the mencoder pages. There are several pirate groups that use only mencoder for all their work; that's how simple and powerful and automatable it can be.
  • user3185306
    user3185306 over 10 years
    Thank you very much for this well-explained example on how to get the video. Your suggested command seems to work perfectly for extracting the video. However, I do not have the audio now. If I use your command without -noaudio and with -oac copy I get the audio, which is not in sync with the video. It is either displaced, at a different speed or both. Any suggestion how I can get also the audio correct? And what about multiple VOB files? How to pack the content into a single .avi file (or other format)?
  • slm
    slm over 10 years
    @Alex - just a thought, but I do not think you can simply do a -oac copy with a 2 pass, since you're re-encoding the video, you'll have to re-encode the audio along with it. As to "packing" them, the vob files should be merged liked this: cat *.vob all.vob. Then use all.vob in the mencoder cmd. There are other ways to do this too.
  • Admin
    Admin about 3 years
    Performing this on the output of vobcopy results in an AVI file with the wrong language and missing subtitles.