ubuntuaudiomergemkvmatroska

How to merge two *.MKA files to one?


I have the next task - there are 3 files: *.mkv file without soundtrack, and two *.mka tracks. I need to merge all of them to the one file (and do it via ubuntu cli). I tried mkvmerge tool, it doing it great, but it generates video file with two audio tracks for choice (like different languages in the movies), but i need do have sound from both tracks in the same time (maybe as a left-right channel, doesn't matter). I tried to google about it - and found nothing. Thanks.


Solution

  • Use ffmpeg.

    1. Concatenate your videos, using ffmpeg's "concatenate" module:

      ffmpeg -i "concat:input1.mkv|input2.mkv|input3.mkv" -c copy video.mkv
      
    2. Mix your two audio files:

      ffmpeg -i input1.mka -i input2.mka -filter_complex emerge audio.mka
      
    3. Put the audio on the video:

      ffmpeg -i video.mkv -i audio.mka -codec copy output.mkv
      

    You can look at the documentation if your problem has some specifics which were not taken of in my answer, or browse StackOverflow and SuperUser.