Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using plex. Plex seems to ignore the default audio stream (on Roku) and instead just use the first audio stream. This is per my testing using mkvpropedit.

Since Plex does not currently support the changing of audio sources on clients outside of the LAN, I'd like to change a few of my files so the current second audio source is the first?

What's the best way to swap audio streams in an MKV on a Linux based system such as Ubuntu?

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

With FFmpeg, this should be rather simple. Make sure you download a static build from their download page and don't use the Ubuntu repository version, which is quite old.

Here's the command:

ffmpeg -i input.mkv -map 0:0 -map 0:2 -map 0:1 -c copy output.mkv

Here's what -map does:

  • The first part before the colon is the input ID. Since we only have one input, it's 0.
  • The second part is the ID of the input stream. 0 will probably be the video track, and 1 and 2 will be your audio tracks.
  • The order of the -map options determines the order of the streams in the output file.

This means we'll leave the video bitstream as the first stream, then take the second audio stream, and then the first—in essence, we're swapping the audio streams.

Using the -c copy option ensures that the bitstreams are copied and not re-encoded.

A few examples on how to use the -map option can be found on the FFmpeg wiki.

share|improve this answer
    
tested and worked. thanks! –  user191723 Jan 22 '13 at 0:48
add comment

Just use mkvtool to avoid, repack, re-encode ... wasting time.

mkvpropedit -v movie.mkv -v --edit track:2 --set track-number=3 --edit track:3 --set track-number=2

this should be enough to swap stream.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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