diff options
| author | gnattu <gnattu@users.noreply.github.com> | 2024-10-19 19:23:48 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-19 05:23:48 -0600 |
| commit | 6813db06d7d092e89eaa7ee291f6b5b1eb7dc4cb (patch) | |
| tree | 0f8537b6caeadd5dc0367e54a3f0202e3e6580a5 /MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs | |
| parent | 8b4fa42e49e305df544dd12fedb7a55a5bdaf74b (diff) | |
Infer more audio codec from containers (#12837)
Diffstat (limited to 'MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs')
| -rw-r--r-- | MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs | 46 |
1 files changed, 9 insertions, 37 deletions
diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index c120e08fa..bd5897a84 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -629,49 +629,21 @@ namespace MediaBrowser.Controller.MediaEncoding /// <returns>Codec string.</returns> public string InferAudioCodec(string container) { - var ext = "." + (container ?? string.Empty); - - if (string.Equals(ext, ".mp3", StringComparison.OrdinalIgnoreCase)) - { - return "mp3"; - } - - if (string.Equals(ext, ".aac", StringComparison.OrdinalIgnoreCase)) + if (string.IsNullOrWhiteSpace(container)) { + // this may not work, but if the client is that broken we can not do anything better return "aac"; } - if (string.Equals(ext, ".wma", StringComparison.OrdinalIgnoreCase)) - { - return "wma"; - } - - if (string.Equals(ext, ".ogg", StringComparison.OrdinalIgnoreCase)) - { - return "vorbis"; - } - - if (string.Equals(ext, ".oga", StringComparison.OrdinalIgnoreCase)) - { - return "vorbis"; - } - - if (string.Equals(ext, ".ogv", StringComparison.OrdinalIgnoreCase)) - { - return "vorbis"; - } + var inferredCodec = container.ToLowerInvariant(); - if (string.Equals(ext, ".webm", StringComparison.OrdinalIgnoreCase)) + return inferredCodec switch { - return "vorbis"; - } - - if (string.Equals(ext, ".webma", StringComparison.OrdinalIgnoreCase)) - { - return "vorbis"; - } - - return "copy"; + "ogg" or "oga" or "ogv" or "webm" or "webma" => "opus", + "m4a" or "m4b" or "mp4" or "mov" or "mkv" or "mka" => "aac", + "ts" or "avi" or "flv" or "f4v" or "swf" => "mp3", + _ => inferredCodec + }; } /// <summary> |
