Merge VOB files via command line?
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?
Solution 1:
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 ...
.
Solution 2:
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:
- FFmpeg trac: Concatenating media files
Solution 3:
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?
Solution 4:
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