Framerate / timescale is off

Mar 8, 2016 at 5:54 PM
First and foremost, awesome work on this library, and thank you so much for sharing it.

Someone posted an issue and I am experiencing the same thing. I am not sure if you follow the issues listed but noticed you are quick to respond on the discussions so I figured I should follow up here.

The issue is:

I also found it here:

I am using Windows 10. I've tried recording in both MotionJpeg for AVI as well as x264 for mp4.

When I record at 60fps the video will playback extremely quickly and end long before it reaches the duration listed along the seek at the bottom.

If I record at 1 fps the duration seems correct but the playback is choppy due to lost frames.

Any thoughts on why that may be?

Mar 8, 2016 at 8:12 PM
I enabled stats in the x264 codec and see that its options are printing ' fps=25/1 timebase=1/25' regardless of what FPS I pass along.

I pass in 25 fps to match the stats and now the video and audio are in sync but the video still thinks its duration is twice as long as it is. So a 10 second video will have a 20 second seek along the bottom.

Will keep adding more notes as I dig deeper.
Mar 8, 2016 at 10:02 PM
Edited Mar 8, 2016 at 10:03 PM
Here is where I am changing the FPS in the sample just in case there is a better way:
 writer = new AviWriter(fileName)
  FramesPerSecond = 10,
  EmitIndex1 = true,

Mar 9, 2016 at 9:35 AM
As I've replied in the issue, most probably the capturing actually goes at a lower frame rate, it just can't keep pace with requested 60 fps for performance reasons.
I guess the frame rate you see in x264 stats is an option which it uses as a hint to optimize the encoding process. The playback frame rate is written in AVI header, and has nothing with an encoder used.
MPEG4 encoder provided with SharpAvi communicates with x264 (and other MPEG4 encoders) using its V4W wrapper, which does not allow to specify custom options for the encoder. One can implement a video encoder for SharpAvi that communicates with x264 DLL directly and uses its capabilitis at full, giving the best control for performance and quality.
Mar 9, 2016 at 2:50 PM
Got it, thank you so much for the quick response. This is very helpful.

I am hopeful the current performance is good enough. And if not and I need to go down the optimizing mentioned in the issue I'll make a branch and perhaps if written well enough it could be included in your library.