# Errors related to creating animations/movies

**URL:** <https://forum.generic-mapping-tools.org/t/errors-related-to-creating-animations-movies/2285>\
**Category:** GMT.jl Q&A\
**Tags:** gmt\
**Created:** [November 10, 2021, 9:10am UTC](https://forum.generic-mapping-tools.org/t/errors-related-to-creating-animations-movies/2285 "2021-11-10T09:10:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![leon6j](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@leon6j](https://forum.generic-mapping-tools.org/u/leon6j)\
**Post date:** [November 10, 2021, 9:10am UTC](https://forum.generic-mapping-tools.org/t/errors-related-to-creating-animations-movies/2285/1 "2021-11-10T09:10:52Z")

</div>

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](https://www.generic-mapping-tools.org/GMT.jl/dev/movie/#movie), 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](http://www.graphicsmagick.org/INSTALL-unix.html) to install GrahicsMagick?

---

<div class="post-metadata">

**Author:** ![biggle1856](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/biggle1856/32/3169_2.png) [@biggle1856](https://forum.generic-mapping-tools.org/u/biggle1856)\
**Post date:** [November 10, 2021, 10:22am UTC](https://forum.generic-mapping-tools.org/t/errors-related-to-creating-animations-movies/2285/2 "2021-11-10T10:22:26Z")

</div>

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](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](https://www.ffmpeg.org)).”

---

<div class="post-metadata">

**Author:** ![leon6j](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@leon6j](https://forum.generic-mapping-tools.org/u/leon6j)\
**Post date:** [November 10, 2021, 5:54pm UTC](https://forum.generic-mapping-tools.org/t/errors-related-to-creating-animations-movies/2285/3 "2021-11-10T17:54:11Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [November 10, 2021, 6:56pm UTC](https://forum.generic-mapping-tools.org/t/errors-related-to-creating-animations-movies/2285/4 "2021-11-10T18:56:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![leon6j](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@leon6j](https://forum.generic-mapping-tools.org/u/leon6j)\
**Post date:** [November 10, 2021, 8:14pm UTC](https://forum.generic-mapping-tools.org/t/errors-related-to-creating-animations-movies/2285/5 "2021-11-10T20:14:43Z")

</div>

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).

```auto
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
```

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [November 10, 2021, 10:59pm UTC](https://forum.generic-mapping-tools.org/t/errors-related-to-creating-animations-movies/2285/6 "2021-11-10T22:59:44Z")

</div>

> [@leon6j](#):
>
> I notice that the GMT.jl documentation only provides a GMT terminal example (instead of a Julia example).
> 
> ```auto
> ffmpeg -loglevel warning -f image2 -framerate 24 -y -i "mydir/myimages_%04d.png" -
> 
> ```

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

> [@leon6j](#):
>
> What does the %04d.png mean?

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

> [@leon6j](#):
>
> 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(“”)?

Please read [Introduction · GMT](https://www.generic-mapping-tools.org/GMT.jl/dev/usage/)  
[Monolithic · GMT](https://www.generic-mapping-tools.org/GMT.jl/dev/monolitic/#Monolithic)

---

<div class="post-metadata">

**Author:** ![leon6j](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@leon6j](https://forum.generic-mapping-tools.org/u/leon6j)\
**Post date:** [November 10, 2021, 11:49pm UTC](https://forum.generic-mapping-tools.org/t/errors-related-to-creating-animations-movies/2285/7 "2021-11-10T23:49:19Z")

</div>

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

Many thanks!
