10

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.

  • ffmpeg is deprecated since long time ago, you are supposed to use its own successor: avconv. – user2485710 Dec 26 '13 at 9:11
  • 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... – Alex Dec 26 '13 at 9:39
  • 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 – user2485710 Dec 26 '13 at 9:43
  • This gives an error Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height – Alex Dec 26 '13 at 9:45
  • Try mencoder yourvob -oac copy -ovc x264 -x264encopts pass=1:preset=veryslow:fast_pskip=0:tune=film:frameref=15:bitrate=3000:threads=auto -nosub -o /dev/null then mencoder yourvob -oac copy -ovc x264 -x264encopts pass=2:preset=veryslow:fast_pskip=0:tune=film:frameref=15:bitrate=3000:threads=auto -nosub -o video.avi - took that in part from the Arch doc @dg99 linked. – user44370 Dec 29 '13 at 19:14
6
+50

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
  • 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)? – Alex Jan 2 '14 at 8:28
  • @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. – slm Jan 2 '14 at 8:33
3

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:

  • The provided links contain dozen of different examples and hundreds of options. It is not a clear and precise answer to my question. – Alex Dec 27 '13 at 8:38
  • 1
    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. – dg99 Dec 27 '13 at 16:11
1

I know this is old posting but searching this issue on the internet the above question pops up, and some other entries are even older.

I have tried different tools but in the end I am most satisfied with this command:

ffmpeg -i *.vob -c:v libx264 -crf 20 -c:a libmp3lame -ac 2 -ab 192k output.avi

It is a slight modification of the one that I found here.

I have just replaced audio codec (libflac was absent on my system, so I replaced it with libmp3lame (source) and the -crf value to increase quality. Other formats can also be used, like mp4.

In my test (with a rather mediocre processor) a 2.6 GB vob file (already concatenated out of three other files) was converted to a 960 MB avi video of comparable quality in about 50 minutes.

20 is the medium acceptable quality (in Handbrake help articles I have seen). Larger numbers reduce the size at expense of quality. Above 20 quality loss is clear.

It is better to use that command in a terminal in order to see the progress, kill it more easily, etc.

What I like about this command is that it provides a good balance between quality, time and size and that it can be easily used from the context menu of the file manager.

How to do that depends on the file manager. The command can be easily added to Thunar and Nautilus as a 'custom action'. I have added it to Dolphin with a ~/.kde/share/kde4/services/ServiceMenus/convert_vob_to_avi.desktop file like this:

[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin,video/mpeg
MimeType=video/mpeg
Actions=Convert2avi
X-KDE-Submenu=Convert vob (DVD video)
Encoding=UTF8

[Desktop Action Convert2avi]
Name=to avi
Icon=video
Exec=konsole -e ffmpeg -i *.vob -c:v libx264 -crf 20 -c:a libmp3lame -ac 2 -ab 192k output.avi

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.