This isn't necessarily a C++ solution - I haven't played with C++ for over a decade - but there is a .NET way to get some video info direct from the OS provided a suitable codec is installed - I use it to get video duration and resolution, using the WindowsAPICodePack in C#:
public static Size GetDisplaySize(string filename)
{
int height = 0;
int width = 0;
try
{
if (System.IO.File.Exists(filename))
{
using (ShellObject so = ShellObject.FromParsingName(filename))
{
if (so != null)
{
string type = (string)so.Properties.GetProperty("System.KindText").ValueAsObject;
switch (type)
{
case "Video":
height = Convert.ToInt32(so.Properties.GetProperty(SystemProperties.System.Video.FrameHeight).ValueAsObject);
width = Convert.ToInt32(so.Properties.GetProperty(SystemProperties.System.Video.FrameWidth).ValueAsObject);
break;
case "Picture":
height = Convert.ToInt32(so.Properties.GetProperty(SystemProperties.System.Image.VerticalSize).ValueAsObject);
width = Convert.ToInt32(so.Properties.GetProperty(SystemProperties.System.Image.HorizontalSize).ValueAsObject);
break;
case "Music":
break;
default:
break;
}
}
}
}
}
catch { }
if (width > 0 && height > 0) return new Size(width, height);
return new Size(0, 0);
}
public static TimeSpan GetDuration(string filename)
{
long duration = 0;
try
{
if (System.IO.File.Exists(filename))
{
using (ShellObject so = ShellObject.FromParsingName(filename))
{
if (so != null)
{
string type = (string)so.Properties.GetProperty("System.KindText").ValueAsObject;
switch (type)
{
case "Video":
duration = Convert.ToInt64(so.Properties.GetProperty(SystemProperties.System.Media.Duration).ValueAsObject);
break;
case "Picture":
break;
case "Music":
duration = Convert.ToInt64(so.Properties.GetProperty(SystemProperties.System.Media.Duration).ValueAsObject);
break;
default:
break;
}
}
}
}
}
catch { }
if (duration > 0) return new TimeSpan(duration);
return new TimeSpan(0);
}
I would think that the CodePack would work in C++ as well.