Re: Is my AvgTimerPerFrame calculation correct?



El Bobo Libre wrote:

In the WMVIDEOINFOHEADER structure, the AvgTimePerFrame
is described as the "desired average time per frame in
100-ns units."

So, is supposed to mean the duration of each frame?

Yes.

If so, is this calculation correct for a 30 fps video
stream?

AvgTimePerFrame = 333333; // (1/30) * 10,000,000

Or, more precisely:

AvgTimePerFrame = 333667; // (1/29.97) * 10,000,000

It's correct.

Second (bonus) question:

If I am writing pre-compressed samples to the Writer
object (from a third-party codec,) how much of the
WMVIDEOINFOHEADER structure and the BITMAPINFOHEADER
sub-structure do I really need to fill-in? Are there any
members that I can/should omit?

You need to fill-in everything your third-party codec
requires. This usually means

VIDEOINFOHEADER::rcSource = (0,0)-(width,height)
VIDEOINFOHEADER::rcTarget = VIDEOINFOHEADER::rcSource
VIDEOINFOHEADER::AvgTimePerFrame
BITMAPINFOHEADER::biSize = sizeof(BITMAPINFOHEADER)
BITMAPINFOHEADER::biWidth = width
BITMAPINFOHEADER::biHeight = height
BITMAPINFOHEADER::biPlanes = 1
BITMAPINFOHEADER::biBitCount = depends on codec (usually 24
or 0)
BITMAPINFOHEADER::biCompression = codec's FOURCC
BITMAPINFOHEADER::biSizeImage = depends on codec (usually 0
or biWidth*biHeight*biBitCount/8)

Set everything else to 0.

--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// a dot angeli at psynet dot net


.



Relevant Pages

  • Re: Is my AvgTimerPerFrame calculation correct?
    ... In the rcSource and rcTarget members, ... If the frame size is 352x240, ... // Alessandro Angeli ... // a dot angeli at psynet dot net ...
    (microsoft.public.windowsmedia.sdk)
  • Re: Convert sampling rate
    ... a 20 ms frame contains 320 samples of type "short". ... I need to downsample the data into 8000Hz inside my C++ ... // Alessandro Angeli ... // a dot angeli at psynet dot net ...
    (microsoft.public.win32.programmer.mmedia)
  • Re: Temporal number in the decoder
    ... Before we start to decode a frame, I need to know when to ... display this. ... // Alessandro Angeli ... // a dot angeli at psynet dot net ...
    (microsoft.public.windowsmedia.sdk)
  • Re: Retreiving video frame size?
    ... Either I'm blind or the only way I can find in this SDK ... the frame size if it is stored in the metadata (via the ... // Alessandro Angeli ... // a dot angeli at psynet dot net ...
    (microsoft.public.windowsmedia.sdk)
  • Re: Only one complete video frame data per MediaSample?
    ... "Alessandro Angeli" wrote: ... MediaSample could contain partial data of a video frame ... Will the obtain "Uncompressed RGB or YUV video" in its MediaSamples? ...
    (microsoft.public.win32.programmer.directx.video)