brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: ffmpeg -disposition picks which audio track plays first by default

Ffmpeg
~/tips/tip-ffmpeg-disposition-default-audio

ffmpeg -i in.mkv -map 0 -c copy -disposition:a:0 0 -disposition:a:1 default out.mkv

Marks a different audio or subtitle track as the default in a video file, without re-encoding.

A film with a Dutch dub as the first audio track and the original English as the second is a small irritation I’d rather fix once in the file than every time I press play. The container keeps a default flag per stream, and ffmpeg can move it with -disposition, without re-encoding anything.

ffmpeg -i in.mkv -map 0 -c copy -disposition:a:0 0 -disposition:a:1 default out.mkv

Piece by piece: -map 0 keeps every stream from the input, -c copy copies them as they are, -disposition:a:0 0 clears all flags on the first audio track and -disposition:a:1 default marks the second audio track as the default. Counting starts at 0, so a:1 is the second audio stream. Subtitles work the same way with s: instead of a:.

Don’t leave out -map 0. Without it ffmpeg picks one stream per type on its own (for audio, the one with the most channels), and your second language or your subtitles quietly disappear from the output.

To see which track has which flag before and after, ffprobe in.mkv lists the streams and shows (default) next to the flagged ones. ffmpeg -dispositions lists every flag ffmpeg knows, such as forced for subtitles that should always show.

Two caveats. A value without a + or - in front replaces all the flags on that stream, so use +default if you only want to add one. And the flag is a hint for the player. A player with its own language preference can still pick another track.

Further reading: ffmpeg documentation: -disposition, ffmpeg documentation: stream selection

Going deeper: Guide: the Bazarr settings that matter, from languages to the minimum score

More Ffmpeg tips ffmpeg -stream_loop 2 -i in.mp4 -c copy out.mp4 ffmpeg -i in.mp4 \ ffmpeg -i video.mp4 -i video.en.srt -map 0 -map 1 -c copy -c:s mov_text -metadata:s:s:0 language=eng video-subs.mp4 ffmpeg -i film.mkv -map 0:v -map 0:a:0 -c:v copy -c:a aac -b:a 192k -ac 2 film-stereo.mkv ffmpeg -i talk.mp4 -vn -c:a copy talk.m4a All Ffmpeg tips (38) All topics

Link