Merge video files with a simple DOS command

The DOS copy command can be used to join a surprising number of video file formats together. And it’s quick.

One problem with digital set-top boxes (STBs) that can record digital TV to external storage is that they invariably only support the FAT32 file system. That means the maximum file size you can get, even in theory, is only 4GB. If you’re capturing 1080i video, it doesn’t take long to go through 4GB of storage — about half an hour. So what these boxes do is split the files into sub-2GB chunks. While the STBs are designed to play them back easily enough, converting them to another format is a bit of a pain when you have all of these chunks to work with. One unlikely solution is the good old DOS command line which, for the uninitiated, is still available in Windows (just run cmd.exe).

All digital TV in Australia is broadcast using the MPEG-2 video codec and the MPEG-Transport Stream (MPEG-TS) file container. At some point in the future, MPEG-2 may give way to MPEG-4, but it’s unlikely to be any time soon. This means that no matter what tricky file extension the STB uses, the file container is still only MPEG-TS. And because all MPEG-TS files are self-contained, which means they include the header information in each file, you can join them together with a single DOS command like this:

copy /b video1.trp+video1.001+video1.002 videofinal.mts.

The command is a modification of the old DOS copy. The /b switch tells it to copy as binary files rather than text, join the three files linked by a (+) symbol and save the three into a single file called videofinal.mts.

If the video files all have the same name and different numerical extensions (such as 000, 001, 002 and so on), you can use this shorter version:

copy /b video1.* videofinal.mts.

The copy command is smart enough to copy files in numeric order in this instance.

Other file containers

We’ve looked at this trick before; however, what we didn’t mention was that it can actually be used on a number of file containers. Like MPEG-TS, VOB and MPG file containers are also self-contained, which means you can join files together using this process. They shouldn’t just be random files, though. You should really only do this with files that were captured using the same device and capturing the same program.

As for audio files, while you can merge .mp3 files using this method, the ID3 tag information will only include that of the first file, not any subsequent files. However, the resulting merged file will play fully in most media players.

Just remember that this method is a straight copy. You can’t cheat and make the output file a different file type — it won’t work. For joining video chunks together, though, you’re not going to get a faster or simpler option than this.

And before you ask, no, it doesn’t work with .avi, .flv or .mkv files, despite what you might read on the web about the latter two. While the videos do indeed join, most video players can only see the first video, not the second. VLC and Media Player Classic had this trouble.

Merging other file formats

If you have video segments of other file types you want to merge together, convert each segment into an .mts file using MPEG-2 or H.264 compression and then the copy /b command to join them together. Once you’ve got them in a single file, convert it into whatever format you want.

You’ll need to set the bit rate as high as you can during the intermediate MTS step so as not to lose video quality, although you could also try a dedicated video or audio merge tool such as MP4Box or MKVtoolnix (both of these can be found at www.videohelp.com).

The only thing that may cause some issues down the track using this one-line method is the fact that unless the files all came from the one recording, the timestamp on the final merged file will probably be wrong. Instead of the timestamp equalling the runtime of all the segments, it may only equal that of the first segment.

Having the wrong timestamp will be a minor problem with our Video Toolkit 2 software, but if you know the exact runtime, you can edit the runtime entry manually to fix that.

Joinable file formats

Here’s a quick list of file types you can join together with the good, old copy /b command:

  • M2TS (Blu-ray)
  • MP3 (audio)
  • MPG (PC video)
  • MTS (Blu-ray, digital TV)
  • TP (digital TV)
  • TS (digital TV)
  • VOB (DVD)

Reports of this working on FLV, MKV and AVI format files are exaggerated.

Email Facebook Reddit AddThis