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 -metadata:s:a:0 language=eng labels an audio track

Ffmpeg
~/tips/tip-ffmpeg-metadata-language

ffmpeg -i film.mkv -map 0 -c copy -metadata:s:a:0 language=eng -metadata:s:a:1 language=nld film-tagged.mkv

Sets the language tag on audio or subtitle tracks so players show the right name.

A film with two audio tracks called “Track 1” and “Track 2” makes you guess. Media players read the language tag of each track, and ffmpeg can set it without re-encoding.

ffmpeg -i film.mkv -map 0 -c copy -metadata:s:a:0 language=eng -metadata:s:a:1 language=nld film-tagged.mkv

The part after :s: picks the stream: a:0 is the first audio track, a:1 the second and s:0 would be the first subtitle track. The value is a three-letter ISO 639-2 code, like eng, nld or deu. You can also give a track a readable name with title=, for example -metadata:s:a:1 title="Commentary".

I’d always add -map 0 here. Without it ffmpeg keeps only one audio track, and the tag for the second one goes nowhere.

This does rewrite the whole file, because ffmpeg always makes a new output. For a big MKV that is a lot of disk activity for a tiny change. If you work with MKV a lot, mkvpropedit from MKVToolNix changes the tags in place within a second. For MP4 and other formats, the ffmpeg way is the simple one.

Further reading: ffmpeg documentation

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