View Full Version : InpaintDelogo - advanced logo removal & hardcoded subtitles extraction
VoodooFX
1st October 2024, 23:21
Don't use settings you don't understand, your script is complete nonsense.
LWLibAvVideoSource("D:\Professor.mp4")
# Back to original resolution:
Crop(160,0,-160,0).Spline16Resize(640,480)
# Remove this after Automask run:
Trim(90,40480)
InpaintDelogo(mask="D:\mask.bmp", Loc="336,420,-12,-8", Automask=0, Mode="Inpaint", Analyze=3)
Before:
https://i.imgur.com/h1Ed0Ry.png
After:
https://i.imgur.com/DGp8i2Z.png
Spiny Norman
4th October 2024, 10:46
If someone could give some beginner-level advice on subtitle extraction, I'd be very grateful.
I very often come across old SD videos that have burnt-in subtitles that may still be useful. Those subtitles are often wanted by someone. So I set out from scratch to see if I could (learn how to) extract them.
So to use an example: What settings would work best for example to extract from this video?
Let's say https://www.youtube.com/watch?v=bJKq7SVNfkM for the simple reason that it's SD but has very legible subtitles. (I have some that are in worse quality but that's for later.)
LWLibavVideoSource("C:\Swtools\Backanterna.mp4")
InpaintDelogo(Loc="94,368,280,86", Show=4, DynMask=4, DynTune=160, DynMask4H=70, Extract=1, ImgDir="C:\Swtools")
Thanks to VoodooFX I installed the required stuff including plugins and I can manage the 'loc' part and I'm extracting png files, like the attached example.
But I could probably get better output, right? I've seen mentioned DynMask=5 and I guess in some cases I should specify something with DynColor with a hexadecimal value. (For example if the colours are different such, like on the arte channel: https://www.youtube.com/watch?v=vNwFwdEtpy0)
How can I improve the script to get better results in cases like these?
(Most of this stuff is new for me, so it's possible an exact argument has to be spelled out for me. But anything that gets me further on the rails I'll very much appreciate!)
VoodooFX
10th October 2024, 13:35
If someone could give some beginner-level advice on subtitle extraction, I'd be very grateful.
From your post I can tell that you are not doing anything yet, so read the manual first.
Both videos are low quality, first learn the subs extraction with the high quality videos.
Spiny Norman
10th October 2024, 15:47
Out of interest: Is there a specific reason to start with HD?
Meanwhile, if anyone has suggestions how to expand my first attempt above to get better results, I'm all ears.
VoodooFX
10th October 2024, 20:00
https://i.imgur.com/s5hWGAR.jpeg
Spiny Norman
11th October 2024, 11:25
So I have the greatest respect for your programming skills, but nevertheless I'd be interested in a more specific reference, or to be given/pointed to an example. Even "see post ##" would already be something. As before, you (the OP) can pass if it doesn't interest you.
As said, a lot of discussion concerns delogoing which is (probably?) irrelevant.
The manual describes the functions but that doesn't directly lead to their application from my POV. (On a theoretical level, all information is already somewhere, but that is not how learning works. Otherwise all schoold etc. could close for good. We ALL (yes, OP included) have at one time or another asked questions that we could have found somewhere - in retrospect.)
Let me change the question completely: Has anyone tried this (sub. extraction) on old VHS sourced material? If so, how did it go?
VoodooFX
11th October 2024, 14:24
...to be given/pointed to an example.
You already posted an example yourself, there -> https://forum.doom9.org/showthread.php?p=2007676
Which is a copy/paste from somewhere, with only Loc adjusted.
The manual describes the functions but that doesn't directly lead to their application from my POV.
The manual directly leads to application, it's oxymoron to think otherwise.
Let me change the question completely: Has anyone tried this (sub. extraction) on old VHS sourced material? If so, how did it go?
Yes. It went well.
PS: No need to post same things on the three different forums.
Spiny Norman
11th October 2024, 14:51
That's the whole point, isn't it: The example I gave is probably not the best possible outcome. That wouldn't make sense given your earlier demonstrations of results.No need to post same things on the three different forums.Yes there is. On the other hand you definitely need not reply on all three. You don't even need to reply on one if you don't want.
(You're making it very hard. You yourself have on occasion also said something wrong or asked for information you could have found. How would you have liked to be put down for something like that?)
VoodooFX
11th October 2024, 15:22
That's the whole point, isn't it: The example I gave is probably not the best possible outcome.
It's crazy to expect that copy/paste of some random script example would have any meaningful output on various random videos.
You need to adjust the script example to video. To be able to do that you need to read the manual.
"The whole point": What prevents you reading the manual?
You yourself have on occasion also said something wrong or asked for information you could have found. How would you have liked to be put down for something like that?
You are implying here some nonsense, I've no idea why you post these fantasies.
Spiny Norman
11th October 2024, 18:26
You are implying here some nonsense, I've no idea why you post these fantasies.What prevents you reading the manual? When you say it like that, it seems like a polite way to say F-- off.
But I can give a completely serious answer, if it is a real question. Outside the technical dimension there might after all be things that you didn't think of yet.
VoodooFX
11th October 2024, 18:45
This topic is outside of your dimension.
Go see the doctors, good luck.
Spiny Norman
13th October 2024, 12:42
Well, I'm sorry you feel that way. There might be more to it then "RTFM", but as said, you're free to pass if explaining with examples is not up your alley - no-one could expect you to answer ALL questions.
Thank you for the help so far and see you in the waiting room then.
Guilbert
13th October 2024, 20:32
Hi,
I sent you a video, VoodooFX.
I think the parameters are good, I have much better results than with VideoSubFinder, except that more than 30 subtitles are missing compared to VSF (https://www.subdiff.com/view-EgsS7cG5ej.html), and I don't understand why.
I tried to play with SubMinDur, SubMinLuma and SubSusDur with no luck...
Here is my parameters:
InpaintDelogo(Loc="400,800,-400,-40", Show=4, DynMask=3, Dyn3Seq=24, DynTune=190, DynTEdge=1, DynTEdgeThY=20, DynTEdgeInf=2, DynLocUp=2, CorrTh=0.7)
Can you explain to me what's wrong, please?
Thank you for your help.
VoodooFX
14th October 2024, 00:27
Can you explain to me what's wrong, please?
Hi, "Dyn3Seq=24" - it means that subs shorter than 1 sec [your video is ~24 fps] will disappear from a mask, so probably all those 30 subs are shorter than 1 sec.
Read about Dyn3Seq in the manual.
And I would use such settings:
InpaintDelogo(Loc="400,800,-400,-40", Show=4, DynMask=3, Dyn3Seq=18, DynTune=210, DynTEdge=1, DynTEdgeThY=15, DynTEdgeInf=4, DynLocUp=2, CorrTh=0.8)
Guilbert
14th October 2024, 09:02
I will. Thank you very much for the explanation and the parameters. :cool:
Also, can InpaintDelogo scan two locs at once?
VoodooFX
14th October 2024, 10:32
Also, can InpaintDelogo scan two locs at once?
No.
dgdgdg
Spiny Norman
21st October 2024, 22:05
Hi, "Dyn3Seq=24" - it means that subs shorter than 1 sec [your video is ~24 fps] will disappear from a mask, so probably all those 30 subs are shorter than 1 sec.
Read about Dyn3Seq in the manual.
And I would use such settings:
InpaintDelogo(Loc="400,800,-400,-40", Show=4, DynMask=3, Dyn3Seq=18, DynTune=210, DynTEdge=1, DynTEdgeThY=15, DynTEdgeInf=4, DynLocUp=2, CorrTh=0.8)Does anyone blame me at this point if I say, Now what the F--- was so hard about that?
buddha9
24th November 2024, 18:36
Hi all,
My video has 2 logos.
1) top right
2) bottom right
I've try this code but only the first is hidden
LoadPlugin("C:\video.MPG")
tdeint()
InpaintDelogo( mask="C:\mask.bmp", Loc="580,50,120,60", Mode="Inpaint")
InpaintDelogo( mask="C:\mask.bmp", Loc="580,470,94,70", Mode="Inpaint")
why?
thanks!
VoodooFX
24th November 2024, 18:47
@buddha9 Make sure that both logo masks are present in "mask.bmp" as you use the same "mask.bmp" in both instances.
buddha9
10th December 2024, 13:48
Hi all!
I've a 1h 30m file.
I've a little logo (a little green circle) at bottom right. But only for the first 3 minutes.
How can I do to "remove " it ? :)
PS
my only problem is to limit the remover only on first 3 minutes..
thanks!
_______________
OK I think this is good :)
Trim(0,4508).InpaintDelogo(mask="I:\_WIP\movie\vlcsnap-00032_right-bottom.bmp", Loc="598,468,42,40")++\
Trim(4509,end=Framecount)
Emulgator
10th December 2024, 17:02
you just Trim++Trim, something like that:
source=<yoursourcefilterhere("yoursourcepathhere")>
lastlogoframe=180*Round(framerate(source))# 180 is a placeholder for seconds of logoduration
Trim(InpaintDeLogo(source),0,lastlogoframe)++Trim(source,lastlogoframe+1,0)
buddha9
11th December 2024, 08:50
you just Trim++Trim, something like that:
source=<yoursourcefilterhere("yoursourcepathhere")>
lastlogoframe=180*Round(framerate(source))# 180 is a placeholder for seconds of logoduration
Trim(InpaintDeLogo(source),0,lastlogoframe)++Trim(source,lastlogoframe+1,0)
Thansk for quick hint! :)
My video is 1h 30m long.
The whole video has a logo (upper left)
For the first 180 seconds there is also another logo (bottom right)
I made 2 BMP file (https://file.io/L1Wa6jqFCCuO):
- the first with 2 white logo masks
- the second only for logo on upper left
How can I write the script with InpaintDeLogo ? :)
VoodooFX
11th December 2024, 09:53
How can I write the script with InpaintDeLogo ? :)
The script would look something like this:
v = LWLibAvVideoSource("D:\video.mp4")
# Here we split video and delogo only some part. Those are frame numbers in Trim():
v1 = v.Trim(0,50).InpaintDelogo(bottom right)
v2 = v.Trim(51,0)
# Here we join all parts and delogo whole video
v1++v2
InpaintDelogo(upper left)
buddha9
11th December 2024, 22:11
path="..."
pathDGD="..."
filename="...mkv"
##################################################
clipv = FFmpegSource2(path+filename)
Delogoed=InpaintDelogo(clipv, mask=path+"upper_left.bmp", Loc="50,32,98,90")
StackHorizontal(clipv.converttorgb32().Zoom(srcx="100", srcy="70",factor="6").crop(100,120,500,420), Delogoed.converttorgb32().Zoom(srcx="100", srcy="70",factor="6").crop(100,120,500,420))
https://i.postimg.cc/mzLB8DL2/compare-1.png (https://postimg.cc/mzLB8DL2) https://i.postimg.cc/r0fcbksG/compare-2.png (https://postimg.cc/r0fcbksG) https://i.postimg.cc/PNFTQTBT/compare-3.png (https://postimg.cc/PNFTQTBT) https://i.postimg.cc/Rq0vtNpg/compare-4.png (https://postimg.cc/Rq0vtNpg) https://i.postimg.cc/PvNhnRvg/compare-5.png (https://postimg.cc/PvNhnRvg) https://i.postimg.cc/ZCBZfXS3/compare-6.png (https://postimg.cc/ZCBZfXS3)
upper_left.bmp:
https://i.postimg.cc/J0Mr1TNV/upper-left.png (https://postimages.org/)
I'm happy with the result!
Anyway, any hints to improve it? :)
Thanks!
VoodooFX
13th December 2024, 16:12
I'm hapy with the result!
Anyway, any hints to improve it? :)
Thanks!
Looks very good I think. :cool:
frobber
19th January 2025, 07:31
Hope this is the right place to post a question.
I, too, am stuck trying to use InpaintDelogo...
Using InpaintLoc() in a script, I have identified the Loc values for the mask. It works. I see a light yellow region in the video preview.
But then when I try to automatically create the mask, MeGUI fails with the error "The video stream cannot be opened". I.e., InpaintLoc() works, but InpaintDelogo() doesn't.
Here's my script:
Import("C:\Program Files (x86)\AviSynth+\plugins64\InpaintDelogo.avsi")
LoadPlugin("C:\MeGUI-2944-64\tools\lsmash\LSMASHSource.dll")
LoadPlugin("C:\MeGUI-2944-64\tools\avisynth_plugin\TIVTC.dll")
LWLibavVideoSource("C:\MyMovie 1080i HDTV MPEG-2 AAC2.0.mkv")
tfm(order=1).tdecimate()
# InpaintLoc(Loc="1144,950,70,88")
InpaintDelogo(mask="C:\Program Files (x86)\AviSynth+\plugins64\Logo Database\MyMask.1080_v1_1144-950.bmp", Loc="1144,950,70,88", Automask=1, aMix=5)
IIUC, this should create the mask file. The source is a TS file. I have converted it to MKV using mkvtoolnix, and also tried making a D2V file using DGIndex (and then opening it using MPEG2Source()), but regardless I always get the same error from MeGUI.
What am I doing wrong?
VoodooFX
19th January 2025, 21:46
I always get the same error from MeGUI.
Post full MeGUI's Log.
And you could cut and share a small sample of video to reproduce.
frobber
19th January 2025, 23:31
Thanks for your message. After restarting my PC, curiously the error changed to something different. The error was due to a missing DLL (AvsInPaint.dll).
I fixed that, but now there's another error. Evidently I'm still doing something wrong.
Here's the log and a short sample of the video:
https://www.sendspace.com/file/zodixv (3 KB)
https://www.sendspace.com/file/5egptg (36 MB)
I'm trying to set up the logo file, remove the logo, convert the video from 29.97 fps, fix the aspect ratio and remove the black bars on the sides.
VoodooFX
20th January 2025, 02:14
Tested your shared script and file - no problems.
After restarting my PC, curiously the error changed to something different. The error was due to a missing DLL (AvsInPaint.dll).
Did you installed all other requirements?
You could share what "AVSMeter64 -avsinfo" shows.
-[NoImage] RT_ReadTxtFromFile: Cannot Open file C:\Program Files (x86)\AviSynth+\plugins64\Logo Database\NihonEiga.1080_v1_1144-950.bmp_InpaintDelogo3_1144-950-226-42_A2-16.txt
-[NoImage] (C:\Program Files (x86)\AviSynth+\plugins64\InpaintDelogo.avsi, line 2977)
-[NoImage] (C:\Program Files (x86)\AviSynth+\plugins64\InpaintDelogo.avsi, line 2994)
-[NoImage] (C:\Program Files (x86)\AviSynth+\plugins64\InpaintDelogo.avsi, line 1885)
-[NoImage] (C:\Program Files (x86)\AviSynth+\plugins64\InpaintDelogo.avsi, line 1890)
-[NoImage] (C:\Program Files (x86)\AviSynth+\plugins64\InpaintDelogo.avsi, line 1892)
-[NoImage] (C:\Program Files (x86)\AviSynth+\plugins64\InpaintDelogo.avsi, line 1906)
-[NoImage] (C:\Users\xxx\Documents\Kinugasa-1.avs, line 9)
Log doesn't match your shared script, post the avs script matching the error.
Check if that txt file exists.
What is "NihonEiga.1080_v1_1144-950.bmp"? There is only "NihonEiga.1080_v2_1310-948.ebmp" in the current "Logo Database".
frobber
20th January 2025, 03:11
Thanks. I believe I have installed all the requirements (though of course maybe I flubbed something).
Here is the AviSynth Info Tool readout:
https://www.sendspace.com/file/ty4y9s
Running the AVS script took hours, so before I post that, could I confirm that I'm on the right track? Probably I need to change the script first.
As you see, there is already a logo in the database, but its position in the frame is different, and the frame in the video I've got appears horizontally squished, so I assumed that I need(?) to create a new BMP file for the logo. And that's where I'm stuck.
The TXT file is missing because I didn't create it. I don't know what it's supposed to be about.
Basically, I am unclear on the steps that I need to take.
TIA !
VoodooFX
20th January 2025, 11:18
Running the AVS script took hours, so before I post that
You can run tests on smaller portion of video, you can limit video with Trim().
As you see, there is already a logo in the database, but its position in the frame is different...
You can move it as you like by changing Loc coords and you don't need to create anything for those ebmp masks in database.
The TXT file is missing because I didn't create it. I don't know what it's supposed to be about.
InpaintDelogo creates it. No idea how you get that error as you didn't shared the script. And I don't know any way how such error could be produced.
Basically, I am unclear on the steps that I need to take.
Basically we are not clear what you are doing out there as you didn't described your steps.
Here is the AviSynth Info Tool readout
I don't see any fatal issues
C:\Program Files (x86)\AviSynth+\plugins64\FrameSel_x64.dll [2.20.0.0] # latest is [2.21.0.0, 2021-07-27]
C:\Program Files (x86)\AviSynth+\plugins64\LSMASHSource.dll [2021-04-23] # very old
C:\Program Files (x86)\AviSynth+\plugins64\mvtools2.dll [2.7.45.0] # latest is [2.7.46.0, 2024-05-03]
C:\Program Files (x86)\AviSynth+\plugins64\RT_Stats_x64.dll [2.0.12.0] # latest is [2.0.13.0, 2020-12-29]
C:\Program Files (x86)\AviSynth+\plugins64\TIVTC.dll [1.0.26.0] # latest is [1.0.29.0, 2024-03-02]
This one missing (not needed by default):
C:\Program Files (x86)\AviSynth+\plugins64+\AddGrainC.dll [1.8.4.0, 2022-02-15]
frobber
20th January 2025, 16:24
OK, here's the script and log file:
https://www.sendspace.com/file/dz2j4c
I tried updating the old DLLs and adding the missing AddGrainC.dll, but I still get the same error.
What should I try next?
VoodooFX
21st January 2025, 01:40
Import("C:\Program Files (x86)\AviSynth+\plugins64\InpaintDelogo.avsi")
LoadPlugin("C:\Program Files (x86)\AviSynth+\plugins64\LSMASHSource.dll")
LoadPlugin("C:\Program Files (x86)\AviSynth+\plugins64\TIVTC.dll")
You don't need to import/load them, plugins are autoloaded from this folder.
InpaintDelogo(mask="C:\Program Files (x86)\AviSynth+\plugins64\Logo Database\NihonEiga.1080_v2_1310-948.bmp", Loc="1144,950,70,88", Automask=1, aMix=5)
Why this bmp named like that?
OK, here's the script and log file:
https://www.sendspace.com/file/dz2j4c
I tried updating the old DLLs and adding the missing AddGrainC.dll, but I still get the same error.
What should I try next?
Maybe there is no permission to write to that folder, use your own non-Windows folder, like "D:\Myfolder".
frobber
21st January 2025, 02:44
Thanks -- write access must have been the issue. I moved the Logo Database folder and now I don't see an error.
So, I am trying to create a mask, like this:
InpaintDelogo(mask="C:\Users\Me\Documents\Logo Database\NihonEiga.1080_v2_1144-948.bmp", Loc="1144,948,70,88", Automask=1, Analyze=2)
I get a video window with two images of the mask, one bitmap and one greyscale, above and below.
However, the mask just looks sort of blurry - not much like the logo.
I have tried adding the aMix parameter, with values ranging from -50 to 6, but it doesn't seem to make much difference.
How should I proceed?
VoodooFX
21st January 2025, 03:27
Thanks -- write access must have been the issue. I moved the Logo Database folder and now I don't see an error.
But I only get a video window with two images of the mask, one bitmap and one greyscale, above and below.
How should I proceed?
Remove Trim() from your script, delete the files created, and now run it again.
After the basemask is generated you can adjust it with aMix, then remove Automask=1 from your script and add Mode="Deblend", run the script again, on the first run the deblend masks will be generated. That's it.
I read the "basic short guide" at the beginning of this thread, but maybe it's out of date. Nothing is clear in that text, really.
No, it' not out of date, the first:
0) Read help/manual (at the top of the script) about parameters mentioned
Did you read about parameters mentioned? Specify what is not clear in the manual!
frobber
21st January 2025, 03:49
OK. It's computing the new mask. I assume this will take a long while.
Re: documentation, I would say this text is not really a "manual" but more just some general code comments and usage notes. If you like, I could give more specific feedback, though it would probably be best after I manage to get this script working and remove a logo.
VoodooFX
21st January 2025, 04:59
OK. It's computing the new mask. I assume this will take a long while.
Depends from your CPU speed. Can take ~hour on slow CPUs.
Re: documentation, I would say this text is not really a "manual" but more just some general code comments and usage notes. If you like, I could give more specific feedback, though it would probably be best after I manage to get this script working and remove a logo.
Dunno what you are smoking out there but it's not "some general code comments" like you imagine.
Now I tried "NihonEiga.1080_v2" mask from Logo Database on your test sample, it fits very well.
Original (zoomed 4 times):
https://i.imgur.com/Rp7XnZ3.png
You already aligned Loc well in your script (Loc="1144,950,70,88"):
https://i.imgur.com/m1GWYug.png
From the image above hard to tell what is what, so disable the postprocessing with dPP=0, Interp=0:
https://i.imgur.com/QyjuYqT.png
Now we can see more clearly, it needs one pixel shift to the right, ShiftMasksHo=-1:
https://i.imgur.com/AlJNyTW.png
Perfect, logo gone, above we see pure deblend output without postprocess.
Artifacts are minimal so we use a bit lighter postprocess, leave Interp=0 in the script and remove dPP as its default is OK:
https://i.imgur.com/TLTASkf.png
As source is bit grainy then we add some grain to the postprocessed area with GrainPP=2:
https://i.imgur.com/05HttUe.png
Here is full command ready to delogo your video:
InpaintDelogo(mask=D:\NihonEiga.1080_v2_1310-948.ebmp, Loc="1144,948,0,0", Interp=0, ShiftMasksHo=-1, GrainPP=2, Greyscale=1)
frobber
21st January 2025, 05:09
That works great, thanks !
eXtremeDevil
9th March 2025, 18:56
Could someone give me a clue on how to use this to remove hardcoded subs? I've been reading the doc and trying stuff but the library always ask me for a mask... but I don't have any.
VoodooFX
9th March 2025, 23:01
Cut and share a video sample, and your AvS script too.
eXtremeDevil
10th March 2025, 10:06
Cut and share a video sample, and your AvS script too.
Here's the sample: https://mega.nz/file/FEgzFAIQ#gppqcmpHtGCLSqctNCovfJ6lGt__S7l3tjcPkGKNPIY
And as for the AVS, I don't really have much, as I said, I read the doc but it's too advanced for me, I found nothing related to subtitle removal to start with. If I were to extract subs or remove a logo, yes, I could maybe get to something myself.
Also, I don't even know if this will be possible with good results, I think the video source is not that good (it's from my personal original DVD, but even then...)
D2VSource("S:\Escritorio\video.d2v").converttoyv12()
InpaintDelogo(Loc="100,450,-100,-50" , Mode="Inpaint", Automask=1, aMix=0)
About the coordinates, they are probably wrong, but I haven't figured out how to calculate them yet.
I have many questions here:
How can I use "InpaintLoc()"? Do I need if for my task?
Should I use the "mask" param?
Should "Automask" be set to 1?
I could go on. What I mean is, I don't understand the values of the parameters, or at least I cannot find any value that match my task here.
VoodooFX
10th March 2025, 17:18
If you don't understand how simple Crop works then there is no point in explaining anything, I guess. :)
Anyway, look at the example below:
o=LWLibAvVideoSource("D:\out.m2v")
mask =o.InpaintDelogo(Loc="160,340,-160,-74", Show=4, DynMask=3, DynTune=90, Dyn3Seq=28, DynTEdge=1, DynInflate=2)
delogo =o.InpaintDelogo(Loc="160,340,-160,-74", Show=0, DynMask=3, DynTune=90, Dyn3Seq=28, DynTEdge=1, DynInflate=2)
StackVertical(o.Crop(160,340,-160,-74),
\ mask.ConvertToYV12,
\ delogo.Crop(160,340,-160,-74))
https://i.imgur.com/sNt07Dm.png
eXtremeDevil
10th March 2025, 20:12
If you don't understand how simple Crop works then there is no point in explaining anything, I guess. :)
Anyway, look at the example below:
o=LWLibAvVideoSource("D:\out.m2v")
mask =o.InpaintDelogo(Loc="160,340,-160,-74", Show=4, DynMask=3, DynTune=90, Dyn3Seq=28, DynTEdge=1, DynInflate=2)
delogo =o.InpaintDelogo(Loc="160,340,-160,-74", Show=0, DynMask=3, DynTune=90, Dyn3Seq=28, DynTEdge=1, DynInflate=2)
StackVertical(o.Crop(160,340,-160,-74),
\ mask.ConvertToYV12,
\ delogo.Crop(160,340,-160,-74))
https://i.imgur.com/sNt07Dm.png
Yes, sorry, I know how crop works, I know the basics and I can create simple scripts myself. But this time for some reason I was confused about the cropping :S
Thanks very much for the script, I can work starting from that, I wasn't getting the mask creation with the library itself.
fa1rid
14th March 2025, 05:17
@VoodooFX
I have many movies which have "Starz" watermark. The logo appears in intervals in the movie for a minute each time. I want to remove the logo without encoding the whole video, only the parts where the watermark appears.
I can split the video at keyframes to get the chunks where the watermarks appear and then concatenate the chunks.
I tried to remove the logo and it worked. The problem is that the original video has the logo fades in at the beginning and then fades out at the end of each chunk.
That makes the logo becomes visible using "Deblend" mode when the logo in the actual video is hidden. I tried Mode="Inpaint" but it doesn't give good results as "Deblend".
How to go around that issue?
Also what settings you think are best for this kind of watermark?
I'm currently using this:
video = FFVideoSource("E:\movie.mkv")
# delogo =video.InpaintDelogo(Loc="1618,950,160,58", Automask=1, mask="E:\movie.bmp")
delogo = video.InpaintDelogo(Loc="1618,950,160,58", mask="E:\movie.bmp", Mode="Deblend")
return delogo
Here is one Chunk: https://archive.org/download/starz-watermark/Starz%20Watermark.mkv
By the way, is there a way to automatically detect the intervals where the watermark appears rather than getting the times manually?
Thanks!
VoodooFX
14th March 2025, 07:22
I want to remove the logo without encoding the whole video, only the parts where the watermark appears.
I think you'll not be able to join new encode with original, so you'll need to encode whole video.
I tried to remove the logo and it worked. The problem is that the original video has the logo fades in at the beginning and then fades out at the end of each chunk.
How to go around that issue?
Use inpaint on the fade animations.
Also what settings you think are best for this kind of watermark?
Share your ebmp file.
By the way, is there a way to automatically detect the intervals where the watermark appears rather than getting the times manually?
No.
fa1rid
14th March 2025, 07:39
I think you'll not be able to join new encode with original, so you'll need to encode whole video.
No.
Yes I actually just realized that when I was doing some tests. But there should be a way to do that. If we match the encoding settings of the original? I tried to match them but couldn't make it work so far. Anyone you think knows how, or it's kinda impossible?
Use inpaint on the fade animations.
It will be a hassle to do that. There are 12 parts where the logo is shown, so that's 24 times micro checking where the fading starts or ends. Any other suggestions?
Share your ebmp file.
I thought you will generate one from the video I gave you. Anyway here it's: https://archive.org/download/starz-watermark/logo.ebmp
Thanks again!
VoodooFX
14th March 2025, 11:13
If we match the encoding settings of the original? I tried to match them but couldn't make it work so far. Anyone you think knows how, or it's kinda impossible?
Yes, that's practically nearly impossible.
It will be a hassle to do that. There are 12 parts where the logo is shown, so that's 24 times micro checking where the fading starts or ends. Any other suggestions?
Write a function so you wouldn't need to bother with those additional 24 parts:
v=LWLibAvVideoSource("D:\Starz Watermark.mkv")
a1=v.Trim(0,11)
a2=v.Trim(12,1449).starz_delogo(10)
a3=v.Trim(1450,0)
a1++a2++a3
function starz_delogo(clip c, int animation_length){
clip_length = c.FrameCount
inpaint = c.InpaintDelogo(Loc="1618,950,160,58", mask="D:\movie.bmp", Mode="Inpaint")
deblend = c.InpaintDelogo(Loc="1618,950,160,58", mask="D:\movie.bmp", Mode="Deblend")
start = inpaint.Trim(0, animation_length - 1)
middle = deblend.Trim(animation_length, clip_length - (animation_length + 1))
end = inpaint.Trim(clip_length - animation_length, 0)
return start ++ middle ++ end
}
I thought you will generate one from the video I gave you. Anyway here it's:
I just wanted to check if you made it right.
Your ebmp looks OK, but that can be just coincidence from your side. :D
fa1rid
14th March 2025, 19:50
@VoodooFX that function will slightly help, thank you, but each video (part/segment) has slight difference in frame numbers of where the logo starts/ends. So it will still require manual work for every fade-in fade-out. Also, I tried on different scene and the logo removal was not good as the artifacts were visible. I might need to look for something else, maybe AI level?
Here is the other part I tried, see in the video in the scene when it's panning from the ceiling going downwards: https://archive.org/download/starz-watermark/part-004-fixed.mkv
VoodooFX
14th March 2025, 20:59
So it will still require manual work for every fade-in fade-out.
Use larger animation length to cover all cases, for example - starz_delogo(30)
Also, I tried on different scene and the logo removal was not good as the artifacts were visible.
Try stronger post-process, for example: dPP=-5, Optimize2=2
buddha9
27th May 2025, 15:50
Any way to use ImpaintDelogo with a logo that horizontally move slowly from left to right?
maybe there is tracking tool somewhere?
PS
I have a video with "1win" logo to remove
VoodooFX
27th May 2025, 23:39
Any way to use ImpaintDelogo with a logo that horizontally move slowly from left to right?
maybe there is tracking tool somewhere?
Yes, make a dynamic mask of the logo.
isidroco
12th June 2025, 22:10
Suggestion for InpaintDelogo.avsi:
Change: isHD = (x > 1024) ? true : false
To: isHD = (y >= 720) ? true : false
Because some of my HD material resized to 4:3 is 960x720 which now fails to be flagged as HD.
VoodooFX
12th June 2025, 23:17
Suggestion for InpaintDelogo.avsi:
Change: isHD = (x > 1024) ? true : false
To: isHD = (y >= 720) ? true : false
Because some of my HD material resized to 4:3 is 960x720 which now fails to be flagged as HD.
Why not (y > 576)?
Anyway, usually isHD isn't doing anything.
isidroco
13th June 2025, 01:31
Why not (y > 576)?
Anyway, usually isHD isn't doing anything.
Is used to select correct colorspace for conversions, otherwise may change correct colors/brightness:
matrixID = (isHD == true) ? "Rec709" : "Rec601"
And (y>576) seems ok to me, although any y>=720 is considered HD, not sure about a non standard resolution (ie: y=600 ).
VoodooFX
13th June 2025, 12:29
Is used to select correct colorspace for conversions...
Not only that, anyway, usually it doesn't do colorspace conversion, unless you are doing something weird, like inputting RGB video.
StainlessS
14th June 2025, 09:28
Somebody posted a thread on default matrix.
https://forum.doom9.org/showthread.php?t=169155
What I eventually used in RT_Stats for default Matrix convertsion of RGB -> YUV:
Matrix: Conversion matrix for conversion of RGB to YUV-Y Luma. 0=REC601 : 1=REC709 : 2 = PC601 : 3 = PC709,
Default = (Width > 1100 OR Height>600) then 3(PC709) else 2(PC601). YUV not used
EDIT: You may also have to guess on black bar (letterbox) cropped image.
VoodooFX
14th June 2025, 13:51
Default = (Width > 1100 OR Height>600) then 3(PC709) else 2(PC601). YUV not used
Why those weird numbers and not: "Width > 1024 OR Height > 576"?
StainlessS
14th June 2025, 17:27
That seemed to be best numbers based on linked thread.
francocho
15th June 2025, 02:53
Is there a certain number of frames that should be the target for AnalyzeTh (per 30-60 minutes of video for example)? A setting of 15 gets just over ~1000 frames for analysis on a 50-minute video but much higher settings (eg AnalyzeTh of 44 with ~55k frames for analysis) seem to produce better deblending results, despite my source being an old XviD 576p TV capture with inconsistent quality. Is there a particular sweet spot to aim for if speed is not a concern whatsoever, or is it just a matter of testing everything from 1-255 in chunks and going by eye?
VoodooFX
15th June 2025, 12:15
Is there a certain number of frames that should be the target for AnalyzeTh (per 30-60 minutes of video for example)?
No.
Is there a particular sweet spot to aim for if speed is not a concern whatsoever, or is it just a matter of testing everything from 1-255 in chunks and going by eye?
Default is that spot IMO, "16" if clip > ~30 mins, else "30".
If I'm not happy with default result then I test AnalyzeTh 16, 30, 45 and all frames with Analyze=3.
If you think that deblend could be better then try manual editing -> https://github.com/Purfview/InpaintDelogo/blob/eceb6e89cf19355b2310445edf53c10422f03a47/InpaintDelogo.avsi#L942
real.finder
3rd July 2025, 10:01
I noted that the output will be yv12 even if I use yv16, why?! IIRC all plugins used in InpaintDelogo do work with anything 8bit like yv16 or yv24
VoodooFX
3rd July 2025, 16:42
I noted that the output will be yv12 even if I use yv16, why?!
No, output will be YV16, unless your Loc is the whole frame.
IIRC all plugins used in InpaintDelogo do work with anything 8bit like yv16 or yv24
Yes, but ID does delogo only in RGB or YV12, it could support YV16 or YV24 but then lots of stuff would need lots of additional code.
And there is maybe no bigger than 0.1% or 0.01% chance that you'll encounter non-YV12 video to delogo, even smaller chance that you'll encounter such video and you'll want the end result in non-YV12. :sly:
EDIT:
https://i.imgur.com/gsxzfds.png
real.finder
3rd July 2025, 17:56
No, output will be YV16, unless your Loc is the whole frame.
I think that is the problem
I didnt use it to delogo :) remember this https://forum.doom9.org/showthread.php?p=1929357#post1929357 ?
preclip.InpaintDelogo(mask=bfixc, Loc="0,0,0,0",dPP=0,dPPm=1,diPP=1,diPPm=0,oPP=1,oPPm=0,Inflate=0) (https://github.com/realfinder/AVS-Stuff/blob/d1735352a76c7abd305a1cbe4054e2535be36689/avs%202.5%20and%20up/Stab3.avsi#L68)
using stab3(mirror=15,fillborder=2,use_inpaintdelogo=true) with yv16 it will not work (scriptclip error) but stab3(mirror=15,fillborder=2) work fine
VoodooFX
3rd July 2025, 18:44
Then limit it's usage to YV12 clips with that option or use AvsInpaint directly.
You’re not going to add YV16/YV24 support to InpaintDelogo. Theoretically, you could, but you’d be in for the adventure of your life. :)
EDIT:
You can remove these, as these options doesn't apply to "inpaint" mode: dPP=0,dPPm=1,diPP=1,diPPm=1
real.finder
4th July 2025, 10:14
Then limit it's usage to YV12 clips with that option or use AvsInpaint directly.
YouÂ’re not going to add YV16/YV24 support to InpaintDelogo. Theoretically, you could, but youÂ’d be in for the adventure of your life. :)
I did a workaround using https://forum.doom9.org/showthread.php?p=1839137#post1839137 http://avisynth.nl/index.php/User:Raffriff42/Utils-r41_Quick_Reference#MatchColorFormat with mt_merge https://github.com/realfinder/AVS-Stuff/commit/d5f766c698580c4444cfcaae1823184da4976a7d but I think if InpaintDelogo work with more Color Formats will be better :)
EDIT:
You can remove these, as these options doesn't apply to "inpaint" mode: dPP=0,dPPm=1,diPP=1,diPPm=1
done :)
drunksunk
8th August 2025, 17:08
It has been running for almost an hour now...
https://i.imgur.com/kUZj1lX.png
VoodooFX
9th August 2025, 02:30
It has been running for almost an hour now...
https://i.imgur.com/kUZj1lX.png
An hour is not so long, there was some user who had it running for days. :D
Post your whole script.
BTW, if you don't want to see this then deselect: "Options>Accessing AviSyth in threads" in AvSPmod.
frobber
1st December 2025, 04:55
Hi,
I was able to use InpaintDelogo once before, but this time I'm stuck.
I'm trying to create a mask using Analyze, and probably doing something wrong.
My script:
v = BSVideoSource("\\MyMovie.mkv", fpsnum=24000, fpsden=1001)
a = BSAudioSource("\\MyMovie.mkv")
AudioDub(v,a)
#InpaintLoc(Loc="124,34,-292,-132")
InpaintDelogo(mask="C:\Program Files (x86)\AviSynth+\plugins64\Logo Database\CS-2.bmp", Automask=1, Analyze=3, Loc="124,34,-292,-132")
After I ran this, InpaintDelogo created two files: CS-2.bmp and CS-2_AutomaskTemp_A3.bmp.
The first one, CS-2.bmp is the same size as the movie, i.e., 1920 x 1080px.
Is this the mask I should use? I was expecting a smaller size, e.g., what I gave as the parameters to Loc. What about the second file? Is it needed?
Next, I try this:
InpaintDelogo(mask="C:\Users\Argento\Documents\Logo Database\CS-2.bmp", Loc="124,34,-292,-132", Interp=0, ShiftMasksHo=-1, GrainPP=2)
It seems to work, but there are some artifacts, apparently due to unexpected white spots in the mask.
How should I proceed?
VoodooFX
1st December 2025, 07:56
I was able to use InpaintDelogo once before, but this time I'm stuck.
...
How should I proceed?
I don't see any info about where you stuck. Just some random questions.
Is this the mask I should use? I was expecting a smaller size, e.g., what I gave as the parameters to Loc.
Yes. BMP basemask always has same dimensions as video input.
What about the second file? Is it needed?
If you are done with a basemask creation then "temp" is not needed anymore.
InpaintDelogo(mask="C:\Users\Argento\Documents\Logo Database\CS-2.bmp", Loc="124,34,-292,-132", Interp=0, ShiftMasksHo=-1, GrainPP=2)
Remove "ShiftMasksHo" & "Interp", no need to randomly add the parameters you found in this thread. :D
frobber
1st December 2025, 08:44
Thanks for your message.
Sorry, I thought my questions were clear, viz., all the masks from Github (https://github.com/Purfview/InpaintDelogo/tree/main/Logo%20Database) are sized to the watermarks, so that's what I was expecting. Apparently that is not the case, so thank you for clearing that up.
Next, there are artifacts in the output, apparently due to large white spots in the auto-generated mask. I was asking how to resolve that.
Idk if it's the best way to handle this, but I just edited the mask directly with GIMP, to black out those spots. The artifacts in the output are gone now.
VoodooFX
1st December 2025, 08:57
all the masks from Github (https://github.com/Purfview/InpaintDelogo/tree/main/Logo%20Database) are sized to the watermarks, so that's what I was expecting.
Those "ebmp" masks at GitHub are not "bmp" basemasks.
Next, there are artifacts in the output, apparently due to large white spots in the auto-generated mask. I was asking how to resolve that.
Adjust "aMix" when "Automask=1". If you didn't delete the "temp" files, the changes will be instant.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.