diff --git a/mkv-audit/analyzer_test.go b/mkv-audit/analyzer_test.go index 7be4e04..ddc4dc2 100644 --- a/mkv-audit/analyzer_test.go +++ b/mkv-audit/analyzer_test.go @@ -209,6 +209,21 @@ func TestAnalyzeFile_BestSubByCodecBecomesDefault(t *testing.T) { } } +func TestAnalyzeFile_WebVTTCodecIDKnown(t *testing.T) { + info := MKVInfo{Tracks: []Track{ + audioTrack(0, "eng", "A_AC3", 2, true), + subTrack(1, "eng", "S_TEXT/UTF8", "English", true, false), // priority 5 + subTrack(2, "eng", "D_WEBVTT/SUBTITLES", "English", false, false), // priority 6, should win + }} + res := AnalyzeFile(info, AnalyzeOptions{}) + if len(res.UnknownCodecs) != 0 { + t.Errorf("D_WEBVTT/SUBTITLES should be a known codec; got %v", res.UnknownCodecs) + } + if !hasEdit(res.Edits, "flag-default=1") { + t.Errorf("WebVTT subtitle should outrank SRT and become default; edits: %v", res.Edits) + } +} + func TestAnalyzeFile_ForcedOnlySub_PromotedToMain(t *testing.T) { // When a forced-keyword subtitle is the only track for its language (no // main candidates), it is promoted to the main slot: default=1, forced=0. diff --git a/mkv-audit/config.go b/mkv-audit/config.go index 08e66bd..d3261b5 100644 --- a/mkv-audit/config.go +++ b/mkv-audit/config.go @@ -48,10 +48,12 @@ var subPriority = map[string]int{ "S_TEXT/SSA": 10, "S_HDMV/PGS": 8, "S_TEXT/WEBVTT": 6, - "S_TEXT/UTF8": 5, - "S_TEXT/ASCII": 5, - "S_DVBSUB": 3, - "S_VOBSUB": 3, + // Newer Matroska codec ID for WebVTT; mkvmerge muxes WebVTT under it. + "D_WEBVTT/SUBTITLES": 6, + "S_TEXT/UTF8": 5, + "S_TEXT/ASCII": 5, + "S_DVBSUB": 3, + "S_VOBSUB": 3, } // ietfMap converts ISO 639-2 codes to IETF/BCP-47 tags including region.