Create high-quality GIFs from recorded videos

Prepare everything for sucessfull plex deployment with hardware transcoding

Share on:  
                 

Introduction

Very often I need to embed videos into my documentation or wiki articles. Due the fact that plain MP4 files arent support and even make no sense in a wiki, I needed a solution to have a quick and easy solution. For this we get use of ffmpeg and convert our file from MP4 to GIF. Especially when you want to show high quality videos, you should add a palette as input to improve the output gif.

Installation

First thing to do is install ffmpeg if not already done.

 
C:\Users\numar>winget install gyan.ffmpeg
Found FFmpeg [Gyan.FFmpeg] Version 6.0
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://github.com/GyanD/codexffmpeg/releases/download/6.0/ffmpeg-6.0-full_build.zip
  ██████████████████████████████   150 MB /  150 MB
Successfully verified installer hash
Extracting archive...
Successfully extracted archive
Starting package install...
Command line alias added: "ffmpeg"
Command line alias added: "ffplay"
Command line alias added: "ffprobe"
Path environment variable modified; restart your shell to use the new value.

Generate GIFs

Second point on the list is convert the files, this will create a GIF with defaults.

 
ffmpeg.exe -i digcre.io-video.mp4 digcre.io-video-plain.gif

If you want to go further, you create a palette and add it as another input.

 
ffmpeg.exe -i digcre.io-video.mp4 -filter_complex "[0:v] palettegen" palette.png

ffmpeg.exe -i digcre.io-video.mp4 -i palette.png -filter_complex "[0:v][1:v] paletteuse" digcre.io-video-optimized.gif
  • -i is the input file
  • output file is always the last command

This is the palette file which is a 256 color palette generated from the input video.

alt text

Comparison

Original GIF (11,7KB) Optimized GIF (24,2KB)
alt text
alt text
comments powered by Disqus