I'm using the MediaInfo Nuget Wrapper to analyse a bunch of files
using MediaInfo Actual on a file I can see
Video
ID : 1
Format : HEVC
Format/Info : High Efficiency Video Coding
Format profile : Main [email protected]@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
This is also seen with Console.WriteLine(mw1.Inform());
However I'm unable to get that from the code below
I've tried HDR format, HDRformat and other speling but always returns ""
Given the fact that every file will be different is there a more dynamic way of doing this rather than hard coding each property?
Code still at testing stage
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();
}
}
}
Thanx
I've tried HDR format, HDRformat and other speling but always returns ""
HDR_Format
Tip: for knowing the keys to use, use MediaInfo command line with " --Language=raw" or graphical interface with XML output.
Jérôme, developer of MediaInfo