We often see interesting GIF animations in Sina Weibo, QQ, facebook, and twitter. GIF files are smaller than videos and more vivid than static JPG pictures. They are very suitable for funny posts, product demonstrations and functional step demonstrations on the Internet. , so this small tutorial will teach you how to make and convert GIF effect pictures in Ubuntu 16.04 LTS desktop system.
In fact, it is not difficult, just need an Ubuntu 16.04 desktop with FFmpeg installed, and then install ImageMagick, and the tools are ready (the same applies to other Linux distributions).
FFmpeg is an open source audio and video converter, using FFmpeg we can convert and record audio and video files very easily, while ImageMagick is an open source software for creating, editing and merging bitmap images.
Convert video to GIF
Let's start with a simple, first look at how to directly convert video to GIF animation. As mentioned above, first install FFmpeg and ImageMagick (these two tools are available in the official Ubuntu source and can be installed directly):
apt install ffmpeg imagemagick
Tip: As mentioned earlier, after the release of Ubuntu 16.04, the official has recommended to use apt to replace the old apt-get command, and the new features and improvements of Ubuntu 16.04 can be seen in previous articles.
To convert a video to GIF just use the ffmpeg command in the following format:
ffmpeg -ss 00:00:20 -i input.mp4 -to 10 -r 10 -vf scale=200:-1 output.gif
- -ss indicates the starting point
- -i followed by the video file to be manipulated
- -to indicates the end point of the file
- -r frame rate, you can increase this value to output a better quality GIF file
- -vf graphics filter, zoom size of GIF
You can adjust the parameters according to your own needs. After the execution is completed, the video will be successfully converted into GIF.
Merge multiple GIF files
If you want to merge multiple GIFs into one file, it is very simple, just save the files to be merged in the same folder, and then execute the following command:
convert -delay 120 -loop 0 *.gif output.gif
Create an animated GIF from a sequence of JPG images
If you have a static sequence of jpg images, you can easily generate animated GIFs in Linux without having to use an artifact like Photoshop in Windows. Put all JPGs in the same folder first, and then execute the following command in the terminal:
convert -delay 120 -loop 0 *.jpg linux.gif
- -delay 120 means GIF animation speed
- -loop 0 means infinite loop
Original: https://www.sysgeek.cn/create-animated-gif-ubuntu-16-04/
Reprinted from: How to Create GIFs in Ubuntu 16.04