Animations - formats other than GIF

I’m currently using Plots to generate graphics, including some animations. The docs make it easy to create animated GIFs but for my purposes I’d prefer an alternate output format such as .mov

Any tips or suggestions on how to do this easily? Is there a way within Plots or some other Julia package?

Thanks for any tips.

1 Like

The answer probably involves ffmpeg, which is how a lot of animations are made. Packages vary as to where and how ffmpeg fits into the tool chain. VIdeoIO provides access. It might depend on how you want to create the image stack which is the input to ffmpeg.

2 Likes

I’m assuming I’ll create frames (images) using Plots and saving each one individually; it sounds like VideoIO can help then turn that sequence of images into a movie.

Is that the “state of the art” package for doing so?

using Plots
gr() 
x = 0:0.01:2*pi
anim = @animate for i in 1:200
    plot(x, sin.(x .+ i / 10.0), legend = false, size = (400,200))
    end every 2 ;
gif(anim,"anim.gif") # then you can also change to  .mp4 or .mov
#gif(anim,"anim.mp4") # this one usually works. If not, 
#then you need to check ffmpeg. 
2 Likes

I’d forgotten I’d seen this somewhere - but I did look at the Plots docs this morning under the topic of animations, and it does not mention any other options than GIF (Animations · Plots). :slight_smile: I’ll try this again, but I have a vague memory of having issues with the generated mp4 files (wouldn’t play on my system or something).

Here is an example how to invoke ffmpeg manually to get other outputs.

1 Like

I had to move away from this was for a few days, but I wanted to reply - thanks for the examples.

I’d hoped to avoid manual ffmpeg invocation, but it is an option too!

Gifski is very efficient to create gifs from png files. You could also use the ImageOptim web service via HTTP.jl to transform gifs to more efficient video files.