Hi unknowplayer,
I tried to run your code a code a really weird result (I was standing still so no motion at all):
Also I’m not sure to get what you are trying to do but I think it is really close to the effect in this thread: Framerate in live video delay project : Ed Tannenbaum, Recollections
You might find some interesting informations here.