How to export animation via gmic cli [SOLVED]

Just as title said. I would like to export to a video specifying frame rate. Right now, I created an animation by splitting z-axis and export the png file, and then combine them into apng, but file size is too big. I did tried to look for documentation on this, but had not found it.

If you have ffmpeg installed, then you should be able to write something as:

$ gmic sp lena animate blur,0,10,10 o out.mp4

On my linux:

$ gmic sp lena animate blur,0,10,10 o toto.mp4
[gmic]-0./ Start G'MIC interpreter.
[gmic]-1./ Input sample image 'lena' (1 image 512x512x1x3).
[gmic]-1./ Compute animated version of filter 'blur', from parameters 0 to 10 with 10 frames.
 > Animate image [0] : Frame 10/10    
[gmic]-10./ Output images [0,1,2,(...),7,8,9] as mp4 file 'toto.mp4', with 25 fps and (default) codec.
[gmic]-10./ End G'MIC interpreter.

Another solution would be to compile gmic.exe with the OpenCV support, that allows saving video files as well, but this is a pain to make it work under Windows.

Change settings? E.g., compression method.

I just installed it, but it doesn’t work. I even added it to path.

I want this to work:

$ pal pear36 500,500,500 rep_markus_lyapunov_fractal[-1] abc,50,3,100%,50%,50%,50%,[-2],0 rm.. o animation.mp4

Basically, it should give me something like this:

-output to video containers takes image sequences as input, 500 single-slice images, not one image with a z-depth of 500 slices. Consider inserting -split. z before o animation.mp4.

Sorry - time constraints led me to experiment with a pretty tiny sequence, just for demonstration purposes:

gmic pal pear36 180,100,50 rep_markus_lyapunov_fractal[-1] abc,50,3,100%,50%,50%,50%,[-2],0 rm.. s. z o animation.mp4

animation.mkv (52.7 KB)

Hope this helps.

Unfortunately:

C:\Users\User\Pictures\gmic-qt-data\animations>gmic pal pear36 180,100,50 rep_markus_lyapunov_fractal[-1] abc,50,3,100%,50%,50%,50%,[-2],0 rm.. s. z o animation.mp4
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./pal/_pal/ Create palette 'pear36'.
[gmic]-1./ Input black image at position 1 (1 image 180x100x50x1).
[gmic]-1./rep_markus_lyapunov_fractal/
[gmic]-2./ Remove image [0] (1 image left).
[gmic]-1./ Split image [0] along the 'z'-axis.
[gmic]-50./ Output images [0,1,2,(...),47,48,49] as mp4 file 'animation.mp4', with 25 fps and (default) codec.
[gmic]-50./ *** Error *** Command 'output': [instance(50,64,00000209a77970a8)] gmicList<float>::save_ffmpeg_external(): Failed to save file 'animation.mp4' with external command 'ffmpeg'.
[gmic] Command 'output' has the following description:

I installed it here. Not sure what’s up with this.

Nor I. Suggest splitting the operation into two parts, G’MIC and ffmpeg, for purposes of isolating the fault in one part or the other.
Part 1: Make a simple image sequence. G’MIC relieved of calling ffmpeg.

gmic pal pear36 180,100,50 rep_markus_lyapunov_fractal[-1] abc,50,3,100%,50%,50%,50%,[-2],0 rm.. s. z o mk_lya_anim.png

If you get through that, G’MIC’s log should look something like this:

[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./pal/_pal/ Create palette 'pear36'.
[gmic]-1./ Input black image at position 1 (1 image 180x100x50x1).
[gmic]-1./rep_markus_lyapunov_fractal/  # Long pause on this step... 
[gmic]-2./ Remove image [0] (1 image left).
[gmic]-1./ Split image [0] along the 'z'-axis.
[gmic]-50./ Output images [0,1,2,(...),47,48,49] as png file 'mk_lya_anim.png'.
[gmic]-50./ End G'MIC interpreter.

This leaves you with 50 images in your local directory, of the form: mk_lya_anim_xxxxxx.png with xxxxxx ranging from 000000 to 000049 .

Part 2: Call ffmpeg to make a video from this sequence of images.

ffmpeg -framerate 30000/1001 -i mk_lya_anim_%06d.png -c:v h264 -profile:v high -bf 2 -g 30 -crf 18 -pix_fmt yuv420p -c:a copy -movflags faststart mk_lya_anim.mp4

See FFMPEG H264 Encoding Guide for background. Highlights: 29.97 framerate, H-264 video encoding, fairly decent quality, video set up to start play before the stream is complete (fast start).
ffmpeg will give out complete, but obscure, error messages if it can’t find - say - the H264 encoding library. At the end of the day, do you get a playable mk_lya_anim.mp4?

2 Likes

Golly, @Reptorian, these can be seductive…

gmic  -input '(255,226,200^179,255,170^20,47,0)' -input '(83,16,142^171,0,63^255,187,255)' -resize[-2,-1] 32,1,1,3,5 -input 512,288,300,1 rep_markus_lyapunov_fractal[-1] cab,50,3,100%,50%,50%,50%,[-3],[-2],0,2,2 rm[-3,-2] -split. z o cab_anim.png
ffmpeg -framerate 30000/1001 -i cab_anim_%06d.png -c:v h264 -profile:v high -bf 2 -g 30 -crf 18 -pix_fmt yuv420p -c:a copy -movflags faststart cab_anim.mp4

But this took just about 60 gigabytes of memory — the command is not something that can run on Grand Dad’s Tandy-RadioShack TRS-80, me thinks.

gmic -pal pear36 512,288,300 rep_markus_lyapunov_fractal[-1] acbc,50,3,100%,50%,50%,50%,[-2],0 rm.. -split. z o acbc_anim.png
ffmpeg -framerate 30000/1001 -i acbc_anim_%06d.png -c:v h264 -profile:v high -bf 2 -g 30 -crf 18 -pix_fmt yuv420p -c:a copy -movflags faststart acbc_anim.mp4


Isn’t there some documentation I should be doing or something… :thinking:

1 Like

EDIT: Never mind. Fixed it. Windoze antivirus.

My laptop cried in the darkness, crashed at some point and generated enough heat to make the room sweat.

Same: I disabled it, it reactivated x3-4 in one sitting. :man_facepalming::woman_facepalming: