diff --git a/src/animation.jl b/src/animation.jl index 8d3c0341..3b271c28 100644 --- a/src/animation.jl +++ b/src/animation.jl @@ -72,9 +72,11 @@ function buildanimation(animdir::AbstractString, fn::AbstractString, if is_animated_gif # generate a colorpalette first so ffmpeg does not have to guess it - run(`ffmpeg -v 0 -i $(animdir)/%06d.png -vf palettegen -y palette.png`) + # use stats_mode=diff to emphasize changes and avoid bias for static white background + run(`ffmpeg -v 0 -i $(animdir)/%06d.png -vf palettegen=stats_mode=diff -y palette.png`) # then apply the palette to get better results - run(`ffmpeg -v 0 -framerate $fps -loop $loop -i $(animdir)/%06d.png -i palette.png -lavfi paletteuse -y $fn`) + # use diff_mode=rectangle to improve rendering quality and reduce file-size + run(`ffmpeg -v 0 -framerate $fps -loop $loop -i $(animdir)/%06d.png -i palette.png -lavfi paletteuse=diff_mode=rectangle -y $fn`) else run(`ffmpeg -v 0 -framerate $fps -loop $loop -i $(animdir)/%06d.png -pix_fmt yuv420p -y $fn`) end