Let me try another way to illustrate the issue:
These are the mean grey values (as reported by identify -verbose), based on the example data in the gist:
This is when running it on a longer series:
The peaks correspond to the original frames. In an animated sequence they show up as sort of flickering.