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

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.

Thank you @KaRo KaRo. We tried to install Open cv 3.2.0 but it failed at 42% because of ffmpeg conflict Éléments but I’ll try tomorrow to install 3.4.7 with Macports Gmic build

Hi Andrea,
as far as I remind me there were problems to build a version working on older MacOS versions too and you thought about moving over to MacPorts, which will deliver other problems still.

Hello @KaRo karo, just to understand : if I install gmic via Mac port and have the opencv version you mentioned, I will have other problems ? Or it would be fine ?

No no, that was a remark to Andrea, who builds a gmic cli package for different MacOS versions …

Of course MacPorts is a bit old-fashioned and loads a tremendous number of dependencies, still I am using it …

@KaRo, so, I install OpenCV 3.4.7, gmic 2.7.5 via macport on my HS 10.13.6 os and everything would run fine for average_video, right ?

Normally MacPorts is installing all things automatically. AFAIK you cannot choose, only install gmic with all dependencies and than it should work! Still I am on 10.14.6 but that should not matter. At least if you don’t have a clutter of libraries and and individually changed compile and link paths!

… and don’t forget to update MacPorts. I am doing nearly automatically:

sudo port selfupdate ; port outdated ; sudo port -cup upgrade outdated

Andrea, if you look again into the gmic-osx build, it would be helpful to rename the latest build again to gmic-cli.zip

It worked ! Thanks !