Goggen240,
attachments are hidden for users. Please reupload them to
https://postimages.org/
However I don't even try to understand the problem, it looks too complex. I honestly recommend to try solving it with avisynth (also probably there is already some filter or script for your needs)