One way to get the media file "bit rate!

Source: Internet
Author: User

Http://blog.sina.com.cn/u/4841fc61010004bk

Bitrate-"bit rate" is an attribute of a media file. Generally, a media file has several streams-"streams", such as audio streams and video streams, the bit rate here refers to the superposition of the bit rate between the audio stream and the video stream.

Environment: VC header file: # include "wmsdk. H "in VC's" tools-> options (options) ", set the path to install wmfsdk9 accordingly, for example, C:/wmsdk/wmfsdk9/include, C: /wmsdk/wmfsdk9/lib (using Windows Media Format SDK 9 related functions) more complete settings, can refer to: http://lenux.blogchina.com/3936516.html (help a lot, huh, huh, like the following: 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 ();
}
}
} Several notes: 1.hr = m_psynreader-> open (L "C: // 2.wmv"); read the instructions in wmfsdk9: Hresult open (
Const wchar * Pwszfilename
); Therefore, if it is not compiled in unicode format, you must first convert ANSI to Unicode, For example, convert cstring STR to lpcwstr pcwstr Cstring STR = _ T ("teststr ");
Uses_conversion;
Lpwcstr pwcstr = a2cw (lpcstr) Str); 2. hresult hR = coinitialize (0); for the use of COM, The coinitialize process is required. If it has been initialized before use, you can skip this step.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.