How about linking TPaintbox to your video form to your form. In the OnPaint method, you simply draw the next frame onto the paintbox canvas. Now put the TTimer on the form, set the interval to the desired frame rate. In the OnTimer event for the timer just write paintbox1.repaint
This should give you regular frames no matter what else the program does.
For added security, you can increase the frame number in the OnTimer event. Now in the paintbox paint method, you know what frame to draw. This means that you will not skip frames if something else calls the drawing method, as well as a timer - you just recolor the same frame for an additional call to OnPaint.
I use this to select marching ants, although I take it one step further and use a canvas overlay so that I can independently paint the selection and base paintbox canvas to remove the need to repaint the main canvas when the selection changes. This requires API calls, but I think you wonβt need it unless you are making a video with transparent color.
David peters
source share