I have a DirectShow graph with the SampleGrabber filter doing some processing. The processing takes up to 50ms so often the playback speed is slower. The processing can be turned on and off.
My problem is that if the processing has been on for a while, when I turn it off the video plays as fast as possible until it reaches a certain point. Presumably this point is where the frame time matches the stream time and there is no longer any lag.
How can I stop this from happening, so that when I turn processing off playback is at normal speed? Can I turn off the stream clock while processing the data? Or perhaps timestamp the samples coming out of the SampleGrabber filter again, with the extra lag added?
Does anyone know the proper way to do this?
Edit:
I used the method of changing the sample times as shown in the answer below, but had some problems with seeking as well as calculating the sample timestamps.
I found a better way was to implement my own reference clock and to stop the clock if the processing took too long.