Good day. I am new to using gmic cli, and while I have read some of the basics I have hit a stumbling block which is hopefully simple to overcome.
Context
I am trying to remove an overlay that says ‘BRB’ from a video that I left active by mistake. It might be better fitting to leave it in place as an incentive to my future self to not be careless; but I am interested in how well different removal methods work†.
Inpainting a single image
I have previously used gmic’s patch-based inpaint via GIMP, so I thought I would try that. It works fine for a single image:
gmic logotest.png logotest-redmask.png +inpaint[0] [1] remove[0,1] -output testgmic.jpg
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Input file 'logotest.png' at position 0 (1 image 1920x1080x1x3).
[gmic]-1./ Input file 'logotest-redmask.png' at position 1 (1 image 1920x1080x1x4).
[gmic]-2./ Inpaint image [0] masked by image [1], with high-connectivity average algorithm.
[gmic]-3./ Remove images [0,1] (1 image left).
[gmic]-1./ Output image [0] as jpg file 'testgmic.jpg', with quality 100% (1 image 1920x1080x1x3).
[gmic]-1./ End G'MIC interpreter.
I have yet to try the parameters in the command reference.
Inpainting a video
It seemed to me this would work since gmic works with videos, and indeed the output suggests it should:
$ gmic delogotest.mkv logotest-redmask.png +inpaint[0,-2] [-1] remove[-1] -output testgmic.mkv,60,h264
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Input all frames of file 'delogotest.mkv' at position 0 (837 images [0] = 1920x1080x1x3, (...),[836] = 1920x1080x1x3).
[gmic]-837./ Input file 'logotest-redmask.png' at position 837 (1 image 1920x1080x1x4).
[gmic]-838./ Inpaint images [0,836] masked by image [837], with high-connectivity average algorithm.
[gmic]-840./ Remove image [839] (839 images left).
[gmic]-839./ Output images [0,1,2,(...),836,837,838] as mkv file 'testgmic.mkv', with 60 fps and h264 codec.
[gmic]-839./ End G'MIC interpreter.
However, at a glance the output seems to be the input (though I think it is not).
Inspecting further without removal and without file output:
$ gmic delogotest.mkv logotest-redmask.png +inpaint[0,-2] [-1]
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Input all frames of file 'delogotest.mkv' at position 0 (837 images [0] = 1920x1080x1x3, (...),[836] = 19
20x1080x1x3).
[gmic]-837./ Input file '/home/robert/downloads/logotest-redmask.png' at position 837 (1 image 1920x1080x1x4).
[gmic]-838./ Inpaint images [0,836] masked by image [837], with high-connectivity average algorithm.
[gmic]-840./ Display images [0,1,2,(...),837,838,839] = 'delogotest.mkv, (...), delogotest_c837.mkv'.
<snip>
[837] = 'logotest-redmask.png':
size = (1920,1080,1,4) [31 Mio of float32].
data = (0,0,0,0,0,0,0,0,0,0,0,0,(...),0,0,0,0,0,0,0,0,0,0,0,0).
min = 0, max = 255, mean = 7.10836, std = 41.9774, coords_min = (0,0,0,0), coords_max = (1154,743,0,0).
[838] = 'delogotest_c1.mkv':
size = (1920,1080,1,3) [23 Mio of float32].
data = (39,118,131,127,120,117,105,109,122,141,146,144,(...),13,8,4,6,3,11,18,24,8,23,19,11).
min = 0, max = 255, mean = 65.443, std = 41.7933, coords_min = (958,7,0,0), coords_max = (1012,0,0,0).
[839] = 'delogotest_c837.mkv':
size = (1920,1080,1,3) [23 Mio of float32].
data = (39,118,131,127,120,117,105,109,122,141,146,144,(...),11,10,7,9,4,10,13,22,8,24,17,8).
min = 0, max = 255, mean = 70.2562, std = 43.1253, coords_min = (871,38,0,0), coords_max = (436,2,0,0).
The last two frames seem to have inpainting applied, and the third last is the mask. The others seem to be the original unchanged frames.
Q: Where have I made a mistake with video input / applying inpaint / remove
-ing frames?
Follow up questions: While I am testing on a short section of video (~13s) I would like to see if I can apply this to a much longer segment (~30 min!). 1) Is there a way to tell gmic to operate sequentially on a single frame at a time, rather than reading all frames in? 2) If not, is there a way to make gmic operate on a named pipe? I was hoping to do <video input> → ffmpeg → <image frames> → named pipe → gmic → <image frames> → second ffmpeg process → <video output>
I’ve tried 2) but not yet gotten it to work, and I haven’t found any references to anyone doing this when I searched!
Thanks in advance for advice. The documentation and tutorial are great – my favourite part so far is the fake depth of field on the Moai heads – and probably answer my question, but I haven’t quite gotten there yet!
†: the video is named delogotest.mkv as I first tried the delogo filter of ffmpeg, even with complex geometry (read: a bunch of rectangles covering the letter lines) the results were not brilliant; though obviously it wasn’t designed for cases like this!