Blog
All posts
Abdul Jamjoom
Edited on 11/1/22
Created on November 1, 2022 at 2:41 pm
Edited on November 1, 2022 at 5:35 pm
·
Click to watch narration
Watch narration
6:16
0:00
Improve GIF quality with ffmpeg
0:27
Let's skip straight to the result before diving into the details
The left side is old, right is new. s/o to this post on the pkh blog that offers great insights into this process!
0:28
0:28
So, how did we create GIFs?
We relied on defaults:
- Generic color pallet
- Ordered bayer dithering (cross-hatch pattern)
- Scale to 480
0:55
[GIF internals] Color Pallet
- GIFs support 256 colors
- The standard/default color pallet covers a range of all colors, so it's able to convert any video into a decent GIF
1:18
[GIF internals] Dithering
1:50
How do we create GIFs now with improved quality?
- palettegen → generate a single palette for a whole video stream and save it as a PNG (process frames and generate a histogram of colors)
stats_mode=diff
(focus on the moving object)
- paletteuse → use the generated pallet to approximate and paint the GIF frames
floyd_steinberg
dithering
0:16
Code for generating HQ GIFs
./<file_name>.sh <video_file_name>.mp4
0:22
References
0:08
Have questions or suggestions?
Shoot me a note at abdul@threads.com or DM me on Twitter @abduljamjoom
©2022 Threads, Inc.