I am trying to write an animation (computer graphics, not video) to a WMV file using DirectShow. Setup:
A Push source that uses a bitmap in memory containing an animation frame. Each time FillBuffer () is called, the bitmap image data is copied to the sample, and the sample has a time stamp with the start time (frame number * frame length) and duration (frame length). The frame rate in the filter is set to 10 frames per second.
ASF Writer Filter. I have a custom profile file that sets a video at 10 frames per second. Its video filter, so there is no sound.
The ligaments are connected, and when the graph starts, a wmv file is created. But...
The problem is that DirectShow outputs data from the Push source at a speed of more than 10 FPS. Thus, the wmv result, reproduced and containing the correct animation (as well as a message about the correct FPS), plays the animation several times too slowly, because too many frames were added during recording. That is, a 10-second video in 10 FPS should have only 100 frames, but about 500 are recorded in the video, as a result of the video lasts 50 seconds.
My initial attempt at a solution was only to slow down the call to FillBuffer () by adding sleep () by 1/10 of a second. And it really more or less works. But it seems hacky, and I doubt it will work well at higher FPS.
, . , , , . , FillBuffer() Push Source ?
!