OK, I just made an interesting discovery - while the glitchy frame isn't there when playing the lossless file in a media player, it is there in the script preview in AvsPmod. Which on one hand is a relief in that it's not just some random glitch, so that if I delete/replace the frame in the script, no other thing like that should happen but on the other hand it's very weird.
Edit: actually when playing the lossless file in MPC, the frame simply isn't there and After Effects crashes on that frame in the lossless file. How do I add a BMP picture into the script to replace that one frame?