mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-06-04 14:14:29 -04:00
Infer more audio codec from containers (#12837)
This commit is contained in:
parent
8b4fa42e49
commit
6813db06d7
@ -629,49 +629,21 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
/// <returns>Codec string.</returns>
|
/// <returns>Codec string.</returns>
|
||||||
public string InferAudioCodec(string container)
|
public string InferAudioCodec(string container)
|
||||||
{
|
{
|
||||||
var ext = "." + (container ?? string.Empty);
|
if (string.IsNullOrWhiteSpace(container))
|
||||||
|
|
||||||
if (string.Equals(ext, ".mp3", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
return "mp3";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.Equals(ext, ".aac", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
{
|
||||||
|
// this may not work, but if the client is that broken we can not do anything better
|
||||||
return "aac";
|
return "aac";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.Equals(ext, ".wma", StringComparison.OrdinalIgnoreCase))
|
var inferredCodec = container.ToLowerInvariant();
|
||||||
{
|
|
||||||
return "wma";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.Equals(ext, ".ogg", StringComparison.OrdinalIgnoreCase))
|
return inferredCodec switch
|
||||||
{
|
{
|
||||||
return "vorbis";
|
"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",
|
||||||
if (string.Equals(ext, ".oga", StringComparison.OrdinalIgnoreCase))
|
_ => inferredCodec
|
||||||
{
|
};
|
||||||
return "vorbis";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.Equals(ext, ".ogv", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
return "vorbis";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.Equals(ext, ".webm", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
return "vorbis";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.Equals(ext, ".webma", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
return "vorbis";
|
|
||||||
}
|
|
||||||
|
|
||||||
return "copy";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user