Is it possible to merge two (or more) video files from the command line? In Windows, one could do this:

copy /b VTS_01_1.vob + VTS_01_2.vob + VTS_01_3.vob + VTS_01_4.vob Output.vob

I find this to be much easier and faster than using a dedicated GUI program. Is there an equivalent in Ubuntu?

up vote 4 down vote accepted
cat VTS_01_*.vob > output.vob

Improved version (this will show a progress bar):

cat VTS_O1_*.VOB | pv | dd of=output.vob

Similar to the 2nd:

 pv VTS_01_*.vob > output.vob

Oh and you could also mv the output.vob to .mpeg and have it play in VLC or another videoplayer.


Using ffmpeg:

ffmpeg -i "concat:VTS_01_1.VOB|VTS_01_2.VOB|VTS_01_3.VOB|VTS_01_4.VOB" -f mpeg -c copy output.mpeg

The methods using cat do NOT interpret the files and just add them together. 1 typical thing you will notice is a slight hickup when the player goes from 1 to the next VOB. Avidemux (GUI), for instance, will also demux(is that the correct word?) the files so it is a smoother experience.


If you receive the error message

ac3 in MPEG-1 system streams is not widely supported, consider using the vob or the dvd muxer to force a MPEG-2 program stream

then you will need to specify DVD as the output format by adjusting the above ffmpeg command with ... -f dvd ....

  • Interesting. I can see that the end result will be identical to what the OP claims works with Windows but would the result be playable? I'll admit I don't work much with VOB files preferring MKV format (via ffmpeg ) and tools like mkvmerge for merging – Elder Geek Jul 28 '16 at 20:50
  • cat works for merging the files. It does not care about chapters and the other stuff if it is a DVD ;) – Rinzwind Jul 28 '16 at 20:55
  • Curious why cat instead of dd if=? Is that something you could add to the description if you don't think it'd be too distracting? – earthmeLon Sep 14 at 20:51

If you are interested in using FFmpeg (which opens up the possibility of concatenating other media types less tractable than .vob) you can use the following for your example:

ffmpeg -i "concat:VTS_01_1.vob|VTS_01_2.vob|VTS_01_3.vob|VTS_01_4.vob" -c copy output.vob

I confess that FFmpeg is a 'dedicated' program which you would prefer not to use but note that other media types may require transcoding before concatenation and in these cases FFmpeg's services will be required...

References:

  • Thanks for the great answer. I use FFmpeg quite a bit ... I've edited the question to include the word 'GUI', which was what I was thinking of as an alternative. – Joel DeWitt Jul 29 '16 at 19:33

you can use the cat (concatenate) command for this.

In your case:

cat VTS_01_1.vob VTS_01_2.vob VTS_01_3.vob VTS_01_4.vob > Output.vob

VOB

VOB requires special care due their potentially complex structure and timestamp incongruities, so blindly concatenating these may have unexpected results. You should use DVD structure aware tools for this format.

The FFmpeg source code comes with a tool (tools/dvd2concat) that utilizes lsdvd to produce a proper concatenation script:

cd ffmpeg/tools
./dvd2concat path/to/dvd/structure > file.concat
ffmpeg -safe 0 -protocol_whitelist subfile,file,concat -f concat -i file.concat -map 0 -c copy -f dvd output.vob

Other file types

ffmpeg has three methods to concatenate:

  • concat demuxer - For general concatenation or for doing so without re-encoding.
  • concat protocol - Similar to just using cat. For formats that can be simply joined with no issues (MPEG-1, MPEG-2 PS, DV, rawvideo).
  • concat filter - Useful if you are performing any filtering (scaling, overlays, etc).

Also see FFmpeg Wiki: Concatenate and FFmpeg FAQ: How can I concatenate video files?

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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