![]() ![]() -lossy enables lossy compression which reduces the size considerably.-O3 (capital ‘O’) is an optimization level that tries several methods for better compression.Gifsicle -O3 -lossy=100 output_trimmed_enhanced_reduced.gif -o output_gifsicle.gif Run this command to further reduce the size: Further Reducing the Size Using Gifsicle (Optional)Īlthough we have reduced the size of the GIF by reducing the frame rate and scaling down the video, the size can be further reduced by using Gifsicle, a command-line tool for creating, editing, and getting information about GIFs. The values of these two arguments can be tweaked depending on the quality and size of the GIF you need. The height is set to -1 to keep the aspect ratio and will be set automatically.įile sizes before and after reducing frame rate and scaling downįrom the comparison above, it can be noticed that reducing the frame rate and size of the video before converting it to a GIF reduces the size of the GIF significantly from 7.0MB to 1.1MB. scale resizes the video where the first parameter is the width and the second one is the height.fps specifies the frame rate of the output GIF.The palette is generated by adding the following argument to the basic FFmpeg conversion command:įfmpeg -ss 23.0 -t 1.8 -i input.mp4 -i palette.png -filter_complex " fps=10,scale=320:-1 paletteuse" output_trimmed_enhanced_reduced.gif It extracts a color palette of the video by creating a base image and applying all changes as layers on top of the base image. The palettegen filter is a filter that generates a 256-color palette to be used in GIF encoding. Enhancementįrom FFmpeg v2.6 and above, it has two important filters which are very useful in creating a high-quality GIF: palettegen and paletteuse. However, we can use the palettegen and paletteuse filters of FFmpeg to generate a custom palette from the colors in our original video to create a higher-quality GIF. By default, FFmpeg uses a generic 256-color palette for every GIF encoding and doesn’t take into account the colors in the input video. This causes the compression to be less efficient and takes up more space.īesides that, the quality of the GIF is also suboptimal as a GIF file is limited to only 256 colors. H.264, H.265) and only encodes changes from frame to frame, every frame in the GIF file is coded on its own. This is because, unlike the original MP4 video which is usually coded in a lossy format (eg. Even the file size of the 1.8-second GIF (3.8MB) is also larger than the original video which is around 2 minutes long.Ī comparison of the sizes of the input video and the output GIFs ![]() If you compare the size of the original video and the GIF output, you will notice that the file size of the GIF (112MB) is significantly larger than the original video (3MB). However, we will face a couple of issues when converting a video to a GIF using FFmpeg: size and quality. For a better understanding, you may refer to the illustration below:Īn illustration of trimming a snippet from a video Issue The two arguments must be inserted before input -i, and they are dependent on which part of the video you want to convert to a GIF. The command below will convert your video to a GIF and save it in the same folder as the input video:įfmpeg -ss 23.0 -t 1.8 -i input.mp4 output_trimmed.gif
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |