Re: HELP: Push Source Screen Capture filter
- From: "Mar Kon" <konop11@xxxxxxxxxxxxxx>
- Date: 1 Jun 2006 03:07:24 -0700
Tim Roberts napisal(a):
Ugh. The RIGHT way to do this is to set proper timestamps on the
CMediaSamples that you are sending downstream.
I already do it, but it is not enough for sure. I put Sleep() calls
with specifically calculated numbers and it works fine, as I said, but
only for the case, when no frame is dropped. When the frame gets
dropped, Sleep() waits for the next frame (there is no time to wait for
the dropped frame, neither setting stamps for the dropped, since it
would cause a dramatic chain reaction and eat the whole cpu power). So,
in the end I receive a lower fps, let's say with 49 frames instead of
full 50 (1 dropped frame) in a case of a target 5 fps in a 10 seconds
animation. When there are more dropped frames, I get lower final fps of
course. The higher target fps I set - the lower I get in the output
AVI. Here is the part of a code:
HRESULT CPushPinDesktop::FillBuffer(IMediaSample *pSample)
{
CheckPointer(pSample, E_POINTER);
CAutoLock cAutoLockShared(&m_cSharedState);
this->setTimeStamp(pSample);
/// (....)
m_iFrameNumber++;
// Set TRUE on every sample for uncompressed frames
pSample->SetSyncPoint(TRUE);
return S_OK;
}
void
CPushPinDesktop::setTimeStamp(IMediaSample *pSample)
{
REFERENCE_TIME rtStart = 0, rtStop = 0;
CRefTime currTime;
this->m_pFilter->StreamTime(currTime);
rtStart = currTime;
// fps wait correction
const int FPS = 5;
const double duration = 1.0/FPS;
double oldStartTime = COARefTime(rtStart);
double start = ceil(oldStartTime*FPS)/FPS;
DWORD diff = (DWORD) floor((start-oldStartTime)*1000.0);
Sleep(diff);
this->m_pFilter->StreamTime(currTime);
rtStart = currTime;
rtStop = rtStart + m_rtFrameLength;
pSample->SetTime(&rtStart, &rtStop);
LONGLONG frameStart = m_iFrameNumber;
LONGLONG frameEnd = frameStart+1;
pSample->SetMediaTime(&frameStart, &frameEnd);
}
5) Is it necessary to implement the IAMBufferNegotiation interface on
such Push Source. Some article - I got - says, it's needed. Is it so,
and if yes, how can I implement it?
No. Did you look at the Filters\PushSource sample? It works, and should
answer many of your questions.
Of course I did. I was just asking because the mentioned sample is not
a perfectly finished one.
Thanks
.
- Follow-Ups:
- Re: HELP: Push Source Screen Capture filter
- From: rep_movsd
- Re: HELP: Push Source Screen Capture filter
- Prev by Date: Mux filter
- Next by Date: Re: Buffering video streams
- Previous by thread: Mux filter
- Next by thread: Re: HELP: Push Source Screen Capture filter
- Index(es):
Relevant Pages
|