Skip to content

fix: keep each audio stream's own tags when selecting streams - #329

Merged
slhck merged 1 commit into
slhck:masterfrom
jayhemnani9910:fix/audio-tags-follow-selected-streams
Dec 3, 2026
Merged

slhck merged 1 commit into
slhck:masterfrom
jayhemnani9910:fix/audio-tags-follow-selected-streams

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

With --audio-streams, the output audio tracks get the language and title of a different track:

in.mkv:  a:0 language=jpn title=Japanese
         a:1 language=eng title=English
$ ffmpeg-normalize in.mkv -o out.mkv -c:a aac --audio-streams 1 --keep-other-audio
out.mkv: a:0 (the English track, normalized)    language=jpn title=Japanese
         a:1 (the Japanese track, copied)       language=eng title=English

Per-stream tags are mapped by position (-map_metadata:s:a:N 0:s:a:N), but the output audio order is the normalized streams first, then the passthrough ones. The positions only line up when every audio stream is normalized in input order. --audio-default-only hits the same problem when the default track is not the first.

For audio, the mapping now follows the output order and takes each track's tags from its own input stream (0:s:<stream index>). Video and subtitle mapping is unchanged. The stream selection moved up a few lines so the metadata step can use it.

Testing: added test_selected_audio_stream_keeps_its_own_tags. On master it fails (['jpn', 'eng']); with this change it gets ['eng', 'jpn']. The full suite passes (191, master 190).

@slhck
slhck merged commit f6ca231 into slhck:master Dec 3, 2026
4 checks passed
@slhck

slhck commented Dec 3, 2026

Copy link
Copy Markdown
Owner

Good catch, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants