I'm trying to use ffmpeg to reduce the size of GIF images by lowering fps and color palette size. This is the command I use:
ffmpeg -i initial.gif -filter_complex "[0]fps=${fps},split[m][t];[t]palettegen=max_colors=${max_colors}[p];[m][p]paletteuse" output.gif
however, for some reason I'm getting larger files even if I do something as stupid as fps=1, max_colors=4.
here's the initial file: enter image description here
here's what I've got after the transformation: enter image description here
the command was:
ffmpeg -i eglite.gif -filter_complex "[0]fps=1,split[m][t];[t]palettegen=max_colors=4[p];[m][p]paletteuse" output.gif
and the sizes I get are:
-rw-r--r-- 1 work work 15860 Aug 26 11:30 eglite.gif
-rw-r--r-- 1 work work 21395 Aug 28 21:35 output.gif
Here's my ffmpeg version:
ffmpeg version n7.0.2 Copyright (c) 2000-2024 the FFmpeg developers
built with gcc 14.2.1 (GCC) 20240805
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-frei0r --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d --enable-libdrm --enable-libdvdnav --enable-libdvdread --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libharfbuzz --enable-libiec61883 --enable-libjack --enable-libjxl --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libplacebo --enable-libpulse --enable-librav1e --enable-librsvg --enable-librubberband --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-nvdec --enable-nvenc --enable-opencl --enable-opengl --enable-shared --enable-vapoursynth --enable-version3 --enable-vulkan
libavutil 59. 8.100 / 59. 8.100
libavcodec 61. 3.100 / 61. 3.100
libavformat 61. 1.100 / 61. 1.100
libavdevice 61. 1.100 / 61. 1.100
libavfilter 10. 1.100 / 10. 1.100
libswscale 8. 1.100 / 8. 1.100
libswresample 5. 1.100 / 5. 1.100
libpostproc 58. 1.100 / 58. 1.100
-
5The original has lots of solid and easily compressible blocks of colours. Due to the reduced colour palette the processed image has a lot of dithering to approximate similar colours to the original. That dithering means no solid blocks to compress and so compression is worse. Sometimes reducing the palette size is not the best option.Mokubai– Mokubai ♦2024年08月29日 07:27:47 +00:00Commented Aug 29, 2024 at 7:27
-
Convert it to webp or avif, these are newer formats and also accept animation, that would probably result in smaller sizes....Ricardo Bohner– Ricardo Bohner2024年08月29日 07:36:47 +00:00Commented Aug 29, 2024 at 7:36
-
Oh, I was wrong. Got bigger file sizes trying to convert to those formats....Ricardo Bohner– Ricardo Bohner2024年08月29日 08:02:23 +00:00Commented Aug 29, 2024 at 8:02
-
Thank you @Mokubai, looks like this is exactly what's happeningxaxa– xaxa2024年08月29日 08:50:08 +00:00Commented Aug 29, 2024 at 8:50