How to concat VOB files with ffmpeg using stream mapping?

6,873

You can use the cat command from the shell to concatenate the .vob files into one.

Here is an example:

To concatenate file1.vob, file2.vob and file3.vob from within the same directory into Allfiles.vob you can use the following command:

cat file*.vob > Allfiles.vob
Share:
6,873

Related videos on Youtube

Konstantin
Author by

Konstantin

Updated on September 18, 2022

Comments

  • Konstantin
    Konstantin almost 2 years

    I have 5 VOB files, I would like to concat them to a big mpegts file, and keeping only the video stream and the last (3rd) audio stream. Unfortunately the stream ordering is different in the VOBs:

        Input #0, mpeg, from 'VTS_01_1.VOB':
          Duration: 00:25:03.00, start: 0.280633, bitrate: 5715 kb/s
            Stream #0:0[0x1bf]: Data: dvd_nav_packet
            Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 7500 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
            Stream #0:2[0x20]: Subtitle: dvd_subtitle
            Stream #0:3[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
            Stream #0:4[0x81]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
            Stream #0:5[0x82]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
        [mpeg2video @ 0x82d3600] Invalid frame dimensions 0x0.
            Last message repeated 5 times
    
    Input #1, mpeg, from 'VTS_01_2.VOB':
          Duration: 00:24:51.03, start: 1503.128633, bitrate: 5761 kb/s
            Stream #1:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 7500 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
            Stream #1:1[0x21]: Subtitle: dvd_subtitle
            Stream #1:2[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
            Stream #1:3[0x81]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
            Stream #1:4[0x82]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
            Stream #1:5[0x1bf]: Data: dvd_nav_packet
            Stream #1:6[0x20]: Subtitle: dvd_subtitle
        [mpeg2video @ 0x86aff00] Invalid frame dimensions 0x0.
            Last message repeated 8 times
    
    Input #2, mpeg, from 'VTS_01_3.VOB':
          Duration: 00:24:17.94, start: 2993.976633, bitrate: 5891 kb/s
            Stream #2:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 7500 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
            Stream #2:1[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
            Stream #2:2[0x81]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
            Stream #2:3[0x82]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
            Stream #2:4[0x1bf]: Data: dvd_nav_packet
            Stream #2:5[0x20]: Subtitle: dvd_subtitle
            Stream #2:6[0x21]: Subtitle: dvd_subtitle
        [mpeg2video @ 0x868fc20] Invalid frame dimensions 0x0.
            Last message repeated 8 times
    
    Input #3, mpeg, from 'VTS_01_4.VOB':
          Duration: 00:24:38.52, start: 4451.800633, bitrate: 5809 kb/s
            Stream #3:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 7500 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
            Stream #3:1[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
            Stream #3:2[0x81]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
            Stream #3:3[0x82]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
            Stream #3:4[0x1bf]: Data: dvd_nav_packet
        [mpeg2video @ 0x83a4aa0] Invalid frame dimensions 0x0.
            Last message repeated 9 times
    
    Input #4, mpeg, from 'VTS_01_5.VOB':
          Duration: 00:02:45.18, start: 5930.104633, bitrate: 5897 kb/s
            Stream #4:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 7500 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
            Stream #4:1[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
            Stream #4:2[0x81]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
            Stream #4:3[0x82]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
            Stream #4:4[0x1bf]: Data: dvd_nav_packet
    

    So I tried this command:

    ffmpeg -y f concat -i list.txt -map 0:v -map 0:a:2 -map 1:v -map 1:a:2 -map 2:v -map 2:a:2 -map 3:v -map 3:a:2 -map 4:v -map 4:a:2 -c copy -f mpegts joined.mpeg
    

    Where list.txt contains

    file VTS_01_1.VOB
    file VTS_01_2.VOB
    file VTS_01_3.VOB
    file VTS_01_4.VOB
    file VTS_01_5.VOB
    

    Unfortunately doesn't work, complete output:

    ffmpeg -y -f concat -i list.txt -map 0:v -map 0:a:2 -map 1:v -map 1:a:2 -map 2:v -map 2:a:2 -map 3:v -map 3:a:2 -map 4:v -map 4:a:2 -c copy -f mpegts joined.mpeg
    ffmpeg version 2.3.1 Copyright (c) 2000-2014 the FFmpeg developers
      built on Jul 31 2014 14:53:16 with gcc 4.9.1 (GCC)
      configuration: --prefix=/usr --disable-debug --disable-static --enable-avisynth --enable-avresample --enable-decoder=atrac3 --enable-decoder=atrac3p --enable-dxva2 --enable-fontconfig --enable-gnutls --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-pic --enable-postproc --enable-runtime-cpudetect --enable-shared --enable-swresample --enable-vdpau --enable-version3 --enable-x11grab
      libavutil      52. 92.100 / 52. 92.100
      libavcodec     55. 69.100 / 55. 69.100
      libavformat    55. 48.100 / 55. 48.100
      libavdevice    55. 13.102 / 55. 13.102
      libavfilter     4. 11.100 /  4. 11.100
      libavresample   1.  3.  0 /  1.  3.  0
      libswscale      2.  6.100 /  2.  6.100
      libswresample   0. 19.100 /  0. 19.100
      libpostproc    52.  3.100 / 52.  3.100
    [concat @ 0x893b1c0] Estimating duration from bitrate, this may be inaccurate
    Input #0, concat, from 'list.txt':
      Duration: 00:00:00.00, start: 0.000000, bitrate: 573 kb/s
        Stream #0:0: Data: dvd_nav_packet
        Stream #0:1: Video: mpeg2video (Main), yuv420p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 7500 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
        Stream #0:2: Subtitle: dvd_subtitle
        Stream #0:3: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
        Stream #0:4: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
        Stream #0:5: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
    Invalid input file index: 1.
    

    How can I achieve the concatenation with stream mapping applied?

    • Elisa Cha Cha
      Elisa Cha Cha almost 10 years
      Can you be more specific than "doesn't work"? What does the ffmpeg console output show?
    • Konstantin
      Konstantin almost 10 years
      The error message: Invalid input file index: 1
    • Elisa Cha Cha
      Elisa Cha Cha almost 10 years
      Please provide the complete ffmpeg console output.
    • Konstantin
      Konstantin almost 10 years
      Okay, I added it.
    • Sun
      Sun over 9 years
      Is there a way for you to break down the steps? First step is to copy only the stream you want to another VOB? Then convert those single VOBs to your eventual output format?
  • Thomas G Henry
    Thomas G Henry over 6 years
    Ha! Great. Dead simple.