Sample time passed to IWMWriter RRS feed

  • Question

  • This is the first time I've worked with any kind of video encoder, so I may just have a bit of theory wrong, but it seems like the value I'm calculating for the cnsSampleTime parameter of IWMWriter::WriteSample is incorrect. Everything about the resulting WMV file is fine, except for the fact that the video stream is slightly slower than it should be.

    I'm calculating cnsSampleTime as follows...

    	// LONGLONG llPerformaceFreq, initialised with QueryPerformanceFrequency when recording begins.
    	// LONGLONG llStartTime, initialised with QueryPerformanceCounter when recording begins.
    	LONGLONG llPerformaceCount;
    	QWORD cnsSampleTime = (QWORD)((DOUBLE)(llPerformaceCount - llStartTime) / llPerformaceFreq * 10000000.0);

    If I multiply cnsSampleTime by a further 1.2, the timing seems to be correct. The samples are not coming from a capture device (they're actually Direct3D surfaces, which I'm encoding into a video as they're rendered in real-time; think game recorder), so they don't have a sample time coming with them, which is why I'm calculating it like this.

    Any help would be greatly appreciated!


    Thursday, March 29, 2012 1:37 AM