http://blog.sina.com.cn/u/4841fc61010004bk
bitrate——“位元速率”是媒體檔案的一個屬性,通常一個媒體檔案會有幾個Stream——“流”,如音頻流、視頻流等,此處的“位元速率”是指音頻流和視頻流的位元速率的疊加。
環境:VC 標頭檔: #include "wmsdk.h" 在VC的“工具-〉選項(options)”中相應地設定安裝WMFSDK9的路徑: 如:C:/WMSDK/WMFSDK9/Include, C:/WMSDK/WMFSDK9/lib (利用windows media Format SDK 9 的相關函數) 更完整的設定,可以參照: http://lenux.blogchina.com/3936516.html (協助很大,呵呵,贊以下:) HRESULT hr = CoInitialize(0);
IWMSyncReader *m_pSynReader;
IWMProfile *ppProfile;
DWORD dwCount = 0;
DWORD totalBitrate = 0; hr = WMCreateSyncReader(NULL,WMT_RIGHT_PLAYBACK,&m_pSynReader);
hr = m_pSynReader->Open(L"C://2.WMV"); m_pSynReader->QueryInterface(IID_IWMProfile, (void **)&ppProfile);
hr = ppProfile->GetStreamCount(&dwCount);
if(SUCCEEDED(hr))
{
for(WORD w=0;w<=dwCount;w++)
{
IWMStreamConfig* pStrmConf = NULL;
hr = ppProfile->GetStream(w,&pStrmConf);
if(SUCCEEDED(hr))
{
GUID guidST;
hr = pStrmConf->GetStreamType(&guidST);
if(SUCCEEDED(hr))
{
if(guidST==WMMEDIATYPE_Video)
{
DWORD videoBitrate;
hr = pStrmConf->GetBitrate(&videoBitrate);
totalBitrate = totalBitrate + videoBitrate;
}
if(guidST==WMMEDIATYPE_Audio)
{
DWORD audioBitrate;
hr = pStrmConf->GetBitrate(&audioBitrate);
totalBitrate = totalBitrate + audioBitrate;
}
}
pStrmConf->Release();
}
}
} 幾個說明:1.hr = m_pSynReader->Open(L"C://2.WMV"); 看一下WMFSDK9的文檔說明:
HRESULT Open(
const WCHAR*
pwszFilename
);
所以,如果不是在Unicode格式下編譯,需要先將ANSI轉換成Unicode,
例如:將CString str 轉換為 LPCWSTR pcwStr
CString str=_T("TestStr");
USES_CONVERSION;
LPWCSTR pwcStr = A2CW((LPCSTR)str);2.HRESULT hr = CoInitialize(0); COM的使用,需要有CoInitialize過程,如果使用前已經初始化了,則可省去