有没有办法使用 Visual Studio C++ 在 Windows 上读取媒体文件(avi、mp4、mkv 等)的信息(fps、比特率、持续时间、所需的编解码器等)?
我设法使用directshow( http://msdn.microsoft.com/en-us/library/windows/desktop/dd389098%28v=vs.85%29.aspx)播放各种文件(实际上我什至不想要)) 但我不知道如何只从文件中获取信息。
编辑:我让它像这样工作......
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();