2013-10-06 51 views
4

有沒有辦法在Windows上使用Visual Studio C++讀取媒體文件(avi,mp4,mkv等)的信息(fps,比特率,持續時間,所需的編解碼器等)?如何使用visual C++讀取媒體文件的信息?

我設法使用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(); 

回答

相關問題