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

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 and tried to apply the two examples.

So, i type the following codes:

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

and

    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

I have the same problem, I use the following workaround

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

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

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!

you will need a trailing slash like

loadpath = "C:/Users/tiago/"
1 Like

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!

My fault, should be

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.

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