Sign in to follow this  
Mari_p

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

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this