So I have multiple videos of the same scenery from different angles. These are stored as separate files. Can I combine these as multiple video streams within one file?

For example I know this is possible with MKV, I just don't know how to "join" them.

Is this possible using ffmpeg? If so, which command sequence do I use? If not, what other application would be able to do this?


2 Answers 2


Yes, this is possible using ffmpeg and the mkv container.

An example command sequence would be:

ffmpeg -i input1 -i input2 -c copy -map 0 -map 1 output.mkv


Breaking down the command:

  • -i input1 This selects the first input file. Could be something like my video_track1.mov.
  • -i input2 Here you can specify the second input file. You can add another entry -i input3 if you have more input videos. I don't know what the maximum amount of videos is you can place in one mkv container.
  • -c copy This copies all the streams (audio and video) in their original encoding.
  • -map 0 This maps all the streams (audio and video) of the first input file to the first track of the output file.
  • -map 1 This maps all the streams (audio and video) of the second input file to the second track of the output file.

More information on the -map option can be found in the documentation of ffmpeg.

  • Thank you Bart. Just a quick follow-up question if I may. Suppose the 2nd video is a bit shorter than the 1st video I want to combine, is there any way I can offset at which point the second stream should be available (eg. 1 second later), to keep the two streams in sync?
    – Zuiq Pazu
    Oct 21, 2014 at 7:22
  • Not sure, I'm not an expert, just a happy Googler, but you could experiment with the -ss option. Please edit your question with the addition and add an answer yourself including the ffmpeg code if you find that it works. This will help future visitors. Oct 21, 2014 at 7:56
  • This almost worked, but my input video didnt have timestamps. I created them with ffmpeg -fflags +genpts -i input1_no_ts.avi -c copy input1.mp4 and ffmpeg -fflags +genpts -i input2_no_ts.avi -c copy input2.mp4
    – user27221
    Aug 16, 2022 at 13:43

'map' selects input sources, files in this case. Your command combines all the tracks into a single stream, not separate ones as desired.

  • 1
    The command in @SaaruLindestakke answer keeps them as separate streams. map does not combine streams; it can only select input streams (not files).
    – Gyan
    Mar 20, 2020 at 4:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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