使用 C# 和 MediaInfo 如何检测 HDR 格式

Using C# and MediaInfo How to detect HDR format

我正在使用 MediaInfo Nuget Wrapper 分析一堆文件

在我能看到的文件上使用 MediaInfo Actual

Video 
ID : 1 
Format : HEVC 
Format/Info : High Efficiency Video Coding 
Format profile : Main 10@L5.1@Main 
HDR format : Dolby Vision, Version 1.0, dvhe.05.09, BL+RPU 
Codec ID : dvhe 
Codec ID/Info : High Efficiency Video Coding with Dolby Vision 

这也与 Console.WriteLine(mw1.Inform());

一起出现

但是我无法从下面的代码中得到它
我尝试过 HDR 格式、HDR 格式和其他拼写,但总是 returns ""

考虑到每个文件都会不同,是否有更动态的方式来执行此操作而不是对每个文件进行硬编码属性?

代码仍处于测试阶段

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MediaInfo;
using MediaInfo.Model;

namespace GetMediaInfo
{
 class Program
{
    static void Main(string[] args)
    {

        string BaseFold = @"Path\To\Test\Samples";

        string[] Files = Directory.GetFiles(BaseFold, "*.*", SearchOption.AllDirectories);
        foreach (var Vid in Files)
        {

            string VidName = Path.GetFileName(Vid);
            if (VidName.EndsWith("jpg"))
            {
                continue;
            }
            Console.WriteLine(VidName);

            var mw1 = new MediaInfo.MediaInfo();
            mw1.Option("ParseSpeed", "0");
            mw1.Open(Vid);
            string ToDisplay = "";
            var videostreamcount = mw1.CountGet(StreamKind.Video, 0);
            var AudioStreamcount = mw1.CountGet(StreamKind.Audio, 0);
            if (videostreamcount > 0)
            {
                    
                Console.WriteLine(mw1.Inform());
                foreach (var item in mw1.Get(StreamKind.Video,0,"*"))
                {
                    Console.WriteLine(item);
                }
                var Height = mw1.Get(StreamKind.Video, 0, "Height");
                var Width = mw1.Get(StreamKind.Video, 0, "Width");
                var VidFormat = mw1.Get(StreamKind.Video, 0, "Format");
                var HDRformat = mw1.Get(StreamKind.Video, 0, "HDR format"); // Always = ""
                var Codec = mw1.Get(StreamKind.Video, 0, "CodecID/Info");
                var CodecID = mw1.Get(StreamKind.Video, 0, "CodecID");
                Console.WriteLine("Height " + Height + ", Width " + Width + ", Codec " + Codec + ", CodecID " + CodecID + ", Format " + VidFormat + " , HDR format " + HDRformat);


                ToDisplay += "\r\n\r\nInfo_Parameters\r\n";
                ToDisplay += mw1.Option("Info_Parameters");

                //ToDisplay += "\r\n\r\nInfo_Capacities\r\n";
                //ToDisplay += mw1.Option("Info_Capacities");

                //ToDisplay += "\r\n\r\nInfo_Codecs\r\n";
                //ToDisplay += mw1.Option("Info_Codecs");
            //    Console.WriteLine(ToDisplay);
            }
            else
            {
                Console.WriteLine("Error No video streams in file");
            }

            if (AudioStreamcount > 0)
            {

                var AudioCodec = mw1.Get(StreamKind.Audio, 0, "CodecID/Info");
                var AudioCodecID = mw1.Get(StreamKind.Audio, 0, "CodecID");
                var AudioFormat = mw1.Get(StreamKind.Audio, 0, "Format");

                Console.WriteLine("AudioCodec: {0}, AudioCodecID: {1}, AudioFormat {2}", AudioCodec, AudioCodecID, AudioFormat);
            }
            else
            {
                Console.WriteLine("Error No Audio streams in file");
            }
        }
        Console.ReadLine();
    }
}
}

谢谢

I've tried HDR format, HDRformat and other speling but always returns ""

HDR_Format

提示:要了解要使用的键,请使用带“--Language=raw”的 MediaInfo 命令行或带 XML 输出的图形界面。

Jérôme,MediaInfo 的开发者