Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions mkv-audit/analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 6 additions & 4 deletions mkv-audit/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down