Sharing pixel art as animated gifs on social media sucks. Uploading animated gifs will typically get automatically converted to a video format with blurry results. We can manually do the conversion ourselves to get much nicer results.
ffmpeg -i input.gif -movflags faststart -pix_fmt yuv420p -vf scale=1920:1080:flags=neighbor output.mp4ffmpeg is the command line tool we are using to do the conversion. It can be downloaded from https://www.ffmpeg.org or acquired from various package managers (apt, brew, winget, etc). To perform the conversion we need to provide ffmpeg several command line parameters.
-i input.gifSpecifies which file to use as input. Hereinput.gifis the file we wish to convert.-movflags faststartEnables fast start for online playback.-pix_fmt yuv420pSpecifies output pixel format. Theyuv420pformat is widely compatible with most media players.-vf scale=1920:1080:flags=neighborApplies a filter to video. Here the filter isscale=1920:1080:flags=neighbor. Which scales the output resolution to 1920x1080. The magic bit isflags=neighborwhich indicates to use nearest neighbor scaling. This is exactly what we want for pixel perfect upscaling.output.mp4Specifies name of output file. Hereoutput.mp4is the file we want to get.
blurry.mp4
Blurry upscaling
pixel_perfect.mp4
Pixel perfect upscaling
ffmpeg -i input.gif -movflags faststart -pix_fmt yuv420p -vf scale=iw*3:ih*3:flags=neighbor output.mp4
You can use a little bit of math inside the filter to calculate the output resolution for you. Here scale=iw*3:ih*3:flags=neighbor will scale the original image up by 3x. Where iw is the input image width and ih is the input image height.
The scale filter has quite a few options. You can read about them at FFmpeg Filters Documentation.
thank you!!! I've been looking for this for a while now