To follow up previous post with Media Foundation bug, here goes another one related to property handler for MPEG-4 files (.MP4
) and specific property PKEY_Video_FrameRate
 which reports frame rate for given media file.
This is the object responsible for filling columns in explorer, or otherwise visually the bug might look like this:
The values of the properties are also accessible programmatically using IPropertyStore::GetValue
 API, in which case they are:
PKEY_Video_FrameWidth
:Â1280
 (VT_UI4
) //Â1,280
PKEY_Video_FrameHeight
:Â720
 (VT_UI4
) //Â720
PKEY_Video_FrameRate
:Â1091345
 (VT_UI4
) //Â1,091,345
PKEY_Video_Compression
:Â{34363248-0000-0010-8000-00AA00389B71}
 (VT_LPWSTR
) // FourCC H264PKEY_Video_FourCC
:Â875967048
 (VT_UI4
) //Â875,967,048
PKEY_Video_HorizontalAspectRatio
:Â1
 (VT_UI4
) //Â1
PKEY_Video_VerticalAspectRatio
:Â1
 (VT_UI4
) //Â1
PKEY_Video_StreamNumber
:Â2
 (VT_UI4
) //Â2
PKEY_Video_TotalBitrate
:Â12123288
 (VT_UI4
) //Â12,123,288
The actual frame rate of the file is 50 fps. The file is playable well in every media player, so the problem is the reporting itself. Let us look inside the file to possibly identify the cause. The mdhd
 box for the video track shows the following information:
Let us do some math now:
- Time Scale:Â
10,000,000
- Duration:Â
4,501,200,000
 (around 7.5 minutes) - Video Sample Count:Â
22,506
This makes the correct fps of 50 (frames per scaled duration). However the duration number itself is a pretty big one and looks exceeding the 32-bit range. Now let us try this one:
22506 / (4501200000 & ((1 << 32) – 1)) * 10000000
And we get 1,091
. Bingo! Arithmetic overflow in the property handler then…
See also:
- Media Foundation MPEG-4 Property Handler returns incorrect Video Frame Rate on Microsoft Connect (including media sample)
Bonus tool:Â FilePropertyStore
 application which reads properties of the file you drag and drop onto it, Win32
 and x64
 versions.