Detect Dolby Vision as HDR and MediaInfo Update

Fixed: Detect Dolby Vision as HDR
New: Updated MediaInfo on Windows and MacOS
Closes #4276
This commit is contained in:
Matt Evans 2021-02-03 12:19:22 +11:00 committed by GitHub
parent 5e4c9dfe60
commit 3d3cd8cf5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 32 additions and 13 deletions

View File

@ -8,20 +8,28 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo.MediaInfoFormatterTests
[TestFixture] [TestFixture]
public class FormatVideoDynamicRangeFixture : TestBase public class FormatVideoDynamicRangeFixture : TestBase
{ {
[TestCase(8, "BT.601 NTSC", "BT.709", "")] [TestCase(8, "", "", "", "", "")]
[TestCase(10, "BT.2020", "PQ", "HDR")] [TestCase(8, "BT.601 NTSC", "BT.709", "", "", "")]
[TestCase(8, "BT.2020", "PQ", "")] [TestCase(10, "BT.2020", "PQ", "", "", "HDR")]
[TestCase(10, "BT.601 NTSC", "PQ", "")] [TestCase(8, "BT.2020", "PQ", "", "", "")]
[TestCase(10, "BT.2020", "BT.709", "")] [TestCase(10, "BT.601 NTSC", "PQ", "", "", "")]
[TestCase(10, "BT.2020", "HLG", "HDR")] [TestCase(10, "BT.2020", "BT.709", "", "", "")]
public void should_format_video_dynamic_range(int bitDepth, string colourPrimaries, string transferCharacteristics, string expectedVideoDynamicRange) [TestCase(10, "BT.2020", "HLG", "", "", "HDR")]
[TestCase(10, "", "", "Dolby Vision", "", "HDR")]
[TestCase(10, "", "", "SMPTE ST 2086", "HDR10", "HDR")]
[TestCase(8, "", "", "Dolby Vision", "", "HDR")]
[TestCase(8, "", "", "SMPTE ST 2086", "HDR10", "HDR")]
[TestCase(10, "BT.2020", "PQ", "Dolby Vision / SMPTE ST 2086", "Blu-ray / HDR10", "HDR")]
public void should_format_video_dynamic_range(int bitDepth, string colourPrimaries, string transferCharacteristics, string hdrFormat, string hdrFormatCompatibility, string expectedVideoDynamicRange)
{ {
var mediaInfo = new MediaInfoModel var mediaInfo = new MediaInfoModel
{ {
VideoBitDepth = bitDepth, VideoBitDepth = bitDepth,
VideoColourPrimaries = colourPrimaries, VideoColourPrimaries = colourPrimaries,
VideoTransferCharacteristics = transferCharacteristics, VideoTransferCharacteristics = transferCharacteristics,
SchemaRevision = 5 VideoHdrFormat = hdrFormat,
VideoHdrFormatCompatibility = hdrFormatCompatibility,
SchemaRevision = 7
}; };
MediaInfoFormatter.FormatVideoDynamicRange(mediaInfo).Should().Be(expectedVideoDynamicRange); MediaInfoFormatter.FormatVideoDynamicRange(mediaInfo).Should().Be(expectedVideoDynamicRange);

View File

@ -65,6 +65,8 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
info.VideoColourPrimaries.Should().Be("BT.601 NTSC"); info.VideoColourPrimaries.Should().Be("BT.601 NTSC");
info.VideoTransferCharacteristics.Should().Be("BT.709"); info.VideoTransferCharacteristics.Should().Be("BT.709");
info.AudioAdditionalFeatures.Should().BeOneOf("", "LC"); info.AudioAdditionalFeatures.Should().BeOneOf("", "LC");
info.VideoHdrFormat.Should().BeEmpty();
info.VideoHdrFormatCompatibility.Should().BeEmpty();
} }
@ -107,6 +109,8 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
info.VideoColourPrimaries.Should().Be("BT.601 NTSC"); info.VideoColourPrimaries.Should().Be("BT.601 NTSC");
info.VideoTransferCharacteristics.Should().Be("BT.709"); info.VideoTransferCharacteristics.Should().Be("BT.709");
info.AudioAdditionalFeatures.Should().BeOneOf("", "LC"); info.AudioAdditionalFeatures.Should().BeOneOf("", "LC");
info.VideoHdrFormat.Should().BeEmpty();
info.VideoHdrFormatCompatibility.Should().BeEmpty();
} }
[Test] [Test]

