After investigating a little more, I noticed a pattern. I think the movie is resetting the game at my save states. When I enter another room in the game, I save a state to slot 0 in the middle of the loading screen. So if the game is resetting at the last state I saved, then that would explain why it happened so often in the loading screen. But just now, the game reset on state 8 which is prior to the state I saved last to slot 9, both of which are in the middle of a boss fight. Except when I go and rerecord that part and play back the movie, it plays back the entire movie without resetting. So it's a little inconsistent, but could there be some sort of glitch in the emulator's state saves? I also return to the question, does anyone know any way to stop this from happening?
Edit:
I looked at the movie file again and noticed that there is a line that's different from all the others. I can easily figure out what lines represent the frames in the movie. What I've noticed is that the second character in each of those lines is a 0 except the first line, which is 2. I scrolled down all the way to the bottom, and noticed that there is a 2 instead of a 0 on my last button input, which was Y. So I decided to just push random buttons and see what happens with that number and this was the result:
|2|........Y....000 000 0|
|0|.............000 000 0|
|2|...U.........000 000 0|
|0|.............000 000 0|
|0|.L...........000 000 0|
|0|.............000 000 0|
|0|..D..........000 000 0|
|0|.............000 000 0|
After testing I can tell that the number is basically a reset code. But I still don't understand why it's assigning a reset code to random button inputs. I can just go into the file and edit it myself, but that's tedious and I would have to stop recording the movie just so I can see the latest button inputs, because np++ doesn't show them all while the file is being recorded in the emulator.