Hi,
Does anyone have any good tips or practical experience on controlling the playback rate of video/audio streams?
Using SetRate() doesn't seem to give me reliable (smooth) results, certainly above values of 2.0, and often locks up completely.
Ideally, I need to typical rates of x1, x2, x5, x10 and up to x60. There are some rates I need to support of up to x3600, but I think they won't be very useful.
Dropping frames is perfectly ok, at elevated speeds the functionality is more akin to a video scrubber so loss of information is no real problem.
In addition to simply trying SetRate() I have also experimented with calling SetPositions(...) at a reasonably high rate, and forcing the video to jump further forwards, e.g. for a 5x rate if wallclock elapsed t=1sec, use set positions to put the video to t=5sec, etc. This will result in bursts of x1 playback and periodic jumps; to maintain the illusion i'm having to make the jumps every 100ms, i.e. 4 frames or so. The results are (as expected) not brilliant - there's so much pausing and resuming of the graph to be of much use - also I notice that some videos don't advance very well, do they jump back to a previous keyframe?
Given the experiments so far, my current thoughts lie in the following areas:
1. Implement my own reference clock, based upon returning a system time, but "building in" a rate factor. Not sure this will work too well, I think it will still place a burden on the renderer to process every frame.
2. Create a transform filter that, depending on the required playrate, can discard MediaSamples or pass them on, e.g. for x5 speed, only pass on 1 frame in 5, but re-timestamp the passed-on samples as though they were consecutive.
3. Non-directshow alternatives?
fyi, the video formats I receive are not yet confirmed, but I suspect they will could be AVI (Mpeg4v2) or MPEG-2. They will come with an audio stream aswell.
I look forward to opinions on how to potentially address this?
Regards,
Jason