A guide about computing the temporal average/median of video frames with G'MIC

These builds are fairly old. It is not recommended to use them anymore! I have stopped the building since some time. I am using MacPorts gmic and build for my privat use the latest git version ((cd ~/work/src/gmic/src/; make -B cli “SUBLIBS=-lX11” || exit; sudo cp ~/work/src/gmic/src/gmic /usr/local/bin/) ), still with the libraries from MacPorts, besides the prebuild from Andrea.

Well, I did build the latest stable release from git using the makelist there but that didn’t work either. Getting the macports to build it now. Macports is installing a ridiculuous number of dependencies, surely gmic doesn’t need three different versions of python.

I just compiled it on another computer, the same error persists. Could you upload the binary and libs you made from the latest stable git?

It is possible that the opencv4 library is not being found as opencv

I did not build any libraries, I have only the executable.

Yeah that number of ports loaded by mac parts is incredible…

I’ll put the exe as gmic.zip in the remote folder you used for download. But I#ll will delete these old things soon!

I#m using opencv not opencv4

You have opencv from 2009 installed still? We had opencv2, 3 and now 4 since. In 4, Opencv dropped pkgconfig support

I am guessing that it is cv2 since that is the lowest version in most repositories. I wonder if OpenCV integration is just for video. If that is the case, is there a lighter weight and license compatible package that could replace it?

I tried installing opencv@2 from homebrew but that didn’t do it either.

I think you try to corrupt your system!

I have opencv 3.7 . I don’t know how you (and @afre) have such ideas.

Do

otool -L gmic

Because Opencv4 does not include pkgconfig, and installs as opencv4 even if you do install with the optional flag. The way that gmic is looking for the package is outdated and so cannot find opencv if you have recent versions installed so you have to willingly install an older version for it to compile without changing the makefiles on gmic.

I compiled and installed opencv 3.4.8 which still goes by opencv in package land, let’s see how this goes…

still doesnt like something
[ 66%] Generating resources/gmic_bashcompletion.sh
make[2]: *** [resources/gmic_bashcompletion.sh] Error 127
make[2]: *** Deleting file resources/gmic_bashcompletion.sh' make[1]: *** [CMakeFiles/bashcompletion.dir/all] Error 2 make: *** [all] Error 2 iMac:gmic-2.7.4 4 jajanene$ make uninstall make: *** No rule to make target uninstall’. Stop.
iMac:gmic-2.7.4 4 jajanene$

Derin, using make with Makefile for gmic there is no config etc. necessary. That might be old-fashioned. I must confess my collection of packages in MacPort is tremendously grown, one large disadvantage, still gmic is IMHO not prepared for opencv4, and in fact opencv was often if not always a problem. Hence my gmic build can only work with opencv (3 actually)

I cannot help you with cmake, never used it for gmic!

Sorry, I wasn’t being clear. I was responding to @freshsisyphus that there is no way that you would be using version 1 since the minimum version for most repositories is cv2 and many have version 3 now.

Anyway, I will let you two and perhaps @David_Tschumperle sort this out since I am not interested in building things. It is way too stressful. :sweat_smile:

@David_Tschumperle, @patdavid exact same problem as above with me. Your help would very appreciated =)

That seems to be some Mac-specific issues, with G’MIC and OpenCV.
Maybe @KaRo or @Carmelo_DrRaw have more info on this.

@David_Tschumperle Thank you David for your answer.
So you confirm that OpenCV 4 + 2.7.4 and your command works on Linux ? Then we can have a try. By the way, do you have installed mean_video or I have to add a custom script from @patdavid website ? Thanks a lot for your quick answer
Here was my config :
Mac osx 10.14
Version 2.7.4 installed with brew install gmic
Command :
tests-MacBook-Pro-2:~ mac$ gmic -average_video /Users/mac/gta5.mp4,0,-1,4 -o /Users/mac/test1/t1.avi
[gmic]-0./ Start G’MIC interpreter.
[gmic]-0./ Average frames of input video file ‘/Users/mac/gta5.mp4’, with first frame 0, last frame -1, frame step 4 and output filename ‘’.

[gmic]-0./ Output image [] as avi file ‘/Users/mac/test1/t1.avi’, with 25 fps and (default) codec.
[gmic]-0./ End G’MIC interpreter.
tests-MacBook-Pro-2:~ mac$

You can update commands using gmic update, but in this case, you don’t need to do anything because it is in 2.7.4 already.

@freshsisyphus @KaRo @David_Tschumperle I do not remember what exactly prevented me from compiling GMIC with OpenCV support, but I will have a look as soon as time allows…

1 Like

I don’t know the homebrew gmic build, still the macports gmic build 2.7.5 is doing something, there is seemingly no mac specificity and t1.avi is some mean image. And opencv linked is version 3.4.7

gmic -average_video test1.avi,0,-1,4 -o t1.avi
[gmic]-0./ Start G’MIC interpreter.
[gmic]-0./ Average frames of input video file ‘test1.avi’, with first frame 0, last frame -1, frame step 4 and output filename ‘’.

Frame #120
[gmic]-1./ Output image [0] as avi file ‘t1.avi’, with 25 fps and (default) codec.OpenCV: FFMPEG: tag 0x5634504d/‘MP4V’ is not supported with codec id 12 and format ‘avi / AVI (Audio Video Interleaved)’
OpenCV: FFMPEG: fallback to use tag 0x34504d46/‘FMP4’

[gmic]-1./ End G’MIC interpreter.

The following command generates a sequence of cumulative means

gmic -average_video test1.avi,0,-1,4,t0.avi
[gmic]-0./ Start G’MIC interpreter.
[gmic]-0./ Average frames of input video file ‘test1.avi’, with first frame 0, last frame -1, frame step 4 and output filename ‘t0.avi’.

Frame #0 OpenCV: FFMPEG: tag 0x5634504d/‘MP4V’ is not supported with codec id 12 and format ‘avi / AVI (Audio Video Interleaved)’
OpenCV: FFMPEG: fallback to use tag 0x34504d46/‘FMP4’
Frame #120
[gmic]-1./ End G’MIC interpreter.