DirectShow: how to play an interval of frames from an AVI

Started by
2 comments, last by Mari_p 19 years, 5 months ago
Hi, I already worked with Direct3D, but I don't have experience in DirectShow. I would like to play (using DirectShow) intervals of a movie (avi). I used some time functions from DirectShow: put_CurrentPosition and WaitForCompletion. They works, but not perfectly, because the video may not run smoothly. Suppose, for example, that the avi has 1000 frames... How could I play EXACTLY the frames contained in interval [235, 612]? Is there some function like "put frame" instead put_CurrentPosition? Please, could somebody help me? Thanks in advance.
Advertisement
...anybody?
This is in C++, right?

Instead of using the IMediaPosition interface, you can use the IMediaSeeking interface. The three functions you would probably want are SetTimeFormat(), SetPositions(), and GetPositions(). To start at a certain location, use something similar to the following:
void PlaySegment(LONGLONG StartFrame, LONGLONG StopFrame){  pMediaSeeking->SetTimeFormat(&TIME_FORMAT_FRAME);  pMediaSeeking->SetPositions(&Frame, AM_SEEKING_AbsolutePositioning, &StopFrame, AM_SEEKING_AbsolutePositioning);}

*Note that I just realized that you can set the stop time as well. I had previously overlooked that feature, since I had previously not needed it, so I personally have not tried it. But it looks like it'll do what you want, and I might look into using it as well...
"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas only, and not for things themselves." - John Locke
Thank you much, Agony. :)

It was exactly what I wanted. The method works fine (I tried it).

Thanks!

This topic is closed to new replies.

Advertisement