- How to generate gif from avi using ffmpeg? [closed]
- 2 Answers 2
- How to convert video to GIF in Linux
- How to Convert Video to GIF via Command-line:
- How to Convert Video to GIF Via GUI:
- Conclusion:
- About the author
- Syeda Wardah Batool
- How to Convert Video to GIF in Linux [Terminal and GUI Methods]
- Method 1: Create GIF from Video using ffmpeg in command line
- Method 2: Converting video to GIF using Gifcurry GUI application
- Open and use gifcurry
- A few other Gifcurry Features
- Conclusion
- Debian User Forums
- How to create an animated gif from an avi file.
- How to create an animated gif from an avi file.
How to generate gif from avi using ffmpeg? [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
ffmpeg -i video.avi -t 5 out.gif
It generates an animated gif but the quality is insane. However when I generate gif image using: ffmpeg -i video.avi -t 10 out%d.gif It generates acceptable quality of gif images. How can i generate animated gif using the first command but the same quality as the second command?
2 Answers 2
I had a similar problem trying to generate high quality animated gif from a series of images extracted from a movie.
For some reasons the animated gif generated with ffmpeg only contains 103 colors assumable using a fixed 256 level system color palette resulting in horrific result. My solution was instead
ffmpeg -i video.avi -t 10 out%02d.gif
gifsicle --delay=10 --loop *.gif > anim.gif
Quality is then quite good. You can find gifsicle here
Edit: Updated the post to reflect Alex Kahn’s suggestions.
Thank you! One adustment: use out%02d.gif. This pads the number in the filename so that they are in proper alphabetical order. Otherwise the order ends up being 1,10,11,12,13,14,15,16,17,18,19,2,20,21,22,23. which gives the resulting gif a weird skipping effect.
You could also have ffmpeg output PNGs instead of GIFs to avoid the crappy quality. FWIW, here’s a nice write-up on creating GIFS in Bash: blog.room208.org/post/48793543478
This works great. One thing you might also want to do, is to skip frames: using seq -f %02g.gif start skip stop instead of *.gif in the gifsicle command, you can skip skip frames, starting at start and ending at stop frames. Pretty useful. E.g.: gifsicle —delay=10 —loop seq -f %02g.gif 1 3 156 > anim.gif Will start at frame 1, skip 3 frames and stop at frame 156.
gifsicle looks not working at all. says «gifsicle.EXE: *.gif: Invalid argument» in response to your command
I haven’t made an animated GIF before but you might try using the bit-rate parameter to specify quality, in spite of it being an image (and presumably having no rate). Thumbnail quality responds to the -b parameter. If by insane, you mean, «insanely bad,» you can specify a very high bitrate and bitrate tolerance (not sure if you’re using vbr or cbr source). (or do the opposite if you mean it’s too good and you want to limit size)
Alternatively, you could also change the dimensions using the -s parameter, which will take an ordinary looking representation of the dimensions like «1920X1200».
It really depends on the bitrate and compression of your source material and what you hope the gif will be like. Maybe consider providing more info than «insane,» but I imagine this will give you a good start either way. Good luck
How to convert video to GIF in Linux
While using social media, we always see animated GIFs everywhere. If adding a picture on blogs would tell you 100 words about the story, GIF would come up with 1000 words.
Animated GIFs are used to make the blogs interesting and a great alternative for demo purposes short videos. It is a quick way to display anything that could not be expressed in images, or you don’t need to insert long videos all the time.
GIFs are also used in software documentation and media and make everything a part of the fun.
In this guide, we will see two ways of the conversion of video to GIF in Linux system:
How to Convert Video to GIF via Command-line:
There is a command-line tool, “ffmpeg,” that is popular for video conversion and an audio convertor and could be used in several scenarios.
Here, we will use the “ffmpeg” tool to convert video to GIF.
Before getting started with the tool, we need to install it on the Ubuntu system. So, to get it, run the mentioned command:
Once it is installed, select the video you want to convert and use the following syntax to find the required results:
Keep in mind that your output name could be different from the input name. It’s totally up to you!
Suppose I have a testing video at the “Downloads” directory:
To convert it, the command would be:
After the process has been completed, visit that directory again from where you selected the video, and you will find the GIF file there:
How to Convert Video to GIF Via GUI:
The “Gifcurry” is an amazing open-source tool specifically for GIF-making. It is very easy to convert videos using this application.
What you need to do is follow the steps carefully.
To get this application on the system, download it by copying the given command:
$ wget -O gifcurry.AppImage https: // github.com / lettier / gifcurry / release / download / 6.0.1.0 / gifcurry-6.0.1.0-x86_64.AppImage
To make AppImage dependencies executable, use the following command to install it:
To give access to the tool, type in terminal:
Now, run the “gifcurry” application by searching it from applications, or you can type the following in a terminal:
You will the following window on the screen, click on “Open” to get the interface:
Now, select the video you want to convert from the directory and select the “Open” button from the right bottom of the interface:
Within few seconds, your video will be converted into GIF. Select the “file” to save GIF file in the system:
From the file, select the directory to save the converted GIF file, set the name of the output file text field, and click on the “save” button at the bottom right corner of the interface:
Close the application, and navigate to the directory where you saved the GIF file; you will get your converted video there:
Conclusion:
This write-up shows how to convert video to GIF in Linux using command-line and GUI.
The “ffmpeg” command tool is a quite simple and straightforward way to convert video to GIF files. While using the “Gifcurry” application seems interesting approach.
About the author
Syeda Wardah Batool
I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.
How to Convert Video to GIF in Linux [Terminal and GUI Methods]
Animated GIFs are everywhere on the internet. From blog posts to social media, GIFs can be used in a humorous as well as explanatory way.
Even on It’s FOSS, we use GIFs to show a certain step in action. It is better than still images and shorter than loading a video.
In this tutorial, I will show you how to convert a video clip to GIF. I’ll discuss both:
Method 1: Create GIF from Video using ffmpeg in command line
FFmpeg is a video and audio converter that can also grab from a live audio/video source. It can also resize video on the fly without compromising the quality.
FFmpeg is a powerful tool and can be used for various scenarios, if you are curious here is the official documentation. We also have a good collection of ffmpge usage examples.
In this example, I will use the Linux Mint 20 new feature presentation video. I downloaded the video from YouTube using youtube-dl and then I trimmed the video to get the first 5 seconds.
Make sure to install ffmpeg using your distribution’s package manager:
Once you have selected the video that you want to convert, open your terminal and change directory where your video is saved. Below is a general principle, where input is the actual name of the video, following by the video format and the name that you want your gif to be.
The output name can be something totally different to the input name, but I tend to use something similar, as it helps to identify it when you have a folder full of files.
ffmpeg -i input_video_file output.gif
Press the enter key to execute the command and your gif will be ready shortly.
You should find the GIF file in the same folder as your video file unless you specified some other path for the output file).
Method 2: Converting video to GIF using Gifcurry GUI application
Gifcurry is an open-source, easy-to-use app GIF maker app.
It uses ffmpeg and imagemagick to process video and convert to GIF. It can be used both in command-line and the graphical user interface, although this tutorial will only cover the GUI part.
It can be installed using snap and other package managers, but I recommend using the AppImage because I found some issue with other packages.
Before you attempt to open gifcurry, you need to make sure that the required dependencies are already installed.
Open and use gifcurry
To make an Appimage executable is very straight forward and you grant the permission at the file properties as following:
When you open Gifcurry you will be prompted to navigate to the file that you want to convert and at this example I will use again the initial video. As ffmpeg, Gifcurry is not limited to purely converting videos to gif and vice versa. Some of the features are listed.
A few other Gifcurry Features
At the last step, you have to choose the file name, the file format and click save.
Conclusion
If you are recording your screen in Linux, you may use Peek to record it a gif instead of a video instead of converting the video to gif later.
Either you choose the command line or the graphical user interface, your job will get done lightning fast both ways.
Let me know which way you prefer and feel free to request any further explanation at the comments section.
Debian User Forums
How to create an animated gif from an avi file.
How to create an animated gif from an avi file.
#1 Post by kinematic » 2008-11-30 17:33
Some of you might find it interesting to know how to create an animated gif from an avi file on Linux so here’s how you do it. You need avidemux, mplayer and imagemagick to create the gif.
Let’s start with avidemux, open the avi file and use the A (selection:start) and B (selection:end) buttons at the bottom to select the portion of the file you want to convert and save it (audio and video set to copy) as movie.avi for example in your /home directory.
You now have just the bit you want to convert so it’s time to fire up your terminal and create a directory in wich to create the animated gif and cd to it.
mkdir /home/username/gif && cd /home/username/gif
mplayer /home/username/movie.avi -vo jpeg
-vo stands for video output and jpeg means it will save the frames from the avi file to jpg’s and mplayer will number them sequentially.
Still in your gif directory it’s time to use convert wich is a commandline util supplied with imagemagick. You can resize, enhance, set the time delay and make an infinite loop with one command line. The command to use is
convert -enhance -resize 150x150 -delay 4 -loop 0 *.jpg movie.gif
-enhance is a filter wich as the name suggests will run an enhancing routine on every jpg. -resize is self explanatory, -delay is the amount of miliseconds delay at wich the gif runs (3 or 4 miliseconds is a good starting point), -loop 0 makes it into an infinite loop and * is a wildcard wich basically means convert will look for files with a .jpg extension an use them. Now press enter, let convert do it’s thing and you end up with a high quality animated gif