How the media bitrate information is obtained in file property

domo 0 Reputation points

The following code to query the video encoding bitrate of a media file (mp4) yields a number that deviates significantly from the value obtained by viewing it with other tools like mediainfo/ffprobe:

#include <windows.h>
#include <shlobj.h>
#include <propvarutil.h>
#include <propkey.h>
#include <iostream>
int main() {
    IShellItem2* pItem = NULL;
    HRESULT hr = SHCreateItemFromParsingName(L"test.mp4", NULL, IID_PPV_ARGS(&pItem));
    if (SUCCEEDED(hr)) {
        PROPVARIANT propvar;
        hr = pItem->GetProperty(PKEY_Video_EncodingBitrate, &propvar);
        if (SUCCEEDED(hr) && propvar.vt == VT_UI4) {
            std::cout << "Video Encoding Bitrate: " << propvar.ulVal / 1024 << " kbps" << std::endl;
    return 0;

User's image


Open source tools mediainfo and ffprobe results are consistent, and the algorithm is known. The question is how Windows gets this bitrate information. I have tried a variety of calculation methods, but still cannot get the results of Windows calculations. I don't know if it's a Windows calculation error, or there is some unique calculation method.

A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
4,725 questions
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,412 questions
{count} votes