1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

New: Additional Atmos detection in MediaInfo

ref Radarr/Radarr#3712
This commit is contained in:
Taloth Saldono 2019-09-04 23:24:29 +02:00 committed by Qstick
parent 7dc629a647
commit 54cfabec5c
3 changed files with 64 additions and 38 deletions

View File

@ -30,6 +30,8 @@ public void should_format_audio_format_legacy(string audioFormat, string expecte
[TestCase("TrueHD, A_TRUEHD, , , ", "", "TrueHD")]
[TestCase("MLP FBA, A_TRUEHD, , , ", "TrueHD", "TrueHD")]
[TestCase("MLP FBA, A_TRUEHD, , , 16-ch", "Atmos", "TrueHD Atmos")]
[TestCase("Atmos / TrueHD, A_TRUEHD, , , ", "TrueHD.Atmos.7.1", "TrueHD Atmos")]
[TestCase("Atmos / TrueHD / AC-3, 131, , , ", "", "TrueHD Atmos")]
[TestCase("WMA, 161, , , ", "Droned.wmv", "WMA")]
[TestCase("WMA, 162, Pro, , ", "B.N.S04E18.720p.WEB-DL", "WMA")]
[TestCase("Opus, A_OPUS, , , ", "Roadkill Ep3x11 - YouTube.webm", "Opus")]
@ -44,6 +46,9 @@ public void should_format_audio_format_legacy(string audioFormat, string expecte
[TestCase("E-AC-3, A_EAC3, , , JOC", "EAC3", "EAC3")]
[TestCase("E-AC-3, A_EAC3, , , ", "DD5.1", "EAC3")]
[TestCase("AC-3, A_AC3, , , ", "DD5.1", "AC3")]
[TestCase("A_QUICKTIME, A_QUICKTIME, , , ", "", "")]
[TestCase("ADPCM, 2, , , ", "Custom?", "PCM")]
[TestCase("ADPCM, ima4, , , ", "Custom", "PCM")]
public void should_format_audio_format(string audioFormatPack, string sceneName, string expectedFormat)
{
var split = audioFormatPack.Split(new string[] { ", " }, System.StringSplitOptions.None);

View File

@ -44,6 +44,7 @@ public void should_format_video_codec_with_source_title_legacy(string videoCodec
[TestCase("MPEG-4 Visual, 20, Simple@L1, Lavc52.29.0", "Will.And.Grace.S08E14.WS.DVDrip.XviD.I.Love.L.Gay-Obfuscated", "XviD")]
[TestCase("MPEG-4 Visual, 20, Advanced Simple@L5, XviD0046", "", "XviD")]
[TestCase("mp4v, mp4v, , ", "American.Chopper.S06E07.Mountain.Creek.Bike.DSR.XviD-KRS", "XviD")]
[TestCase("mp43, V_MS/VFW/FOURCC / mp43, , ", "Bubble.Guppies.S01E13.480p.WEB-DL.H.264-BTN-Custom", "")]
public void should_format_video_format(string videoFormatPack, string sceneName, string expectedFormat)
{
var split = videoFormatPack.Split(new string[] { ", " }, System.StringSplitOptions.None);

View File

@ -39,38 +39,43 @@ public static string FormatAudioCodec(MediaInfoModel mediaInfo, string sceneName
return FormatAudioCodecLegacy(mediaInfo, sceneName);
}
var audioFormat = mediaInfo.AudioFormat;
var audioFormat = mediaInfo.AudioFormat.Trim().Split(new[] { " / " }, StringSplitOptions.RemoveEmptyEntries);
var audioCodecID = mediaInfo.AudioCodecID ?? string.Empty;
var audioProfile = mediaInfo.AudioProfile ?? string.Empty;
var audioCodecLibrary = mediaInfo.AudioCodecLibrary ?? string.Empty;
var splitAdditionalFeatures = (mediaInfo.AudioAdditionalFeatures ?? string.Empty).Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
if (audioFormat.IsNullOrWhiteSpace())
if (audioFormat.Empty())
{
return string.Empty;
}
if (audioFormat.EqualsIgnoreCase("AC-3"))
if (audioFormat.ContainsIgnoreCase("Atmos"))
{
return "AC3";
return "TrueHD Atmos";
}
if (audioFormat.EqualsIgnoreCase("E-AC-3"))
if (audioFormat.ContainsIgnoreCase("MLP FBA"))
{
return "EAC3";
}
if (audioFormat.EqualsIgnoreCase("AAC"))
{
if (audioCodecID == "A_AAC/MPEG4/LC/SBR")
if (splitAdditionalFeatures.ContainsIgnoreCase("16-ch"))
{
return "HE-AAC";
return "TrueHD Atmos";
}
return "AAC";
return "TrueHD";
}
if (audioFormat.EqualsIgnoreCase("DTS"))
if (audioFormat.ContainsIgnoreCase("TrueHD"))
{
return "TrueHD";
}
if (audioFormat.ContainsIgnoreCase("FLAC"))
{
return "FLAC";
}
if (audioFormat.ContainsIgnoreCase("DTS"))
{
if (splitAdditionalFeatures.ContainsIgnoreCase("XLL"))
{
@ -94,17 +99,32 @@ public static string FormatAudioCodec(MediaInfoModel mediaInfo, string sceneName
return "DTS";
}
if (audioFormat.EqualsIgnoreCase("FLAC"))
if (audioFormat.ContainsIgnoreCase("E-AC-3"))
{
return "FLAC";
return "EAC3";
}
if (audioFormat.Trim().EqualsIgnoreCase("mp3"))
if (audioFormat.ContainsIgnoreCase("AC-3"))
{
return "AC3";
}
if (audioFormat.ContainsIgnoreCase("AAC"))
{
if (audioCodecID == "A_AAC/MPEG4/LC/SBR")
{
return "HE-AAC";
}
return "AAC";
}
if (audioFormat.ContainsIgnoreCase("mp3"))
{
return "MP3";
}
if (audioFormat.EqualsIgnoreCase("MPEG Audio"))
if (audioFormat.ContainsIgnoreCase("MPEG Audio"))
{
if (mediaInfo.AudioCodecID == "55" || mediaInfo.AudioCodecID == "A_MPEG/L3" || mediaInfo.AudioProfile == "Layer 3")
{
@ -117,47 +137,42 @@ public static string FormatAudioCodec(MediaInfoModel mediaInfo, string sceneName
}
}
if (audioFormat.EqualsIgnoreCase("Opus"))
if (audioFormat.ContainsIgnoreCase("Opus"))
{
return "Opus";
}
if (audioFormat.EqualsIgnoreCase("PCM"))
if (audioFormat.ContainsIgnoreCase("PCM"))
{
return "PCM";
}
if (audioFormat.EqualsIgnoreCase("TrueHD"))
if (audioFormat.ContainsIgnoreCase("ADPCM"))
{
return "TrueHD";
return "PCM";
}
if (audioFormat.EqualsIgnoreCase("MLP FBA"))
{
if (splitAdditionalFeatures.ContainsIgnoreCase("16-ch"))
{
return "TrueHD Atmos";
}
return "TrueHD";
}
if (audioFormat.EqualsIgnoreCase("Vorbis"))
if (audioFormat.ContainsIgnoreCase("Vorbis"))
{
return "Vorbis";
}
if (audioFormat == "WMA")
if (audioFormat.ContainsIgnoreCase("WMA"))
{
return "WMA";
}
if (audioFormat.ContainsIgnoreCase("A_QUICKTIME"))
{
return "";
}
Logger.Debug()
.Message("Unknown audio format: '{0}' in '{1}'.", string.Join(", ", audioFormat, audioCodecID, audioProfile, audioCodecLibrary), sceneName)
.WriteSentryWarn("UnknownAudioFormat", mediaInfo.ContainerFormat, audioFormat, audioCodecID)
.Message("Unknown audio format: '{0}' in '{1}'.", string.Join(", ", mediaInfo.AudioFormat, audioCodecID, audioProfile, audioCodecLibrary, mediaInfo.AudioAdditionalFeatures), sceneName)
.WriteSentryWarn("UnknownAudioFormat", mediaInfo.ContainerFormat, mediaInfo.AudioFormat, audioCodecID)
.Write();
return audioFormat;
return mediaInfo.AudioFormat;
}
public static string FormatAudioCodecLegacy(MediaInfoModel mediaInfo, string sceneName)
@ -331,6 +346,11 @@ public static string FormatVideoCodec(MediaInfoModel mediaInfo, string sceneName
return "XviD";
}
if (videoFormat.EqualsIgnoreCase("mp43"))
{
return "";
}
Logger.Debug()
.Message("Unknown video format: '{0}' in '{1}'.", string.Join(", ", videoFormat, videoCodecID, videoProfile, videoCodecLibrary), sceneName)
.WriteSentryWarn("UnknownVideoFormat", mediaInfo.ContainerFormat, videoFormat, videoCodecID)