
Marty Jay helpfully mentions that sameq means same quantizer as in the input, which may not result in the same quality. The last time I transcoded video I used qscale=8.0, but I'd suggest that you experiment to find the optimum to match the quality of your input. The lower the number the better the quality, but the more space your file will take. Alternatively, you may want to use the qscale option to set the quality manually. I hope you can use zetah's suggestion above in his comment and use the -sameq switch. If you must transcode because you need to use a particular video codec codec:copy may be helpful if you don't have a reason to transcode (and it should be faster). Your input will very likely be more blurry if you don't.You always lose a little quality whenever you transcode from one codec to another, video or audio, but perhaps you can avoid it if you only want to change from MP4 container type to an AVI container. It is recommended that you rescale using lanczos or bicubic as they are far superior to bilinear. a scale using lanczos scaler instead of the default (bilinear currently).an adjustment of the frames per second (reduced to 15 can make it visually jerky but will make the final GIF smaller).input.mp4 -vf "fps=10,split palettegen paletteuse" -loop 0 output.gifįilters = "fps=15,scale=320:-1:flags=lanczos"įfmpeg -v warning -i $ 1 -vf "$ filters ,palettegen" -y $ paletteįfmpeg -v warning -i $ 1 -i $ palette -lavfi "$ filters paletteuse" -y $ 2 So a value of 10 will cause the GIF to play 11 times. A value of 0 is infinite looping, -1 is no looping, and 1 will loop once meaning it will play twice. Control looping with -loop output option but the values are confusing.split filter will allow everything to be done in one command and avoids having to create a temporary PNG file of the palette.Also see the Advanced options section below. These filters have many options, so refer to the links for a list of all available options and values. palettegen and paletteuse filters will generate and use a custom palette generated from your input.The lanczos scaling algorithm is used in this example.



A rate of 10 frames per second is used in the example. This example will skip the first 30 seconds (-ss 30) of the input and create a 3 second output (-t 3).Convert MP4 to GIF § With scaling § ffmpeg -ss 30 -t 3 -i input.mp4 -vf "fps=10,scale=320:-1:flags=lanczos,split palettegen paletteuse" -loop 0 output.gif FFmpeg is a suite of libraries and programs for handling video, audio, and other multimedia files and streams.
