Animation and File Size

this code generates error and I know why
Is there a way to get over it
I need to animate each 100 steps because the file size reach 1GB with each step animation
How to generate animation with small file size given that there are 6 thousands frames in total

anime = @animate for ist in 1:Nsteps
        if (ist%100 == 0)
            scatter([Person[i]["x"] for i in 1:Npopulations], [Person[i]["y"] for i in 1:Npopulations],legend=false, color = [Person[i]["color"] for i in 1:Npopulations])
        end
end
    gif(anime, "E:\\0.9prob.gif", fps = 50)

I guess you cannot use a .gif file with 6000 frames… This is not what the .gif format was ment for.

You can save the images as .png and create a video with high compression out of it using ffmpeg.

Example:

ffmpeg -r:v 20 -i "video%06d.png" -codec:v libx264 -preset veryslow -pix_fmt yuv420p -crf 10 -an "video.mp4

This example assumes that the .png file names look like this:
video000000.png video000001.png etc

So you first need to save them in this format.

This package might help: GitHub - JuliaIO/FFMPEG.jl: Julia Package for the FFMPEG builder binaries

Does this answer your question?

2 Likes

Yes, thank you
I did not know about this before

You can also try mp4(anime, "video.mp4", fps = 50) (code example taken from Pllots.jl)

1 Like