Joining Two MKV files in Ubuntu?

36,377

Solution 1

If the resolution of the videos are same, then you can use avidemux to join them

Solution 2

Recommended way is to use mkvtoolnix

sudo apt-get install mkvtoolnix mkvtoolnix-gui
  • Start mmg (graphical user interface for mkvmerge)
  • "Add" the first file
  • "Append" the second one, third, fourth, ...
  • Set output name in the textbox at the bottom
  • "Start muxing"

Subtitles are preserved and properly concatenated, so are audio and video. Chapters can be edited in the resulting file with mmg.

This procedure creates a properly muxed file. Any problems should be mentioned in the "log"-window in mmg. You can even set and name audio and subtitle tracks with the correct language codes and Annotations like "Forced" or "Directors Commentary".

If you plan to do this repeatedly on different files you better use the command line version mkvmerge ("mkvmerge --help")

mkvmerge -o output.mkv input1.mkv +input2.mkv

Solution 3

Use this command in terminal, to merge two separate '.mkv-files' into one.

mkvmerge -o newfile.mkv part1.mkv +part2.mkv

Solution 4

You can use dmMediaConverter to do this. It is very simple and works well. There is a mode of the program for joining MKV files and uses ffmpeg under the hood. See this answer for more.

Solution 5

The easiest way to combine video is to use a container format that supports concatenation and re-indexing, like mpg. Then you can just cat file1 file2 > file3 and re-index with ffmpeg.

The steps in your case would be:
Convert from mkv to mpg
Concatenate
Re-index
Change back to mkv if you like

If it's just audio, you could use a more easily editable file type...like wav, mp3, or ogg until you've got your final output. Then you can use loads of tools to join audio. Sox or FFmpeg come to mind.

Share:
36,377

Related videos on Youtube

Thibault
Author by

Thibault

I'm a music education major at Shepherd University. I couldn't stand the limitations that OSX/Windows gave me, so I made the switch to Linux. Started out with Ubuntu 11.04, survived up until 12.04, and after my system crash as I upgraded to 12.10, I decided to switch to Arch Linux as my default distro. IRC: ryanmcclure

Updated on September 18, 2022

Comments

  • Thibault
    Thibault almost 2 years

    I have an opera that I'm ripping to my computer in MKV format with Handbrake. This opera is on two discs. Is there a way to join the resulting MKV's together? They will have the same bitrate, resolution, etc. If I do this, can I keep chapters from both MKV files organized? And, since I have subtitles in the file (not burnt in), will they still stay intact?

    I'm not too sure if this question is off-topic or not. If it is, feel more than free to delete it. :)

  • Thibault
    Thibault over 12 years
    I'm in the process of ripping disc 2 now...whenever I finish, I'll give this a try...let's hope it works! :)
  • Thibault
    Thibault over 12 years
    This method was easier than aking1012's, so that's the only reason that I accepted this answer.
  • user93692
    user93692 over 7 years
    Nice that only ffmpeg is required for this solution!
  • Jaime M.
    Jaime M. over 6 years
    I don't find the append button in mkvtoolnix-gui currently. The command line version seems to be the simpler and faster way to concat mkv files. Note the + character to append video files instead of merge.
  • John Manko
    John Manko about 6 years
    This worked perfect for me.
  • Joe
    Joe about 6 years
    I just used mkvmerge (without the plus sign) with no issues to combine an mkv video file and an mp3 audio file that had to be downloaded separately from a website. It rocks!
  • Auspex
    Auspex about 4 years
    The higher rated answer actually tells you how to get mkvmerge...