How to make a GIF from Video file using FFMPEG

Converting video to GIF is easy and free. In this post, we will create a GIF file from a view on windows pro laptop. We will be using “FFMPEG” for creating GIF files. Note that FFMPEG is a vast tool and has many options to deal with media files. Therefore, we will only see the GIF creation to keep this post short and simple. 

 

Installation on Ubuntu or WSL:

sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install ffmpeg
Syntax to generate the GIF file:
ffmpeg -ss 2 -t 60 -r 100 -i 'input_video.mp4'  -vf "fps=10,scale=1024:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif
Now let’s break down the command:
  • -i input_video.mp4: Input video used for GIF conversion.
  • -ss 2: Skip the first 2 seconds of the video for GIF
  • -t 60: Transform 60 seconds of view into GIF
  • -r 100: The speed does the GIF. This will make GIF run fast if a higher value is used. 
  • fps=10: Frames per second, the more the value, the bigger the file sizer. Higher the quality. 
  • scale=1024: Control the resolution of the output. 
  • -loop 0: Infinite loop the GIF (if 1 is used, GIF will loop once if 2 is used, GIF will loop twice if -1 is used, no looping)
  • output.gif: The output file. 
 Example:
FFmpeg GIF conversion

Note: Note that, I have used -hide_banner -loglevel error to minimize the output on the screen. It’s optional. 

0 0 votes
Please, Rate this post
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
Scroll to Top