Applying an offset to timestamp prevents smooth playback



Hi,

I've developped for experimental purposes a transform filter (inherits from
CTransformFilter) which accepts anything as input, output the same format
as its input and choose the same buffer for its output as the one used for
its input. Its Transform method simply makes a identical copy of given
media sample. In other words, it's a do-nothing filter.

I've tried it in GraphEdit:

Live video capture from webcam -> my do-nothing filter -> Color Space
Converter -> Video Renderer

It works perfectly, that is, it does nothing. The video plays back smoothly
in real-time at 30 frames/sec.

Now, it'd like to delay the video playback by one second. So in the
Transform i've used the IMediaSample::GetTime() and IMediaSample::SetTime()
methods to add one second to the start and end times of the output
MediaSample. When i try that in GraphEdit, the video starts playing one
second later which seems to indicate that my trick worked. But instead of
playing smoothly, it "jumps". 2 or 3 frames play properly then it freezes
for a second or so then another 2 or 3 frames play and so on.

Would anubody knows what's going on here?

Here is what i've tried to do to solve this problem:
1) Checked that the timesptamps were set properly. They are. I can see that
they are identical to the original timestamps but offset by one second.
They are all contiguous.

2) Thought that the problem might be due to the renderer running out of
buffers to store the delayed frames so i've increased the number of buffers
in my DecideBufferSize() method to 30 (30 frames/second) naively thinking
that the frames would stay there until the renderer could process them. No
luck, didn't change anything.

3) Checked how many times per seconds my Tansform method was called. When
it don't play with the timestamps, it's called 30 times per second as
expected. When i modify the timestamps, it only gets called 2 or 3 times
per second so it seems that the whole graphs is slowed down by the renderer
somehow. I would have thought that increasing the buffers in my filter
would take care of that but it doesn't.

I would appreciate any help on this matter. The ultimate goal would be to
do some audio/video synchronization so i need to be able to delay the video
until the audio is there.
.



Relevant Pages