http://giflib.sourceforge.net/whatsinagif/index.html

http://giflib.sourceforge.net/whatsinagif/bits_and_bytes.html


https://gif.ski/ gifski 可以从视频生成高质量的 gif


浓缩的才是精华:浅析 GIF 格式图片的存储和压缩 https://cloud.tencent.com/developer/article/1004763

用av1视频替代 gif https://www.singhkays.com/blog/its-time-replace-gifs-with-av1-video

“Replace animated GIFs with video for faster page loads” : https://web.dev/replace-gifs-with-videos/

https://web.dev/efficient-animated-content/

http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html

每帧一个调色板,就可以消除噪点。 https://medium.com/@Peter_UXer/small-sized-and-beautiful-gifs-with-ffmpeg-25c5082ed733

if 本身的算法比较古老压缩率低下,和 h264/h265/vp9 之类的编码算法是没法比的,比如用 h264/VP9 mp4/webm 视频代替 gif,大概可以压缩到原大小的 1/5 ~ 1/10

“Replace animated GIFs with video for faster page loads” : https://web.dev/replace-gifs-with-videos/

《页面加载性能之video替换GIF》: https://www.bilibili.com/read/cv6905954

“用av1视频替代 gif " https://www.singhkays.com/blog/its-time-replace-gifs-with-av1-video


gifsicle https://www.lcdf.org/gifsicle/

查看 gif 文件结构:

1
gifsicle -I input.gif
1
gcc -pthread -DHAVE_CONFIG_H quantize.c merge.c optimize.c gifunopt.c gifwrite.c gifsicle.c clp.c support.c giffunc.c xform.c gifread.c fmalloc.c  -I ../include/ -I ../ -lm
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# gcc -pthread -DHAVE_CONFIG_H quantize.c merge.c optimize.c gifunopt.c gifwrite.c gifsicle.c clp.c support.c giffunc.c xform.c gifread.c fmalloc.c  -I ../include/ -I ../ -lm

function scale(){
    input=$1
    time ffmpeg -hide_banner -y -i $input -b 568k -r 20 -vf 'fps=20,scale=w=162:h=-1:flags=lanczos,palettegen '  ${input}.palettegen.png
    time ffmpeg -hide_banner -y -i $input -i ${input}.palettegen.png -r 15 -lavfi 'fps=15,scale=w=162:h=-1:flags=lanczos[x];[x][1:v]paletteuse' $2
    rm -f ${input}.palettegen.png
}

time ffmpeg -threads 1   -hide_banner  -y -i 987.gif  -vf 'scale=w=162:h=-1:flags=lanczos '  987.gif.162.lanczos.gif

scale 987.gif 987.gif.162.palettegen.gif

gifsicle 987.gif  --resize 162x_ -o 987.gif.162.gifsicle.gif


#ffmpeg  -y -i 987.gif -filter_complex "[0:v] fps=15,scale=w=720:h=-1,split [a][b];[a] palettegen=stats_mode=single [p];[b][p] paletteuse=new=1" avengers3.gif
#ffmpeg  -y -i 987.gif -filter_complex "[0:v]scale=w=162:h=-1,split [a][b];[a] palettegen=stats_mode=single [p];[b][p] paletteuse=new=1" 987.gif.162.ffmpeg_single.gif

ffmpeg  -y -i 987.gif -filter_complex "[0:v]scale=w=162:h=-1:flags=lanczos,split [a][b];[a] palettegen=stats_mode=single [p];[b][p] paletteuse=new=1" 987.gif.162.ffmpeg_single.gif

time convert 987.gif  -resize 162x1620 987.162.gif