The GIF file format has a colour limitation of 256 colours, so optimisation needs to be done to ensure a good quality output. The script utilises ffmpegs palettegen options to generate a pallete of colours to use in the second pass using the bayer dither option. This is what the pallete PNG file looks like (upscaled from 16x16):
The resulting animated GIF turns out quite nice, this was captured from my Xbox One in the Battlefield 1 beta, the file is 480x260 and 4.3MB at 15 frames per second:
Just a warning, keep the input videos short, GIFs can get very large very quickly.
The script is available on github or copy and paste from below: