How to convert Webm to Gif in Linux and resize the gif in Linux
I use debian as my daily driver. Its a rock solid linux distribution. In the course of writing articles and howtos, I have had the need to record videos of my phone and post them. A video goes a long way to show and explain how a app works. Its better than writing a 1000 words. The videos that I record in my phone or emulator gets saved as a .webm file. These files are sometimes quite large and I wanted to
- convert them to gif
- scale them down to 50% of their original size. This also reduce their size.
I use two little nifty programs to do this - ffmpeg and gifsicle.
For debian based systems:
$ sudo apt intall ffmpeg gifsicle
Step 1 - convert the
.webm file to
$ ffmpeg -y -i rec.webm -vf palettegen palette.png $ ffmpeg -y -i rec.webm -i palette.png -filter_complex paletteus -r 10 out.gif
rec.webm is the recorded video.
The first command creates a palette out of the webm file.
The second command converts the webm file to gif using the created palette.
Step 2 - now that we have the gif, we will now scale it down to say 25%. This is how its done.
$ gifsicle --scale 0.25 out.gif -o scaled25.gif
out.gif is the output from the step 1.
scaled25.gif is the final output.