How can I read media file information using Visual C ++?

Is there a way to read the information (fps, bitrate, duration, codecs required, etc.) of a media file (avi, mp4, mkv, etc.) in windows using visual studio C ++?

I managed to play various files (which I donโ€™t even want) using directshow ( http://msdn.microsoft.com/en-us/library/windows/desktop/dd389098%28v=vs.85%29.aspx ), but I donโ€™t know how to get information only from a file.

Edit: I got it like this ...

int             height, width, framerate, bitrate;
LARGE_INTEGER   duration;

// initialize the COM library
CoInitialize(NULL);

// 
IPropertyStore* store = NULL;
SHGetPropertyStoreFromParsingName(L"E:\\test.avi", NULL, GPS_DEFAULT, __uuidof(IPropertyStore), (void**)&store);

PROPVARIANT variant;

store->GetValue(PKEY_Media_Duration, &variant);
duration = variant.hVal;
store->GetValue(PKEY_Video_FrameHeight, &variant);
height = variant.lVal;
store->GetValue(PKEY_Video_FrameWidth, &variant);
width = variant.lVal;
store->GetValue(PKEY_Video_FrameRate, &variant);
framerate = variant.lVal;
store->GetValue(PKEY_Video_TotalBitrate, &variant);
bitrate = variant.lVal;
// 
store->Release();
//
CoUninitialize();
+4
source share

All Articles