And a bunch of video codecs. Also fixed the dual-video channel issue.

pull/2/head
Taloth Saldono 5 years ago committed by Qstick
parent 54cfabec5c
commit 9a25878104

@ -32,6 +32,8 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo.MediaInfoFormatterTests
[TestCase("VC-1, V_MS/VFW/FOURCC / WVC1, Advanced@L3, ", "", "VC1")]
[TestCase("VC-1, WMV3, MP@LL, ", "It's Always Sunny S07E13 The Gang's RevengeHDTV.XviD-2HD.avi", "VC1")]
[TestCase("V.MPEG4/ISO/AVC, V.MPEG4/ISO/AVC, , ", "pd.2015.S03E08.720p.iP.WEBRip.AAC2.0.H264-BTW", "h264")]
[TestCase("AVC / AVC, V_MPEG4/ISO/AVC, High@L4, ", "Resistance.2019.S01E03.1080p.RTE.WEB-DL.AAC2.0.x264-RTN", "x264")]
[TestCase("WMV1, WMV1, , ", "Droned.wmv", "WMV")]
[TestCase("WMV2, WMV2, , ", "Droned.wmv", "WMV")]
[TestCase("xvid, xvid, , ", "", "XviD")]
[TestCase("div3, div3, , ", "spsm.dvdrip.divx.avi'.", "DivX")]
@ -43,7 +45,12 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo.MediaInfoFormatterTests
[TestCase("V_MPEGH/ISO/HEVC, V_MPEGH/ISO/HEVC, , ", "The BBT S11E12 The Matrimonial Metric 1080p 10bit AMZN WEB-DL", "h265")]
[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("MPEG-4 Visual, 20, , ", "", "")]
[TestCase("MPEG-4 Visual, mp4v-20, Simple@L1, Lavc57.48.101", "", "")]
[TestCase("mp4v, mp4v, , ", "American.Chopper.S06E07.Mountain.Creek.Bike.DSR.XviD-KRS", "XviD")]
[TestCase("V_QUICKTIME, V_QUICKTIME, , ", "Custom", "")]
[TestCase("MPEG-4 Visual, FMP4, , ", "", "")]
[TestCase("MPEG-4 Visual, MP42, , ", "", "")]
[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)
{

@ -239,24 +239,24 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
return FormatVideoCodecLegacy(mediaInfo, sceneName);
}
var videoFormat = mediaInfo.VideoFormat;
var videoFormat = mediaInfo.VideoFormat.Trim().Split(new[] { " / " }, StringSplitOptions.RemoveEmptyEntries);
var videoCodecID = mediaInfo.VideoCodecID ?? string.Empty;
var videoProfile = mediaInfo.VideoProfile ?? string.Empty;
var videoCodecLibrary = mediaInfo.VideoCodecLibrary ?? string.Empty;
var result = videoFormat;
var result = mediaInfo.VideoFormat.Trim();
if (videoFormat.IsNullOrWhiteSpace())
if (videoFormat.Empty())
{
return result;
}
if (videoFormat == "x264")
if (videoFormat.ContainsIgnoreCase("x264"))
{
return "x264";
}
if (videoFormat == "AVC" || videoFormat == "V.MPEG4/ISO/AVC")
if (videoFormat.ContainsIgnoreCase("AVC") || videoFormat.ContainsIgnoreCase("V.MPEG4/ISO/AVC"))
{
if (videoCodecLibrary.StartsWithIgnoreCase("x264"))
{
@ -266,7 +266,7 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
return GetSceneNameMatch(sceneName, "AVC", "x264", "h264");
}
if (videoFormat == "HEVC" || videoFormat == "V_MPEGH/ISO/HEVC")
if (videoFormat.ContainsIgnoreCase("HEVC") || videoFormat.ContainsIgnoreCase("V_MPEGH/ISO/HEVC"))
{
if (videoCodecLibrary.StartsWithIgnoreCase("x265"))
{
@ -276,7 +276,7 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
return GetSceneNameMatch(sceneName, "HEVC", "x265", "h265");
}
if (videoFormat == "MPEG Video")
if (videoFormat.ContainsIgnoreCase("MPEG Video"))
{
if (videoCodecID == "2" || videoCodecID == "V_MPEG2")
{
@ -289,12 +289,12 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
}
}
if (videoFormat == "MPEG-2 Video")
if (videoFormat.ContainsIgnoreCase("MPEG-2 Video"))
{
return "MPEG2";
}
if (videoFormat == "MPEG-4 Visual")
if (videoFormat.ContainsIgnoreCase("MPEG-4 Visual"))
{
if (videoCodecID.ContainsIgnoreCase("XVID") ||
videoCodecLibrary.StartsWithIgnoreCase("XviD"))
@ -311,49 +311,77 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
}
}
if (videoFormat == "MPEG-4 Visual" || videoFormat == "mp4v")
if (videoFormat.ContainsIgnoreCase("MPEG-4 Visual") || videoFormat.ContainsIgnoreCase("mp4v"))
{
result = GetSceneNameMatch(sceneName, "XviD", "DivX", "");
if (result.IsNotNullOrWhiteSpace())
{
return result;
}
if (videoCodecLibrary.Contains("Lavc"))
{
return ""; // libavcodec mpeg-4
}
if (videoCodecLibrary.Contains("em4v"))
{
return ""; // NeroDigital
}
if (videoCodecLibrary.Contains("Intel(R) IPP"))
{
return ""; // Intel(R) IPP
}
if (videoFormat == "VC-1")
if (videoCodecLibrary == "")
{
return ""; // Unknown mp4v
}
}
if (videoFormat.ContainsIgnoreCase("VC-1"))
{
return "VC1";
}
if (videoFormat.EqualsIgnoreCase("VP6") || videoFormat.EqualsIgnoreCase("VP7") ||
videoFormat.EqualsIgnoreCase("VP8") || videoFormat.EqualsIgnoreCase("VP9"))
if (videoFormat.ContainsIgnoreCase("VP6") || videoFormat.ContainsIgnoreCase("VP7") ||
videoFormat.ContainsIgnoreCase("VP8") || videoFormat.ContainsIgnoreCase("VP9"))
{
return videoFormat.ToUpperInvariant();
return videoFormat.First().ToUpperInvariant();
}
if (videoFormat == "WMV2")
if (videoFormat.ContainsIgnoreCase("WMV1") || videoFormat.ContainsIgnoreCase("WMV2"))
{
return "WMV";
}
if (videoFormat.EqualsIgnoreCase("DivX") || videoFormat.EqualsIgnoreCase("div3"))
if (videoFormat.ContainsIgnoreCase("DivX") || videoFormat.ContainsIgnoreCase("div3"))
{
return "DivX";
}
if (videoFormat.EqualsIgnoreCase("XviD"))
if (videoFormat.ContainsIgnoreCase("XviD"))
{
return "XviD";
}
if (videoFormat.EqualsIgnoreCase("mp43"))
if (videoFormat.ContainsIgnoreCase("V_QUICKTIME") ||
videoFormat.ContainsIgnoreCase("RealVideo 4"))
{
return "";
}
if (videoFormat.ContainsIgnoreCase("mp42") ||
videoFormat.ContainsIgnoreCase("mp43"))
{
// MS old DivX competitor
return "";
}
Logger.Debug()
.Message("Unknown video format: '{0}' in '{1}'.", string.Join(", ", videoFormat, videoCodecID, videoProfile, videoCodecLibrary), sceneName)
.WriteSentryWarn("UnknownVideoFormat", mediaInfo.ContainerFormat, videoFormat, videoCodecID)
.WriteSentryWarn("UnknownVideoFormat", mediaInfo.ContainerFormat, mediaInfo.VideoFormat, videoCodecID)
.Write();
return result;

Loading…
Cancel
Save