How to Get Higher Quality Gifs with Python and FFMPEG
programming·@makerhacks·
0.000 HBDHow to Get Higher Quality Gifs with Python and FFMPEG
 One of the things that lets a gif down is obvious dithering. We can mitigate this by pre-processing the palette, then using it in the subsequent gif to find the best match rather than overplay our dither hand. Take our [previous Python code](https://steemit.com/python/@makerhacks/how-to-create-animated-gifs-with-python) and tweak it thus: ``` # output the result os.system('ffmpeg -framerate 24 -i frames/%03d.png -c:v ffv1 -r 24 -y out.avi') os.system('ffmpeg -y -i out.avi -vf palettegen palette.png') os.system('ffmpeg -y -i out.avi -i palette.png -lavfi paletteuse out.gif') ``` What we do here is take the AVI and extract a palette, which will look like this:  Then we use that palette to generate the gif. You can see the difference here is subtle unless you zoom in:   But! you might find the higher quality *palette* version is smaller in file size!  <hr> https://cdn.steemitimages.com/0x0/https://cdn.discordapp.com/attachments/383256479056134146/446022370608676864/makerhacks.png
👍 makerhacks, fitim, steemitgifts, pjo, theuxyeti, waphilip, earthnation-bot, fucktime, aboutcoolscience, bunnypuncher, share4every1, docsweettooth, taukproung85, cryptokraze, tpvoter1, spectrumecons, minnowbooster, snowflake, someonewhoisme, cheftony, fractalnode, transcendingman, bhuz, anotherjoe, timm, thecrazygm, mitrin, escapeamericanow, fortinbuff, expat, expatembassy, unmesh, kacperkwc, dobryborowik, calmacs, stranded, kamrankhan900, kupel, gradzio, steemitlotteries, steemabuse, unimelb, lauramarielis, rawpride, coincussion, sbi3, joeyp978, dmxmaster, jangossens, qam2112, resteem.bot, voyeger, fitofanka, wombatbreeder, constantcrypto, ash, scaredycatguide, lennstar, cikxaijen, flurgx, wix, greengreen, woodywood143, melbookermusic, eloyibarra, rbreauxfl, jemakaje, ontheway2017, dalethewhale, inceptionally, luna33, malekalmsaddi, ccsbot, cnfund, peskov, zymer, hashing247.com, hmushtaq, cryptoeater, amitraj, bestgift, cookit, chasechiro, la4life, synace, stevenmosoes, inmylife, steem-plus, beastlybanter, gallop, arnel, dugan, arqetype, gyeryak, imp.unity, readrun, dshelton32, sergey44, chey, xaero1, geekpowered, letsawesome, keno1234, howo, drmake,