locked
Incorrect duration of a WMV file returned by IWMHeaderInfo3::GetAttributeByName(/*...*/, g_wszWMDuration, /*...*/) RRS feed

  • Question

  • Hello!

    I'm trying to find the duration of a WMV file without actually playing it.  This is currently in C++ using the Windows Media SDK.  The problem is that when I get the duration attribute from the IWMHeaderInfo3 structure it returns a duration that's longer than the generated video... The details:

    I have a WMV of 113 frames generated at 30fps (3.766666s) using After Effects with the WMV9 encoder.  However, when calling GetAttributeByName specifying the duration I get a value close to 4.233333s.  Dividing the time by the average frame time (WMVIDEOINFOHEADER::AvgTimePerFrame) gives me 127 frames.  But, when I play back the video it only plays until frame 113.

    I am at a loss as to why this is happening.  Any help would be greatly appreciated.

    Thanks!

    Note: I'm currently using this example to reproduce this: http://www.codeproject.com/Articles/18708/Reading-WMV-ASF-WMA-windows-media-Files

    Sunday, November 11, 2012 3:53 AM

All replies

  • So, apparently After Effects doesn't write the correct duration in the header when generating a WMV.

    In order to work around this issue I fetch the g_wszWMNumberOfFrames attribute from the video stream.

    Monday, November 12, 2012 6:32 PM