fix(audio): preserve Opus codec in M4A scans

This commit is contained in:
zarzet
2026-09-04 12:39:03 +07:00
parent 83beccbb63
commit 55da453913
3 changed files with 8 additions and 0 deletions
+2
View File
@@ -258,6 +258,8 @@ func libraryFormatForM4ACodec(codec string) string {
return "ac3"
case "ac4", "ac-4":
return "ac4"
case "opus":
return "opus"
case "aac", "mp4a":
return "m4a"
default:
+2
View File
@@ -842,6 +842,8 @@ func normalizeM4AAudioCodec(atomType string) string {
return "ac3"
case "ac-4":
return "ac4"
case "Opus":
return "opus"
default:
return strings.TrimSpace(atomType)
}
+4
View File
@@ -56,6 +56,7 @@ func TestM4ACodecFormatMapping(t *testing.T) {
"ec-3": "eac3",
"ac-3": "ac3",
"ac-4": "ac4",
"Opus": "opus",
}
for atomType, want := range cases {
if got := normalizeM4AAudioCodec(atomType); got != want {
@@ -69,6 +70,9 @@ func TestM4ACodecFormatMapping(t *testing.T) {
if got := libraryFormatForM4ACodec("eac3"); got != "eac3" {
t.Fatalf("libraryFormatForM4ACodec(eac3) = %q", got)
}
if got := libraryFormatForM4ACodec("Opus"); got != "opus" {
t.Fatalf("libraryFormatForM4ACodec(Opus) = %q", got)
}
if got := libraryFormatForM4ACodec("aac"); got != "m4a" {
t.Fatalf("libraryFormatForM4ACodec(aac) = %q", got)
}