View File

@ -587,11 +587,14 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
private static readonly string[] ValidHdrTransferFunctions = {"PQ", "HLG"}; private static readonly string[] ValidHdrTransferFunctions = {"PQ", "HLG"};
private const string ValidHdrColourPrimaries = "BT.2020"; private const string ValidHdrColourPrimaries = "BT.2020";
private const string VideoDynamicRangeHdr = "HDR";
public static string FormatVideoDynamicRange(MediaInfoModel mediaInfo) public static string FormatVideoDynamicRange(MediaInfoModel mediaInfo)
{ {
// assume SDR by default if (mediaInfo.VideoHdrFormat.IsNotNullOrWhiteSpace())
var videoDynamicRange = ""; {
return VideoDynamicRangeHdr;
}
if (mediaInfo.VideoBitDepth >= 10 && if (mediaInfo.VideoBitDepth >= 10 &&
mediaInfo.VideoColourPrimaries.IsNotNullOrWhiteSpace() && mediaInfo.VideoColourPrimaries.IsNotNullOrWhiteSpace() &&
@ -600,11 +603,11 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
if (mediaInfo.VideoColourPrimaries.EqualsIgnoreCase(ValidHdrColourPrimaries) && if (mediaInfo.VideoColourPrimaries.EqualsIgnoreCase(ValidHdrColourPrimaries) &&
ValidHdrTransferFunctions.Any(mediaInfo.VideoTransferCharacteristics.Contains)) ValidHdrTransferFunctions.Any(mediaInfo.VideoTransferCharacteristics.Contains))
{ {
videoDynamicRange = "HDR"; return VideoDynamicRangeHdr;
} }
} }
return videoDynamicRange; return "";
} }
} }
} }

View File

@ -21,6 +21,8 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
public int VideoMultiViewCount { get; set; } public int VideoMultiViewCount { get; set; }
public string VideoColourPrimaries { get; set; } public string VideoColourPrimaries { get; set; }
public string VideoTransferCharacteristics { get; set; } public string VideoTransferCharacteristics { get; set; }
public string VideoHdrFormat { get; set; }
public string VideoHdrFormatCompatibility { get; set; }
public int Width { get; set; } public int Width { get; set; }
public int Height { get; set; } public int Height { get; set; }
public string AudioFormat { get; set; } public string AudioFormat { get; set; }

View File

@ -19,7 +19,7 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
private readonly Logger _logger; private readonly Logger _logger;
public const int MINIMUM_MEDIA_INFO_SCHEMA_REVISION = 3; public const int MINIMUM_MEDIA_INFO_SCHEMA_REVISION = 3;
public const int CURRENT_MEDIA_INFO_SCHEMA_REVISION = 6; public const int CURRENT_MEDIA_INFO_SCHEMA_REVISION = 7;
public VideoFileInfoReader(IDiskProvider diskProvider, Logger logger) public VideoFileInfoReader(IDiskProvider diskProvider, Logger logger)
{ {
@ -166,6 +166,8 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
VideoMultiViewCount = videoMultiViewCount, VideoMultiViewCount = videoMultiViewCount,
VideoColourPrimaries = mediaInfo.Get(StreamKind.Video, 0, "colour_primaries"), VideoColourPrimaries = mediaInfo.Get(StreamKind.Video, 0, "colour_primaries"),
VideoTransferCharacteristics = mediaInfo.Get(StreamKind.Video, 0, "transfer_characteristics"), VideoTransferCharacteristics = mediaInfo.Get(StreamKind.Video, 0, "transfer_characteristics"),
VideoHdrFormat = mediaInfo.Get(StreamKind.Video, 0, "HDR_Format"),
VideoHdrFormatCompatibility = mediaInfo.Get(StreamKind.Video, 0, "HDR_Format_Compatibility"),
Height = height, Height = height,
Width = width, Width = width,
AudioFormat = mediaInfo.Get(StreamKind.Audio, 0, "Format"), AudioFormat = mediaInfo.Get(StreamKind.Audio, 0, "Format"),