M: I have an MKV file with three audio tracks. I actually have the command line using FFmpeg to swap two audio tracks, but evidently that's insufficient to bring the second track to be the primary track. When you've got three audio tracks. So please give me a command line to make the second audio track the first audio track in an MKV file without doing any conversion or anything, just remapping the streams.
G: Here’s the precise
ffmpeg command you want — it remaps streams
only, doing no re-encoding, and makes the second audio
track the first (primary) while preserving all other
streams:
ffmpeg -i input.mkv -map 0:v -map 0:a:1 -map 0:a:0 -map 0:a:2 -map 0:s? -c copy output.mkvExplanation:
-map 0:v → include all video streams in original
order-map 0:a:1 → select the second audio stream first (it
becomes primary)-map 0:a:0 → then the original first audio-map 0:a:2 → then the original third audio-map 0:s? → include subtitles if present
(? avoids error if none)-c copy → direct stream copy (no re-encoding)If you don’t care about subtitles, you can drop
-map 0:s?.
Result: same MKV, streams just reordered, no quality loss.
M: Okay, here's an anomaly. It certainly switched the first track and the second, but then it started up using the second audio track. Now, I'm using VLC, so it may have just automatically done that from when I was testing things out, and I'll try it again, but does this sound like something that could happen because of the file itself?
G: [Non-text content: thoughts; content_type=thoughts]
G: [Non-text content: reasoning_recap; content_type=reasoning_recap]
G: TL;DR: Yes—players don’t pick “track 1” just because it’s first. They usually honor MKV flags (default/forced) and language prefs, and VLC can also remember your last manual choice. Fix by setting the right disposition flags, not just reordering.
This remaps streams (making the original 2nd audio first) and sets only the new first audio as default:
ffmpeg -i input.mkv \
-map 0:v -map 0:a:1 -map 0:a:0 -map 0:a:2 -map 0:s? \
-c copy \
-disposition:a:0 default \
-disposition:a:1 0 \
-disposition:a:2 0 \
output.mkva:0 = your desired primary; we mark it
default.0.ffprobe -hide_banner -loglevel error -select_streams a \
-show_entries stream=index,disposition:stream_tags=language,title \
-of default=nw=1 input.mkvLook for disposition:default=1 on the one you want.
If you prefer to edit in place:
mkvmerge -i input.mkvmkvpropedit input.mkv \
--edit track:a1 --set flag-default=1 --set flag-forced=0 \
--edit track:a2 --set flag-default=0 --set flag-forced=0 \
--edit track:a3 --set flag-default=0 --set flag-forced=0This will make the second track truly “primary” for players that honor MKV defaults.