Update animation.jl

Generates a color palette for each frame (instead of each animation) to improve quality, and avoid palette file format issues in FFMPEG 3.4
This commit is contained in:
biggsbiggsby 2017-11-17 10:30:23 +01:00 committed by GitHub
parent acf6e86c0f
commit cf58f3cbf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,10 +71,9 @@ function buildanimation(animdir::AbstractString, fn::AbstractString,
fn = abspath(fn) fn = abspath(fn)
if is_animated_gif if is_animated_gif
# generate a colorpalette first so ffmpeg does not have to guess it # generate a colorpalette for each frame to improve quality
run(`ffmpeg -v 0 -i $(animdir)/%06d.png -vf palettegen -y palette.gif`) palette="palettegen=stats_mode=single[pal],[0:v][pal]paletteuse=new=1"
# then apply the palette to get better results run(`ffmpeg -v 0 -framerate $fps -loop $loop -i $(animdir)/%06d.png -lavfi "$palette" -y $fn`)
run(`ffmpeg -v 0 -framerate $fps -loop $loop -i $(animdir)/%06d.png -i palette.gif -lavfi paletteuse -y $fn`)
else else
run(`ffmpeg -v 0 -framerate $fps -loop $loop -i $(animdir)/%06d.png -pix_fmt yuv420p -y $fn`) run(`ffmpeg -v 0 -framerate $fps -loop $loop -i $(animdir)/%06d.png -pix_fmt yuv420p -y $fn`)
end end