# Animation and File Size

**URL:** <https://discourse.julialang.org/t/animation-and-file-size/82972>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [June 18, 2022, 3:21pm UTC](https://discourse.julialang.org/t/animation-and-file-size/82972 "2022-06-18T15:21:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahmoud](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@Mahmoud](https://discourse.julialang.org/u/Mahmoud)\
**Post date:** [June 18, 2022, 3:21pm UTC](https://discourse.julialang.org/t/animation-and-file-size/82972/1 "2022-06-18T15:21:23Z")

</div>

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

```julia
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)

```

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [June 20, 2022, 2:08pm UTC](https://discourse.julialang.org/t/animation-and-file-size/82972/2 "2022-06-20T14:08:03Z")

</div>

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:

```bash
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](https://github.com/JuliaIO/FFMPEG.jl)

Does this answer your question?

---

<div class="post-metadata">

**Author:** ![Mahmoud](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@Mahmoud](https://discourse.julialang.org/u/Mahmoud)\
**Post date:** [June 20, 2022, 2:31pm UTC](https://discourse.julialang.org/t/animation-and-file-size/82972/3 "2022-06-20T14:31:14Z")

</div>

Yes, thank you  
I did not know about this before

---

<div class="post-metadata">

**Author:** ![Wen-Wei\_Tseng](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wen-wei_tseng/32/28839_2.png) [@Wen-Wei\_Tseng](https://discourse.julialang.org/u/Wen-Wei_Tseng)\
**Post date:** [June 20, 2022, 3:32pm UTC](https://discourse.julialang.org/t/animation-and-file-size/82972/4 "2022-06-20T15:32:35Z")

</div>

You can also try `mp4(anime, "video.mp4", fps = 50)` ([code example](https://sosiristseng.github.io/juliabook-visualization/plotsjl-gallery.html#animations) taken from Pllots.jl)
