Errors related to creating animations/movies

I have a program to plot 10 maps like the below:

for i in 1:10
    coast...
    grdimage...
    ...
end

My goal is to save them all as a GIF file. So based on the documentation, I would need to wrap them up into a function (f1, in this example), and do something like the below? Then I would be able to find my created movie called abc.gif, with a folder named “abc” storing all of the 10 PNG images?

movie(f1, canvas="15x15x100", name=:abc, frames=360, gif=true, label=:f, progress=true, Vd=1)

Unfortunately, this did not work for me, and I get a lot of errors:

movie main_script.sh -C15x15x100 -Nglobe -Lf -A -P -T360
movie [WARNING]: Main script appears to have a sub-shell call $(...) without the leading $: gmt colorbar  -Bpx+l"Variable (@%Times-Italic%f@%Times-Roman%CO@-2@-, @%Times-Roman%@~m@~atm)" --FONT_ANNOT_PRIMARY=10p,Times-Roman,black --FONT_LABEL=14p,Times-Roman,black -DJBC+w12.5/0.4+o-0.2/0.6 -Cmakecpt  -Cjet -T0/1500/100 -H

Interesting that I do not get the above error related to my colorbar at all, while plotting each of those maps previously, without trying to create a GIF file.

movie [ERROR]: GraphicsMagick is not installed or not in your executable path - cannot build animated GIF.

Sounds like I would need to follow this link to install GrahicsMagick?

It is usually a good idea to read the man pages.
In the one for movie it clearly states under Technical Details:
“The conversion of PNG frames to an animated GIF (-Fgif) relies on GraphicsMagick (http://www.graphicsmagick.org). Thus, “gm” must be accessible via your standard search path. Likewise, the conversion of PNG frames to an MP4 movie (-Fmp4) relies on ffmpeg (https://www.ffmpeg.org).”

1 Like

Afte I install GraphicsMagicK, the first error still holds and the 2nd error is gone. Now I have a new error:

movie_frame.sh: line 10: gmt: command not found

The movie wrapper is a very difficult beast and can’t currently work in many cases. The issue is that, depending on what is requested, GMT may have to generate and execute scripts. And it only knows how to run Windows batch or *nix shell scripts. Not Julia (and other) ones.
Seeing movie_frame.sh: ... message indicates that you likely fell into one of those cases.

But if you generated the images with that loop, you should be able to assemble them in a movie directly with ffmpeg.

1 Like

Joaquim,

This is a very important piece of information! Many thanks for pointing me to the direction of ffmpeg. I’ll check it out soon. Many thanks!

I notice that the GMT.jl documentation only provides a GMT terminal example (instead of a Julia example).

ffmpeg -loglevel warning -f image2 -framerate 24 -y -i "mydir/myimages_%04d.png" -vcodec libx264 -pix_fmt yuv420p mymovie.mp4

I remember you said previously that in order to run GMT commands within Julia, all I need to do is to wrap the whole thing up within GMT("")? Or would I have to run it in a GMT terminal?

What does the %04d.png mean? Is that a way to describe the file names of all the jpg files? If my files names are like the below, I should write it as
mydir/Variable1_%0.jpg?

Variable1_10.jpg
Variable1_20.jpg
Variable1_30.jpg

How could I give a Julia example of using ffmpeg!!!

That is a C formatting string saying the names have a suffix of 4 digits; _0001, _0002, … _9999.png

Please read Introduction · GMT
Monolithic · GMT

1 Like

Got you! Now I know that ffmpeg is actually a 3rd party program, instead of a function of GMT :grinning:

Many thanks!