Re: HELP: Push Source Screen Capture filter

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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

.



Relevant Pages

  • Re: Androcles and draper.
    ... When Sam and Joe carry a 32 ft ladder between them at 3 fps and the ... frame. ... It doesn't matter how pretty the math is, it is fiction. ...
    (sci.physics)
  • Re: JTs Stumpers
    ... Would be nice to see some relativists calculate fps of transmissions ... within restspace of ... Let there be a one-dimensional inertial frame of reference S. ... A's transmission wrt A, A's reception wrt A, B's ...
    (sci.physics)
  • Re: JTs Stumpers
    ... Would be nice to see some relativists calculate fps of transmissions ... Within restspace two objects A and B is located 300 000 meter ... special theory of relativity, or SRT. ... Let there be a one-dimensional inertial frame of reference S. ...
    (sci.physics)
  • Re: JTs Stumpers
    ... Would be nice to see some relativists calculate fps of transmissions ... Within restspace two objects A and B is located 300 000 meter ... Let there be a one-dimensional inertial frame of reference S. ...
    (sci.physics)
  • JTs Stumpers
    ... Would be nice to see some relativists calculate fps of transmissions ... Let there be a one-dimensional inertial frame of reference S. ... So the rate in A-time of B's receptions is 1.10 spf ...
    (sci.physics)