How do you reduce the frame rate?  
Author Message
jrc_11





PostPosted: DirectShow Development, How do you reduce the frame rate? Top

How do you reduce the frame rate For example, I am using the ezrgb24 sample directshow filter using graphedit, how do i reduce the frame rate, to for example, only have 50-75% of frames displayed Which parts of the code need to be changed


Software Development for Windows Vista10  
 
 
Michel Roujansky





PostPosted: DirectShow Development, How do you reduce the frame rate? Top

Hi, I think you must be more precise in describing what you want to achieve. Do you actually mean : display only about half of the frames, in half of the original clip duration, resulting in fact in a 100% speed up of the clip Or something else

As you are using EZRGB24, there are two things you can do easily :

1) you can skip a frame by returning S_FALSE in the transform function. Add in_framecount and out_framecount as members of the Filter.

HRESULT CEZrgb24::Transform(IMediaSample *pIn, IMediaSample *pOut){

in_frameount++; // we count all incoming samples

if (somefunction of in_framecount) { return S_FALSE}; // skip if somefunction is true

out_framecount++; // here we count only actually outgoing samples

// now we process the samples

HRESULT hr = copy(pIn, pOut);

......

}

2) you can adjust the sample times by setting the pOut samples start and stop times. In fact, if you skip samples, then you must retime all samples afterwards to make sure they are correctly timestamped for display by the renderer. You should do this in the same transform function after callling the copy function. Use the out_framecount to compute the start and stop times, and set them on the pOut sample using pOut->SetTime();

Typically, you should have :

tStart = out_counter * frameduration; tStop = tStart + frameduration;

You can speed up the display by reducing frameduration.

Hope this helps,



 
 
jrc_11





PostPosted: DirectShow Development, How do you reduce the frame rate? Top

I am thinking more of reducing frame rate to improve CPU performance. I am using an extremely CPU taxing filter, and would like to improve performance by reducing the number of frames processed. I don't mind if the video stream is lagging. I am thinking more of a 'frame eater' - but something which does not 'eat' as many frames as the one directshow provides (code was not supplied) - and you can assign how many frames it actually 'eats'.

 
 
Michel Roujansky





PostPosted: DirectShow Development, How do you reduce the frame rate? Top

This is exactly what my code sample above does : you can define a function that computes for each incoming sample if it gets skipped ("eaten") or processed normally.

For example, to skip one frame out of 3 :

int skipparam = 3;

if ((in_framecount % skipparam) ==0)  {return S_FALSE}; // eat this frame

You can make this function more sophisticated, to eat one frame out of 5, or 4 out of 5, as you want it.

If you want to be able to set the function parameters at runtime then you need to develop a specific interface for this purpose, and also a property page if you want to do it in graphedit.

Do not forget to adjust the timestamps as explained above.