Problem with CameraDevice frame rate varying

I have a USB iSight camera which slows down its frame rate depending on the light level (same as is happening here: 

On Windows, CameraDevice::startRecordingToFile() is not taking account of this varying rate, so the resulting video plays too fast.

I'm happy to delve into the problem myself, but I'm not familiar with DirectShow - any ideas how to fix the frame rate, or maybe insert a rate converter in the filter graph?





It should be recording a VBR file... Are you sure that it's the recording that's wrong, and not your video player that's failing to replay it with the correct timings for each frame?

Do you mean variable bit rate or variable frame rate?  It's wrong with all players I've tried.  Here is what VLC Media Player says:

Stream 0
    Type: Video
    Codec: Windows Media Video 9 (WMV3)
    Language: English
    Resolution: 320x240
    Frame rate: 30.000030
    Decoded format: Planar 4:2:0 YUV

The actual frame rate (watching via CameraDevice::addListener()) is more like 12 fps, but varying.

I did mean variable frame rate - I thought that DShow would create a file with variable frame lengths. But TBH I don't know much about DShow either..