# Having problems with creating animations with Plots.jl - GRBackend - Juno

**URL:** <https://discourse.julialang.org/t/having-problems-with-creating-animations-with-plots-jl-grbackend-juno/21876>\
**Category:** Visualization\
**Tags:** plots, gr, animations\
**Created:** [March 14, 2019, 4:25pm UTC](https://discourse.julialang.org/t/having-problems-with-creating-animations-with-plots-jl-grbackend-juno/21876 "2019-03-14T16:25:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tiago](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tiago/32/22567_2.png) [@tiago](https://discourse.julialang.org/u/tiago)\
**Post date:** [March 14, 2019, 4:25pm UTC](https://discourse.julialang.org/t/having-problems-with-creating-animations-with-plots-jl-grbackend-juno/21876/1 "2019-03-14T16:25:44Z")

</div>

Hello!

I am trying to create a simple animation in 1D, using the Plots.jl with GR as a backend.

Basically, I have a matrix where the rows are the solution u at a time instant. What I was trying to do was to plot the evolution of my solution along time.  
For that I checked the website: [Plots.jl/animations](https://docs.juliaplots.org/latest/animations/) and tried to apply the two examples.

So, i type the following codes:

```julia
@gif for i=1:n
        plot(x,u_sol[i,:])
     end every 10

```

and

```julia
    anim = @animate for i=1:n
        plot(x,u_sol[i,:])
    end
    gif(anim, "/tmp/anim_fps15.gif", fps = 15)
    gif(anim, "/tmp/anim_fps30.gif", fps = 30)

```

In either cases I got this error:  
**IOError: could not spawn `ffmpeg -v 0 -i 'C:\Users\tiago\AppData\Local\Temp\jl_289C.tmp/%06d.png' -vf palettegen=stats_mode=diff -y 'C:\Users\tiago\AppData\Local\Temp\jl_289C.tmp/palette.bmp'`: no such file or directory (ENOENT)**

I don’t know exactly if I need to install or define something on Juno.  
Does anyone had the same or similar problem? Help is welcome.

Cheers,  
Tiago

---

<div class="post-metadata">

**Author:** ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)\
**Post date:** [March 14, 2019, 4:40pm UTC](https://discourse.julialang.org/t/having-problems-with-creating-animations-with-plots-jl-grbackend-juno/21876/2 "2019-03-14T16:40:45Z")

</div>

I have the same problem, I use the following workaround

```julia
loadpath = # path to where plots should be stored
animation = Animation(loadpath,String[])
for i=1:n
        p = plot(x,u_sol[i,:])
        frame( animation, p )
end
name_of_gif = # name of file.gif
run(`ffmpeg -framerate 15 -i $loadpath"%06d.png" $name_of_gif`) # run this in the REPL, it will hang indefinetly, if the gif already exists

```

when you already go this road I would recommend to use a better format for the video like for example `.mp4` with

```julia
run(`ffmpeg -framerate 15 -i $loadpath"%06d.png" -vcodec libx264 -crf 25 $name_ending_in_mp4`)

```

---

<div class="post-metadata">

**Author:** ![tiago](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tiago/32/22567_2.png) [@tiago](https://discourse.julialang.org/u/tiago)\
**Post date:** [March 14, 2019, 11:03pm UTC](https://discourse.julialang.org/t/having-problems-with-creating-animations-with-plots-jl-grbackend-juno/21876/3 "2019-03-14T23:03:37Z")

</div>

Thank you for the help! But didn’t work with me, it throws this error:

**ERROR: IOError: could not spawn `ffmpeg -framerate=15 -i C:/Users/tiago%06d.png teste.gif`: no such file or directory (ENOENT)**

I did a quick search and I saw that I must install ffmpeg in my computer. Did you had to install too?

**UPDATE** : I installed now ffmpeg but the error is the same.  
I had problems to put my path in a string, but I think I did it right:  
`loadpath = "C:/Users/tiago"`, the slash i think is correct!

---

<div class="post-metadata">

**Author:** ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)\
**Post date:** [March 15, 2019, 10:22am UTC](https://discourse.julialang.org/t/having-problems-with-creating-animations-with-plots-jl-grbackend-juno/21876/4 "2019-03-15T10:22:11Z")

</div>

you will need a trailing slash like

```julia
loadpath = "C:/Users/tiago/"

```

---

<div class="post-metadata">

**Author:** ![tiago](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tiago/32/22567_2.png) [@tiago](https://discourse.julialang.org/u/tiago)\
**Post date:** [March 18, 2019, 6:11pm UTC](https://discourse.julialang.org/t/having-problems-with-creating-animations-with-plots-jl-grbackend-juno/21876/5 "2019-03-18T18:11:51Z")

</div>

> [@BeastyBlacksmith](#):
>
> run(`ffmpeg -framerate=15 -i $loadpath"%06d.png" -vcodec libx264 -crf 25 $name_ending_in_mp4`)

Oh yes! Of course, you’re right.  
Now I tried and I had a problem with the attribute `-framerate`, it says:

**Unrecognized option ‘framerate=15’.  
Error splitting the argument list: Option not found  
ERROR: failed process: Process(`ffmpeg -framerate=15 -i C:/Users/tiago/%06d.png -vcodec libx264 -crf 25 teste.mp4`, ProcessExited(1)) [1]**

So, I deleted the `-framerate` attribute and it worked “fine”. I couldn’t get any gif, instead of a gif saved every plot as a png file in the destination folder. I installed ffmpeg in my computer, I don’t know if it was supposed to.

For a workaround I can, manually, do the gif by my own but it’s just a bit annoying!

---

<div class="post-metadata">

**Author:** ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)\
**Post date:** [March 19, 2019, 9:20am UTC](https://discourse.julialang.org/t/having-problems-with-creating-animations-with-plots-jl-grbackend-juno/21876/6 "2019-03-19T09:20:56Z")

</div>

My fault, should be

```julia
run( `ffmpeg -framerate 15 -i $loadpath"%06d.png" -vcodec libx264 -crf 25 $name_ending_in_mp4` )

```

if it still errors, try `-r` instead of framerate. The `.png` files are created by the `frame` command, from these the `.gif` is build via the call to `ffmpeg`.

---

<div class="post-metadata">

**Author:** ![tiago](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tiago/32/22567_2.png) [@tiago](https://discourse.julialang.org/u/tiago)\
**Post date:** [March 21, 2019, 3:41pm UTC](https://discourse.julialang.org/t/having-problems-with-creating-animations-with-plots-jl-grbackend-juno/21876/7 "2019-03-21T15:41:19Z")

</div>

> [@BeastyBlacksmith](#):
>
> run( `ffmpeg -framerate 15 -i $loadpath"%06d.png" -vcodec libx264 -crf 25 $name_ending_in_mp4` )

Oh now worked perfectly!  
Thank you so much for the help!!
