I have a video file and I have successfully extracted the average frameRate and duration:
UINT64 frameRate = 0;
mediaType->GetUINT64(MF_MT_FRAME_RATE, &frameRate)
PROPVARIANT prop;
m_pReader->GetPresentationAttribute(MF_SOURCE_READER_MEDIASOURCE,
MF_PD_DURATION, &prop);
double duration = prop.hVal.QuadPart / 1e7;
Now I am simply calculating the number of frames:
frameCount = duration*frameRate
And I compare it with the actual number of samples by iterating over them:
realFrameCount = 0;
while(true)
{
m_pReader->ReadSample(
MF_SOURCE_READER_FIRST_VIDEO_STREAM,
0, &streamIndex, index. &flags, &llTimeStamp, &videoSample);
if (flags & MF_SOURCE_READERF_ENDOFSTREAM)
break;
realFrameCount++;
}
In some cases, I get an exact match, but for some files, I do get it within a small difference.
My question is: Is there a way to get exact number of frames without iterating over all samples?
Thanks