Added an option to analyse a small sample of frames to create a single colour palette for the whole gif #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I extended Moments for my own project, and I thought other people might find these changes useful, as I get more stable colours and substantially faster encoding time now.
What Moments does now:
The existing version of Moments creates a new colour palette for every frame in a gif. NeuQuant is computationally expensive, so this makes encoding slow and, more importantly, it can result in "flickering" colours every frame when the NeuQuant operation quantises the colors slightly differently with a moving camera or changing colors on the screen.
What my additions do:
My fork gives Moments the ability to sample several frames from a gif, analyze those frames together with NeuQuant, and create a single color palette that every frame will map to, without further NeuQuant calls.
I've added a "Frames Per Color Sample" field to the inspector, which allows you to sample every n-th frame in a recording for color mapping purposes. If the "Frames Per Color Sample" is set to zero, Moments reverts to its current default behaviour of creating a brand new color palette every frame.
The results:
By setting "Frames Per Color Sample" to 6, for instance, I halved the encoding time for my 5.5 second gifs on Windows and I get rock-solid colours for the duration of my gif, without the frame-by-frame flickering I experienced previously.
BEFORE: (please note the flickering pinks and purples on some objects)

AFTER:
