Using MediaInfo DLL (64-bit), I am attempting to get the standard text output providing information about an mp4 file.
To wrap the dll, I have created a MediaInfo class, based on my (limited) understanding from the quickstart guide.
public class MediaInfo
{
[DllImport("MediaInfo.dll")]
private static extern IntPtr MediaInfo_New();
[DllImport("MediaInfo.dll")]
private static extern void MediaInfo_Open(string FileName);
[DllImport("MediaInfo.dll")]
private static extern IntPtr MediaInfo_Inform(IntPtr Handle);
[DllImport("MediaInfo.DLL")]
private static extern void MediaInfo_Close(IntPtr Handle);
IntPtr Handle;
public MediaInfo()
{
Handle = MediaInfo_New();
}
public void Open(string FileName)
{
MediaInfo_Open(FileName);
}
public string Inform()
{
return Marshal.PtrToStringUni(MediaInfo_Inform(Handle));
}
public void Close()
{
MediaInfo_Close(Handle);
}
}
And I am calling this class using the below console app:
static void Main(string[] args)
{
var objMediaInfo = new MediaInfo();
objMediaInfo.Open("test.mp4");
string result = objMediaInfo.Inform();
objMediaInfo.Close();
Console.WriteLine(result);
Console.ReadKey();
}
However, I am only getting a blank string in return. I have tried a few different media files.
I am aware there is already a fully developed wrapper for this, but I would like to keep this simple and lightweight.