View Full Version : InpaintDelogo - advanced logo removal & hardcoded subtitles extraction


Pages : [1] 2

VoodooFX
31st August 2019, 21:57
##================================================================================================##
# #
# ____ _ __ ____ __ #
# / _/___ ____ ____ _(_)___ / /_/ __ \___ / /___ ____ ____ #
# / // __ \/ __ \/ __ `/ / __ \/ __/ / / / _ \/ / __ \/ __ `/ __ \ #
# _/ // / / / /_/ / /_/ / / / / / /_/ /_/ / __/ / /_/ / /_/ / /_/ / #
# /___/_/ /_/ .___/\__,_/_/_/ /_/\__/_____/\___/_/\____/\__, /\____/ #
# /_/ /____/ #
# #
##================================================================================================##


# InpaintDelogo is an advanced logo and watermark removal function using inpainting and deblending
# with an adjustable fine process to hide artifacts and get best delogo results.
# Can remove opaque, transparent, semi-transparent and some dynamic logos from video.
# Can be used to remove hardcoded subtitles or extract them to images for OCR.

# Inpainting refers to the application of sophisticated algorithms to reconstruct of lost
# or deteriorated parts of images or videos.


##================================================================================================##

Someone asked for my delogo script, so here it is: InpaintDelogo() is user friendly script for AvsInpaint plugin (plugin created by Wolfgang Boiger).
Why another script for AvsInpaint!? Because other scripts - rm_logo & InpaintFunc are both semi-broken, slow inpainting, with subpar to unusable results.

AvsInpaint is a great plugin, questionably the best tool atm to remove logos. With InpaintDelogo you can expect better delogo results than from any other tool.
InpaintDelogo can save your time by generating a logo mask automatically, get Color/Alpha masks for deblending in a second, 3x times faster inpainting than with previous user friendly scripts.

Issues with previous scripts for AvsInpaint:

InpaintFunc Deblend: Results from poor to unusable. As in practice you can't get good masks by analyzing random frames.
InpaintFunc Both: Broken. Results same as Inpaint, simply there is no code to do it.
InpaintFunc Inpaint: Works. No controls. Very slow.
InpaintFunc PP: Subpar. Broken code creates edges and PP=3 can't solve it.

rm_logo Deblend: Results from poor to unusable. Same as InpaintFunc.
rm_logo Both: Broken. Does both but can't do PP as there is no masks to do it.
rm_logo Inpaint: Works. Very slow.
rm_logo PP: Works (not for both).


Benchmarks (in brackets - fps with all new features On. rm_logo is modded for speed or it wouldn't be able to run test at all, both rm_logo & InpaintFunc runs at ~same speed. ):

InpaintDelogo v1.11 rm_logo v0.6_mod/InpaintFunc v1.15
180x180(pre cut):
Deblend 702 fps (153 fps) 587 Fps
Inpaint 33 fps 10 fps
Both 47 fps 10 fps

1920x1080:
Deblend 121 fps (60 fps) 121 Fps
Inpaint 12 fps 4 fps



Basic short guide( things you need before doing delogo ):
0) Read help/manual (at the top of the script) about parameters mentioned below.
1) Run this function to get "Loc" values: InpaintLoc(Loc="100,100,-100,-100"). Adjust "Loc" crop parameters around logo (aka "Left,Top,-Right,-Bottom"). Use even(mod2) numbers.
2) Prepare the "mask" manually, or start InpaintDelogo with "Automask=1" and "Analyze=2", automask result can be adjusted with"aMix".

Some basic delogo parameters for non-transparent logo:

InpaintDelogo( mask="D:\mask.bmp", Automask=0, aMix=0, Loc="100,100,-100,-100", Mode="Inpaint")



Version history:

# Version 3.7 : 2023/08/11. Fixed: Broken "YColorSolidIns" arg [code typo].
# Fixed: Bug with "isHD" variable.
# Added 'Mask' path check before running 'Automask'.
# New params: "UVAlphaFromY", "SubPrefix", "SubPostfix".
# Removed "colors_rgb.avsi" dependancy.
# Changed "mShow" to red instead of black.
# Version 3.6 : 2023/01/12. New conditional: Auto max "Interp" for frames where logo is in ~solid background.
# "Optimize" is split to "Optimize1" & "Optimize2".
# Burnin version number into ebmp ["Ver-", positive analyze only].
# Version 3.5 : 2022/12/27. Fixed: Dynamic mask inpainting was broken since v3.4.
# Version 3.4 : 2022/11/24. New feature: "Greyscale" parameter, affects positive "Analyze", "Deblend", "Inpaint"...
# Up to ~60% speed-up when enabled.
# Prevents chroma changes on the greyscale videos by deblend [side effect of "3.1" fix].
# FFT3DFilter replaced by Neo_FFT3D, up to ~20% speed-up.
# Version 3.3 : 2022/11/13. Corrected a code 'typo' in SubsMask2Img(), introduced in v2.10.
# Version 3.2 : 2022/10/22. New feature: Conditional optimizations with "Optimize", enabled by default.
# Up to ~1000% speed-up for slow "Inpaint" & "Interp" presets.
# Additional auto "Interp" disabling.
# New feature: Negative "dPP"/"oPP", adds denoise, enabled by default [20%-50% slow down].
# Very slow inpainting preset: Turbo=-2.
# Quick masks dump with clean "outs": DumpMasks=2.
# Various other tweaks.
# FFT3DFilter plugin is required.
# Version 3.1 : 2022/10/11. Fixed: "Deblend" with positive "Analyze" was unreliable on the colored logos.
# Version 3.00 : 2022/10/07. Fixed: A frame selection scan result wasn't saved properly when "Automask=1" and "Inpaint" mode,
# now the deblending masks generation is up to twice faster in this scenario.
# New feature: Easy use of the ebmp masks on other videos, you can input them directly with "Mask" parameter.
# Ebmp format is changed, the masks from older versions are not compatible.
# New feature: Twice faster subtitles extraction with auto intermediate file.
# It's activated by negative "Extract" values.
# Requirements: LSMASH, TWriteAVI, x264vfw.
# New params: "ReExtract", "FourCC".
# New feature: Adjustable subs detection window, useful if video has non-middle subs alignment.
# New params: "DetWinPercW", "DetWinPercH", "DetWinHoPos".
# With "Show=12" you can see the subs detection window and correlation coefficient [CorrTh/Corr].
# New: "Turbo=-1", it activates an inpainting preset more suitable for UHD - HD resolutions.
# New: "IntSpd=4", similar as above.
# Basemask change: Background should be less than full white, logo - full white.
# Swapped "Turbo" 1 & 3.
# Removed "rSize" parameter.
# Reworked "Show=2", alternative to "Show=1" for positive Analyze.
# New feature: Various parameters to manipulate the deblending masks from positive analyze [for the experts only]:
# "YAlphaTweak", "UAlphaTweak", "VAlphaTweak",
# "YAlphaSolidIns", "UAlphaSolidIns", "VAlphaSolidIns",
# "YAlphaSolidOuts", "UAlphaSolidOuts", "VAlphaSolidOuts",
# "YColorSolid", "UColorSolid", "VColorSolid",
# "YColorSolidOuts", "UColorSolidOuts", "VColorSolidOuts",
# "YColorSolidIns", "UColorSolidIns", "VColorSolidIns",
# "YOffsetIns", "YOffsetOuts", "UVOffsetIns", "UVOffsetOuts", "ShiftMasksVe", "ShiftMasksHo",
# "YAlphaExternal", "WholeDeblend", "TriggerDynamic", "DumpMasks".
# Various other tweaks.
# Avisynth+ v3.7.2 or later is required.
#
#---------------------------------------------------------------------------------------------------
#
# Version 2.17 : 2022/06/13. Option for ranged luma mask with DynMask6.
# Version 2.16 : 2022/06/12. Higher quality and faster "DynColor" mask when used with "DynLocUp".
# Faster "DynColor" alternative if parameter is string, and it supports multiple colors.
# TColorMask plugin is required.
# Version 2.15 : 2022/05/29. Spaces are allowed in "Loc".
# Version 2.14 : 2022/05/22. SubsMask2Img: New option to extract raw non-binarized images.
# Enabled by "Extract=2" in InpaintDelogo() or "Raw" in SubsMask2Img().
# New: "Raw", "RawAvr".
# Version 2.13 : 2022/05/21. SubsMask2Img: Added average luma check to catch non-sub images.
# New: "SubMinLuma", "SubSusLuma".
# Renamed: "SubSuspect" to "SubSusDur".
# Version 2.12 : 2022/05/14. Added generation of the dynamic mask by gradient magnitude map (aka "DynMask=7"/"DynTEdge").
# New: "DynTEdge", "DynTEdgeThY", "DynTEdgeInf", "DynTuneInf", Show=10, Show=11.
# vsTEdgeMask plugin is required.
# Version 2.11 : 2022/05/13. Rewrite: "DynColor" ~30%-300% faster. New: "DynMask=6/"DynTune". Removed: "Show=10".
# Version 2.10 : 2022/05/02. Added auto generation of the dynamic mask by color (aka "DynMask=5"/"DynColor").
# New: "DynColor", "DynColorTol", "DynColorInf", "Show=10".
# This dynamic mask by color can pre-patch video for other "DynMask" methods.
# Version 2.09 : 2022/04/08. Positive "DynMaskUp" is supported with "DynMask=3".
# Improved "KillNoise".
# Version 2.08 : 2022/04/07. Improved negative "KillBlobs".
# Version 2.07 : 2022/04/06. Changed defaults of the sub-parameters for "DynMask=3" (no need to set the bunch of parameters anymore).
# Version 2.06 : 2022/04/06. Fixed: "Show=3" was broken since v1.36.
# Version 2.05 : 2022/04/04. Masktools2 v2.2.30 or later is required.
# Tweaked: "DynMask=4" and positive "DynMaskUp", should be a bit faster and no more glitches.
# New: "DynLocUp" [Experimental WIP parameter for tests].
# Version 2.04 : 2022/02/11. Improved deblend quality with positive "Analyze" when frames quantity to analyze is low.
# Tweaked: A/C masks filename from negative "Analyze" ('Deep' goes to the end of the filename).
# Tweaked: "iTune", "EdgeWide".
# Version 2.03 : 2021/12/13. Tweaked "DynTune".
# Version 2.02 : 2021/12/10. Fixed: "Analyze=1" bug.
# +11% deblend speed-up.
# Tweaked "aMix". "Analyze=2" is default. Adaptive "AnalyzeTh" default [16 or 30].
# Don't search frames for analyse if 'txt' file is present and ReAnalyze=0.
# Version 2.01 : 2021/12/05. "Analyze" 3 option.
# Version 2.00 : 2021/12/04. AviSynth+ v3.7.1 or later & FrameSel plugin is required.
# New: Old Deblend delogo is superceded by the new superior one.
# New: Smart frames selection for analyze using "AnalyzeTh" & "NoBorderAt" parameters.
# New: "Automask" adapted to the new stuff and it doesn't reanalyze when "aMix" is adjusted.
# New: "Show" 7/8/9.
# Note: Old Deblend is saved as negative "Analyze",
# -3/-4 should be same as old, -1/-2 were augmented by the smart frames selection.
#


Requirements:

# Core requirements:
# AviSynth+ v3.7.2 or later ( https://github.com/AviSynth/AviSynthPlus ).
# AvsInpaint v1.3 or later ( https://github.com/pinterf/AvsInpaint ).

# Other requirements:
# MaskTools2 ( https://github.com/pinterf/masktools ).
# RgTools ( https://github.com/pinterf/RgTools ).
# GRunT ( https://github.com/pinterf/GRunT ).
# RequestLinear ( https://github.com/pinterf/TIVTC ).
# ClipBlend ( http://avisynth.nl/index.php/ClipBlend ).
# RT_Stats ( http://avisynth.nl/index.php/RT_Stats ).
# FrameSel ( http://avisynth.nl/index.php/FrameSel ).
# GrainFactory3 ( http://avisynth.nl/index.php/GrainFactory3 ).
# vsTEdgeMask ( https://github.com/Asd-g/AviSynth-vsTEdgeMask ).
# TColorMask ( https://github.com/Asd-g/AviSynth-tcolormask ).


# Requirements for fast subtitles extraction:
# LSMASH ( http://avisynth.nl/index.php/LSMASHSource ).
# TWriteAVI ( https://github.com/Asd-g/AviSynth-TWriteAVI ).
# x264vfw ( https://sourceforge.net/projects/mpxplay/files/x264vfw ).


Notes for AviSynth v2.6 users:

# Last compatible version is 1.48
# Requirement: GScript ( http://avisynth.nl/index.php/GScript ).
# "InpaintDelogo.avsi" needs to be renamed to "InpaintDelogo.avs",
# and loaded manually in AviSynth script with: GImport("C:\AviSynth 2.5\plugins\InpaintDelogo.avs"),
# or use AvsInit for autoloading ( https://forum.doom9.org/showthread.php?t=176749 ).
# Subs extraction is up to 600% slower than with AviSynth+!


Helper scripts:
A script that can extract forced cues from a full subtitle: https://github.com/pcroland/substoforced
Automatic switching between alternating logos: https://forum.doom9.org/showthread.php?t=186921


Download link:
Latest version v3.7: https://github.com/Purfview/InpaintDelogo

VoodooFX
1st September 2019, 13:19
Comparisons with rm_logo and InpaintFunc:

Easy logo to deblend:
Original (zoomed in few times):
https://images2.imgbox.com/b1/54/t3qx5ZGs_o.png

Deblended: (1-InpaintDelogo, 2-InpaintFunc, 3-rm-delogo)
https://images2.imgbox.com/10/43/GC3AjRpB_o.png
https://images2.imgbox.com/8a/10/SAZtkOmw_o.png
https://images2.imgbox.com/36/f9/GqlAbiNp_o.png

Inpainted: (1-InpaintDelogo, 2-InpaintFunc, 3-rm-delogo)
https://images2.imgbox.com/c8/bf/Sk40SDKS_o.png
https://images2.imgbox.com/7c/a0/ve6Vng9e_o.png
https://images2.imgbox.com/67/14/EJXfzarE_o.png


Both logo:
1-Original, 2-InpaintDelogo, 3-rm_logo:
https://images2.imgbox.com/85/48/6jtR55VB_o.png
https://images2.imgbox.com/de/29/sEaKlxdV_o.png
https://images2.imgbox.com/93/ac/ZHMTsV14_o.png


Hard logo to deblend:
Deblended:
1-Original, 2-InpaintDelogo, 3-rm_logo/InpaintFunc(they look similar):
https://images2.imgbox.com/46/5c/1vdzaFIt_o.png
https://images2.imgbox.com/2e/53/tROrZREl_o.png
https://images2.imgbox.com/06/fd/vRzas4zP_o.png

johnmeyer
1st September 2019, 15:43
Interesting work. Thanks for doing that.

I've spent a lot of time using Delogo inside of Virtualdub, and even created a YouTube tutorial for it:

Tutorial on Delogo (https://www.youtube.com/watch?v=Z12TutFSg8c)

I did that tutorial in response to a long thread about how to eliminate a sensor defect from a camera. This is a considerably easier job than logo/bug removal and one that Delogo was able to do with near-perfection.

I have not used any AVISynth logo removal tools, but I have used all the features of Delogo, including training it for removal of semi-transparent bugs, and specifying frame ranges for TV shows where the logo comes and goes, or moves around.

For me, the biggest need in advancing the state of the art is the blending algorithm. When the background is uniform and dark, such as the edges of a stage performance where the talent is brightly lit, but the wings of the stage are dark, the removal can be perfect. However, if the video was shot outdoors in the daylight, and the camera pans, you can get some pretty annoying results. For some videos, I just give up and leave it as is because the artifacts from the removal are worse than looking at the bug.

The problem is that the inpainting is nothing more than a blur function.

I know nothing about the technology of the existing AVISynth DLL you are using because I haven't used it, but the example above of the "Hawe Knho" shows the Inpaint blending looking pretty similar to Delogo. This is not meant as a criticism, but instead as a way to lead to my main question:

Is there a reason why I would want to use this instead of continuing to use Delogo? What are its advantages?

I am always looking for something that works either better or faster. Delogo is plenty fast, and it is also easy to use because it lets me tune the mask parameter interactively using the VD "preview" display. I want something that can make the logo disappear, with almost no residual evidence that it was there.

Is this possible?

I think it might be. If I were going to do development in this area, I'd look at how RemoveDirt does its painting. I just did a restoration of one of the most spectacularly degraded movies I've ever dealt with, a one-of-a-kind 16mm print of a 1963 AFL football game. It had been badly stored, and the emulsion stuck to the backing on the adjacent film in the reel, so once every revolution of the big film reel, there were huge (1/3 of the frame) chunks of mottled image. Where the emulsion had been completely removed, and there was no image, I had to reconstruct by hand from adjacent frames. However, when it was just a big stain, I used a heavily modified version of RemoveDirtMC to fix it, and when it worked, the reconstructed frame was near-perfect.

I haven't posted the results of this work, because it is copyrighted, but I did post a very short before/after of some Polavision restoration. This instant movie film from Polaroid had much of the same problem, because the film was developed in the cassette and then stayed there for 40+ years and, because of the residual chemicals, stuck together and, when unwound after all those years, the emulsion would come off, resulting in a black spot on one frame, and a matching blank spot a few frames later. Here is a few "before/after" frames from that work. You'll need to freeze at a random frame to see the results of what RemoveDirt was able to do. I did no manual work at all; it was all done by RemoveDirt.

Before After Polavision (https://www.youtube.com/watch?v=gzTistk2Ms0)

Whatever inpainting algorithms RemoveDirt uses might provide some ideas for how to do better logo removal.

StainlessS
1st September 2019, 18:00
I think that you will find that RemoveDirt uses temporal info from adjacent frames to fix spots/dirt, logo is entirely different being also on adjacent frames.

Looks nice VDX.

johnmeyer
1st September 2019, 19:19
I think that you will find that RemoveDirt uses temporal info from adjacent frames to fix spots/dirt, logo is entirely different being also on adjacent frames.Thanks, StainlessS. I wondered to myself as I was writing that last post whether that might be the case and, if that is the secret, you are right: it would be mostly useless for logo removal.

Having said that, in theory (maybe not in practice) you could use motion estimation from adjacent frames to predict what should be under the logo in the current frame and come up with a better replacement. It might work for my example of what happens when the camera pans. However, in practice, it probably wouldn't be useful, and would be of no help at all unless there was motion going through/under the logo.

P.S. The other area for improvement would be semi-transparent logos. In that case you DO have information on what is behind the logo. My experience, even with Delogo, is that if the logo is really faint, so you can see lots of detail behind it, you can get remarkably good, artifact-free removal.

VoodooFX
1st September 2019, 23:55
Is there a reason why I would want to use this instead of continuing to use Delogo? What are its advantages?
I am always looking for something that works either better or faster.

Delogo is pretty outdated, there were tools that perform way better, and InpaintDelogo does better than those other ones. Let me know if you find tool/script doing better job than InpaintDelogo. :cool:

The problem is that the inpainting is nothing more than a blur function.
You are mixing up something, it's not a "blur" function or a temporal thing like RemoveDirt.
Here is good starting point to read about it - Inpainting (https://en.wikipedia.org/wiki/Inpainting)

Having said that, in theory (maybe not in practice) you could use motion estimation from adjacent frames to predict what should be under the logo in the current frame...
It sounds good only in theory, in practice it would be very complicated task to implement something to fit various cases of motion, actually it was implemented and was called "msu" something.

StainlessS
2nd September 2019, 02:13
John, the S_Exlogo() thing I did [ based on DeKafka() ], is purely blurring the logo [using data from spatially outside of the logo], but not the AvsInpaint.dll based scripts [as is this one],
however, S_Exlogo() is easy to set up and goes like the clappers, and so long as you are easily pleased, is quite good [a man on a galloping horse might not notice any remaining logo].

MC based delogo [as with mvtools] is doomed to failure, methinks.
[neural network stuff might at some future date be much better than today, but would likely be a somewhat unstable [although maybe less so if 3D neural networks],
ExInpaint [another dll] uses something along those lines [purely spatial, I think] and is a little temporally unstable but good for single frames (see the demo image in docs)]

EDIT: Think ExInpaint is using the "Exemplar-based image inpainting" in above link, seem to remember the word 'Exemplar' being used in the docs [and source for the plugin name].

from above VDX link
Exemplar-based image inpainting attempts to automate the clone tool process. It fills "holes" in the image by searching for similar patches in a nearby source
region of the image, and copying the pixels from the most similar patch into the hole. By performing the fill at the patch level as opposed to the pixel level, the
algorithm reduces blurring artifacts caused by prior techniques.

EDIT:
it was implemented and was called "msu" something.
MSU Subtitle and Logo Remover:- http://forum.doom9.org/showthread.php?t=95955
Use this
global VDub = "C:\Programme\AviSynth 2.5\VDub\plugins"

LoadVirtualdubPlugin(VDub+"\MSU_DeLogo.vdf", "_MSUDeLogo")


The open VirtualDub. Add to the filters the MSUDelogo-Filter. Tweak it, so it remove your Logo fine. Go to
FILE ->
SAVE PROCESSING SETTINGS...

and save them to a file. Open The file in a texteditor and look for line like this one:
VirtualDub.video.filters.Add("MSU Subtitle&Logo Remover");
VirtualDub.video.filters.instance[0].Config(0, 0);


Now copy allparameters in Config and use the to Call the Filter in Avisynth this way:
ConvertToRGB32._MSUDeLogo(0, 0)

I tried the filter but does not get good results with it. It is also very slow. Have you better results with this filter?

Many MSU Vdub filters do NOT export some of the settings, [described in code above as Config] and so cannot be used properley in Avisynth, [settings only exist when set up within VDub, and
cannot be saved and reused at a later date, even within VDub], dont know if MSU_Delogo is one of those which do not save ALL settings.

EDIT: Dont know/recall what method AvsInpaint dll is using [the one used by this script].

VoodooFX
3rd September 2019, 17:34
the S_Exlogo() thing I did [ based on DeKafka() ], is purely blurring the logo...

I was thinking to add Very Fast mode where s_Exlogo could do post-processing, could be useful for big logos where there is no point to use slow inpainting. But forgot about it as I didn't wrote that to todo list :) .
I strikethrough that list today, only one line left - "moving logo", it should be doable in theory but could be over my head, maybe I'll replace it with "very fast mode". :D

MSU Subtitle and Logo Remover...

I looked at MSU site, it is called MSU Logo Remover 2.xx, MC implementation is broken, no open source...

Dont know/recall what method AvsInpaint dll is using [the one used by this script].

Ideas are implemented from these papers:

Folkmar Bornemann, Tom März: Fast Image Inpainting Based on Coherence Transport.
Joachim Weickert: Coherence-Enhancing Shock Filters.
Alexandru Telea: An Image Inpainting Technique Based on the Fast Marching Method.
James Sethian: Fast Marching Methods.

StainlessS
3rd September 2019, 18:07
I should go back to my current mod for s_Exlogo(), It stalled a bit when I bumped into a bug in r2772, fixed now in bugfix avs+ test build (r2915), but been a bit busy of late.

I've seen some delogo stuff that was somewhat like s_ExLogo(), but seems to take most data from mostly one side (inner most long side), but partially mixed with other sides,
it in some cases was way better than s_ExLogo, I could not figure out how it worked. [sending you a link, not suitable clip for general viewing].

VoodooFX
4th September 2019, 22:56
I've seen some delogo stuff that was somewhat like s_ExLogo(), but seems to take most data from mostly one side (inner most long side), but partially mixed with other sides,
it in some cases was way better than s_ExLogo, I could not figure out how it worked. [sending you a link, not suitable clip for general viewing].

That looks pretty simple, take 2 pixels at the top resize them to the size of the hole. I don't see any interpolation from other sides.

StainlessS
4th September 2019, 23:47
Oh, simple as that, I guess I was seeing stuff that wern't there.
Thanks awfully :)

EDIT: sometimes less is more.

VoodooFX
5th September 2019, 00:29
I just tested it to be sure. Sometimes in original I see some discrepancies, but I don't have any logical explanation, maybe some compression/resize artifacts maybe broken delogo code. Like this one:

2x Size
1) original (SD), arrows to some artifacts, they appear and disappear without any apparent reason, but mostly it looks same as "3".
2) s_exLogo, delogo of "original", sides and bottom is blocked from interpolation, 4px left at top, "Amount=256".
3) 2px from the top resized. :)

https://images2.imgbox.com/d1/ff/dzI1b30l_o.png

manolito
5th September 2019, 01:07
You guys made me curious so I did some tests comparing s_ExLogo to the old LogoAway plugin by Krzysztof Wojdon. I did not test InpaintDelogo for several reasons (too complicated, I hate plugins with dozens of params, have to select frames and create masks manually, requires AVS+, no option for logos over black borders). Here are the results:
https://www.sendspace.com/file/8nvhi6

For s_ExLogo I used the default parameters, for LogoAway the UGLARM method was used with the blur slider set to max (all the way to the right).

https://i.postimg.cc/9fFcJcFF/LogoAway.png (https://postimages.org/)

LogoAway also has a much faster XYBlur mode which creates results very similar to s_ExLogo. But UGLARM does look so much better in almost every situation that I have been using this mode exclusively over the last couple of years.

Now I would like to challenge VooDooFX if his script can create a better looking result. My requirements are pretty simple:

1. Just 1 mode for opaque logos. I do not care for semi-transparent logos.
2. No manual mask creation. All I want to provide to the plugin are the logo coordinates.
3. I do not mind if the logo area gets blurred strongly. All I want is that my attention is not taken away from the movie itself, so the delogo'd area should be as unobtrusive as possible, mainly I hate when this area shows strong flickering.
4. Easy to use and reasonably fast.

Tough challenge, I know. For now I will stick with LogoAway, s_ExLogo is no serious contender IMO.


Cheers
manolito

StainlessS
5th September 2019, 14:22
Mani, for s_ExLogo, sPow=1.0 (linear) should be about same as your XYBlur mode [I think].

VoodooFX
5th September 2019, 20:26
Now I would like to challenge VooDooFX...

Do you want some fast preset? I'll look what can be done. Can you PM link to that unresized logo?

manolito
5th September 2019, 20:46
Do you want some fast preset? I'll look what can be done. Can you PM link to that unresized logo?
Of course faster is better, if the result does not suffer too much.

For the "unresized logo" I don't know what you mean. The original source is a German DVB-T2 capture which means 1080p @ 50fps. Applying logo removal at this resolution is forbiddingly slow, and since my target format is SD (704 x 396) I perform my logo removal after resizing which is way faster.

So you need to use the "Source.mkv" file in my upload as your source for the logo removal.

VoodooFX
5th September 2019, 21:07
It's just for personal tests, logo is "both" and I don't have much logos to test that mode on. If you have source then I would be happy with just the logo cut with surrounding of ~80 px (no need black bar), ~5-10 mins, ~Lagarith YV12, should include frame where logo is in a black background.

VoodooFX
6th September 2019, 23:41
New version 1.12 attached at original post.
Various tweaks for speed and quality. Changed "Inflate", "Deep" now is not re-analyzed on every load, selectable number of passes for "Deep".
New "Turbo" presets parameter for fast and blurry logo removal, few other parameters.

v1.12 Deblend, 2x zoom:
https://images2.imgbox.com/e8/c5/y4Y0IVHq_o.png

v1.11 Deblend, 2x zoom:
https://images2.imgbox.com/c1/85/d518TgUm_o.png




You guys made me curious so I did some tests comparing s_ExLogo to the old LogoAway plugin by Krzysztof Wojdon. I did not test InpaintDelogo for several reasons (too complicated, I hate plugins with dozens of params, have to select frames and create masks manually, requires AVS+, no option for logos over black borders). Here are the results:
https://www.sendspace.com/file/8nvhi6

For s_ExLogo I used the default parameters, for LogoAway the UGLARM method was used with the blur slider set to max (all the way to the right).



LogoAway also has a much faster XYBlur mode which creates results very similar to s_ExLogo. But UGLARM does look so much better in almost every situation that I have been using this mode exclusively over the last couple of years.

Now I would like to challenge VooDooFX if his script can create a better looking result. My requirements are pretty simple:

1. Just 1 mode for opaque logos. I do not care for semi-transparent logos.
2. No manual mask creation. All I want to provide to the plugin are the logo coordinates.
3. I do not mind if the logo area gets blurred strongly. All I want is that my attention is not taken away from the movie itself, so the delogo'd area should be as unobtrusive as possible, mainly I hate when this area shows strong flickering.
4. Easy to use and reasonably fast.

Tough challenge, I know. For now I will stick with LogoAway, s_ExLogo is no serious contender IMO.


Cheers
manolito

a) "too complicated" - It's relatively simple.
b) "dozens of params" - It's not mandatory to use them all, you can use only 2 parameters if you want. LogoAway has dozens parameters too...
c) "have to select frames and create masks manually" - Not mandatory. Quote from op - "can save your time by generating a logo mask automatically".
d) "requires AVS+" - Not mandatory.
e) "no option for logos over black borders" - Does it prevent you to delogo? You said it has too many params already. :)

1) There is already such mode.
2) Mask generation is automatic already.
3) You can do that already. Why you don't want to use deblend? It would remove your logo almost without a trace.
4) It is easy already. Added new fast "Turbo" presets parameter in v1.12.

https://thumbs2.imgbox.com/8c/8c/LA1EL2fB_t.png (https://i.postimg.cc/9fFcJcFF/LogoAway.png[/url)

Whole comparison video: [url]https://we.tl/t-kcAI66C8GQ

manolito
7th September 2019, 02:08
Thanks for these comparisons... :)

Especially the "Turbo=1" mode impresses me. In most cases it looks just as good or even better than the slower "Turbo=3" mode. This mode is something I would really be interested in...

The speed comparison with LogoAway is a little unfair. I use an "Active Area" approach where VDub just processes the actual logo. It was inspired by Didées DeLogo script, but a little bit expanded and added exception handling with the help of gavino. Makes it much faster.

Your new version is not approved yet by a mod, please upload it somewhere else.

For the AVS+ requirement this is what you say in the first post of this thread:
Requirement:
Avisynth+ r2915 or newer ( https://github.com/pinterf/AviSynthPlus )
Please tell me what I have to change under classic AVS 2.60.

And then I would like to know how you can preview your results. For LogoAway it is easy: In VDub you can visually see the different results when you change any of the parameters. In AviSynth would I have to use AVSP(mod) to interactively see the results when changing parameters?

And for treating logos which are partly over letterboxed (or pillarboxed) areas do you have any special treatment for such logos? LogoAway and s_ExLogo do have provisions for such logos.

manono
7th September 2019, 03:13
Your new version is not approved yet by a mod...

I'll do it immediately.

Please tell me what I have to change under classic AVS 2.60.

Me too. I have no interest in AviSynth+ yet and do a lot of logo removal using InPaintFunc.

VoodooFX
7th September 2019, 03:41
Especially the "Turbo=1" mode impresses me. In most cases it looks just as good or even better than the slower "Turbo=3" mode. This mode is something I would really be interested in...


I think you are concentrating on some frames too much, in general Turbo=3 is less alive.
Turbo=1 is using bit lower oPP=6 (opaque blur) as it gets more blur than 1/2 by other means, when Turbo=3/Turbo=2 is using oPP=7, you can change options to whatever you want, like to oPP=8 (max amount of unhealthy blur). Turbo are not hard presets.

Avs+ is my recommendation, it is faster maybe ~10%, script works with Avs 2.6 too without any changes.


The speed comparison with LogoAway is a little unfair. I use an "Active Area" approach where VDub just processes the actual logo.

LogoAway benchmark didn't go through conversion to YV12, so it's unfair for others. :) I benchmarked that small pre-cut area , it would be close to "Active Area".


And for treating logos which are partly over letterboxed (or pillarboxed) areas do you have any special treatment for such logos?
Just don't select that border with Loc (I didn't tested such case).


And then I would like to know how you can preview...
I use Notepad or other txt editor like PSPad, I never had any need for something fancy like AvsMod, I just need preview, and I get it from programs I already have installed.
You can open your avs script with same Vdub, change something in your script>save then in VDub>File>Reopen and it will refresh preview at same frame you are looking at.

VirtualDub2 has its own avs script editor and F5 will do as above.

Then MeGUI has script editor and preview, I like it most as preview window is not bonded to main program.

johnmeyer
7th September 2019, 04:53
That's a great comparison video.

I wonder if s_Exlogo's settings were correct. As I indicated earlier, I've done a lot of logo removal using Delogo, and you can set it so its "inpainting" is done primarily from pixels above and below the logo, which is what I see in the s_Exlogo example.

Your function does a good job, but it does look similar to what I get with Delogo. If you have a version of the original, I'd be happy to create a demo of what can be done with that, and see how it compares to yours.

manolito
7th September 2019, 12:29
If you have a version of the original, I'd be happy to create a demo of what can be done with that, and see how it compares to yours.

The file "Source.mkv" from this link...
https://www.sendspace.com/file/8nvhi6

VoodooFX
7th September 2019, 14:43
That's a great comparison video.

I wonder if s_Exlogo's settings were correct. As I indicated earlier, I've done a lot of logo removal using Delogo, and you can set it so its "inpainting" is done primarily from pixels above and below the logo, which is what I see in the s_Exlogo example.

Your function does a good job, but it does look similar to what I get with Delogo. If you have a version of the original, I'd be happy to create a demo of what can be done with that, and see how it compares to yours.
That is how s_Exlogo looks. Blur looks similar to blur, I know what Delogo does, I can tell you from my memory:

You have to do mask manually.
It is slow.
Bit more solid "smoked glass" look.
Doesn't hide edges.

Advantages over LogoAway:
Interpolates from the edges of the mask, so doesn't damage good parts of the frame.
Probably faster.

Advantages over InpaintDelogo:
None.

StainlessS
7th September 2019, 15:40
By the way, it was mostly the likes of the angled vertical tan/brown edge on left below (top & bottom images) that threw me,
center one s_exlogo is vertical edge, others angled, (did not realize where the angle was coming from [is from 2 pixel resize]).
https://images2.imgbox.com/d1/ff/dzI1b30l_o.png

EDIT: Dekafka does a 2 pixel resize, but I did not like that and only use single pixel nearest to logo in resize (with opposite pixel from bottom edge),
seems that 2 pixel resize may be not so bad after all [but still seems weird to me, shifting two pixels and resizing].
The dark 'lip' at top of tan/brown edge #1(top) is likely due to the two pixel resize, and seems to have been cropped off for the bottom image #3.
[The lip is original image, the faded pixels below due to two pixel resize make it visually stand out]
EDIT: Also the top image seems to have 'more' angle than bottom image, something else seems to be going on there.
EDIT: And where is that brown line coming from [above to the left of left red arrow].

EDIT: Above requires no comment, just some observations.

VoodooFX
7th September 2019, 17:10
EDIT: Also the top image seems to have 'more' angle than bottom image, something else seems to be going on there.
EDIT: And where is that brown line coming from [above to the left of left red arrow].

a) We don't know history of that clip, delogo could be done on HD (interpolating ~4 top pixels), then clip resized to SD.

b) Do you mean that oblique line? It is above delogoed area, and it hits other vertical line just ~3-4px above delogoed area.

If you interested you can look at xLogo interpolation, it is fast and tries to make choices on vertical lines over horizontal (with multi passes), what ends up with very flickery interpolation.

manolito
7th September 2019, 19:35
I spent the better part of the afternoon testing InpaintDelogo, and in short the result is that I will abandon LogoAway and use InpaintDelogo instead... :D

As my source I used the same "Source.mkv" clip I uploaded (because it is very typical for my use cases). I used the Inpaint mode (part of the logo is semi-transparent, the other part is opaque), and I tried it without Turbo, Turbo=1 and Turbo=3. I also tested adding the "KillShape=1" parameter.

First of all I must say that the Automask feature works well. Just some small white spots which did not affect the results at all (I compared it to the results after manually cleaning up the mask).

For the different Turbo modes I could not point my fingers on any significant difference in visual quality. Even the result with Turbo OFF did not look noticeably better than Turbo Mode1. Of course this could be because my source was SD (or because my vision is degrading too much - getting old...).

These are the speeds I got:

LogoAway: 76.5 fps
Inpaint Turbo Off: 64.5 fps
Turbo=3: 88 fps
Turbo=1: 93 fps

Using "KillShape=1" with the Turbo modes slowed it down just a tiny bit, but the results did not look any better to me.

And all InpaintDelogo methods I tested looked way better than LogoAway, no doubt about it. So a big Thank You for your efforts... :thanks:

Some questions:
What about interlaced sources? Will they work out of the box? Or should I make the logo coefficients MOD4 instead of MOD2? And if GrainFactory functions are added, the GrainFactory doc says that it only supports progressive input.

I also tested a source where the logo is partly over the top letterbox. You said:
Just don't select that border with Loc (I didn't tested such case).
but this does not work. If I omit the top border value then the script will assume 0 as the value. Creating the AutoMask will fail with a "Mask Full" error message. The same thing happens when I set the top border value to the real top position of the logo.

The only way to get it working was to set the top value for the logo to the top of the movie area. This results in a clip where the logo part which lies over the top letterbox area will not be removed, this part needs to be cropped off after the logo removal. Pretty much the same procedure I have to use with LogoAway.


Cheers
manolito

VoodooFX
7th September 2019, 21:39
Those benchmarks doesn't look right as Turbo=1 is ~15x faster than Turbo=0, avs scripts should be benchmarked with AVSMeter. And I do it with uncompressed clip.
Or maybe you override Turbo presets by keeping other InpaintDelogo parameters in your script. Turbo just changes defaults. Like KillShape=1 is already in Turbo>=1 presets.
If you have mask generated then InpaintDelogo(mask="c:\mymask.bmp", Loc="0,0,-0,-0", Turbo=1) is enough for what you do (at least for that source clip you have shared), I use Show=2 to see only Loc area zoomed in.

Delogo needs to be done after deinterlacing, not before.

As with borders, in theory you need Loc at least 8 pixels from logo edges to generate good mask (Automask=1), you can use less but mask will be not that good, but as you just want to blur everything then it doesn't matter I guess.
When you done generating mask, then Loc will have different purpose, then you can set one of its edge to the back border without including it. If you have some problems with it then share that logo so I can look what is really going on.


First of all I must say that the Automask feature works well. Just some small white spots which did not affect the results at all (I compared it to the results after manually cleaning up the mask).

That bmp mask is just a base mask, inside InpaintDelogo it goes through various transformations, you can see them with Show=1 parameter.

StainlessS
8th September 2019, 00:04
b) Do you mean that oblique line? It is above delogoed area
Oops, yes of course.

manolito
8th September 2019, 20:34
Those benchmarks doesn't look right as Turbo=1 is ~15x faster than Turbo=0, avs scripts should be benchmarked with AVSMeter. And I do it with uncompressed clip.
Or maybe you override Turbo presets by keeping other InpaintDelogo parameters in your script. Turbo just changes defaults. Like KillShape=1 is already in Turbo>=1 presets.


Those benchmarks are totally right because they represent the real world conversion speeds. Just benchmarking the AVS script with AVSMeter does not tell you anything about the real world conversion speed where the bottle neck may be somewhere else (X264 in my case). So all my speed benchmarks are done in a "real" conversion scenario, not just using AVSMeter...


Some new findings while trying to establish a stable workflow for my SD conversions using InpaintDelogo:

For sources where the logo is partly in the black borders area your suggestion to just omit this border value after creating the mask does not work. An example for a logo which is partly in the top border area where the top movie border is at 52 pixels down from the top frame border:

For the logo location you need to set the top logo value to 52, then create the logo mask. This will keep the part of the logo which is in the black border area. To get rid of it you need to apply the command "Letterbox(52,0)" in the AVS script after the InpaintDelogo command.

I did some more tests with such a source (downloaded from the ARTE Mediathek, they usually place their logo partly in the black border area). I found the speed benchmarks very interesting:

Turbo=1: 80 fps
Turbo=3: 79 fps
Turbo=0: 71.5 fps

There is almost no difference between Turbo1 and Turbo3 mode, and even not using Turbo mode at all is only slightly slower. My conclusion is that I will probably ditch the Turbo modes completely. Of course this may be different for HD conversions, but I don't do those...

VoodooFX
9th September 2019, 15:16
Those benchmarks are totally right because they represent the real world conversion speeds. Just benchmarking the AVS script with AVSMeter does not tell you anything about the real world conversion speed where the bottle neck may be somewhere else (X264 in my case). So all my speed benchmarks are done in a "real" conversion scenario, not just using AVSMeter...

That way you are benchmarking Decoder+delogo+Encoder , that doesn't tell us much about delogo speed.
When we know real delogo speed then we can know how much Encoder's speed will be influenced by it.

Here is real delogo speeds (on i5-2450M 2.5GHz):
InpaintDelogo, Turbo=0 45 fps
InpaintDelogo, Turbo=3 304 fps
InpaintDelogo, Turbo=2 497 fps
InpaintDelogo, Turbo=1 736 fps

LogoAway, UGLARM, max Exponent, 61 fps
s_Ex_Logo 5288 fps



For sources where the logo is partly in the black borders area your suggestion to just omit this border value after creating the mask does not work.

I meant don't include black border in selection, not to omit setting the parameter.
I found such logo to test, it works as expected, like I wrote in a post above.

manolito
9th September 2019, 20:53
Alright, getting familiar with the InpaintDelogo method and really liking the results... :cool:

A feature request:
Is there a way to speed up the AutoMask creation?
I only use SD (704x396) clips as the input, but even then it takes almost 20 minutes to create the mask for a 2 and a half hour source clip. (Core i5 3rd generation CPU with 8GB of RAM, AVS+ with MT enabled using 4 threads.) The created mask is usually excellent, but there should be a way to make it faster, maybe by using only a percentage of the source. For a HD source clip of such a duration the AutoMask creation is useless for me, it takes more than an hour on my computer.

VoodooFX
9th September 2019, 22:22
I looked around how to remove moving logo, only solution I see is using Avisynthtrackin (https://sourceforge.net/projects/avisynthtrackin/), to automate everything would involve Python, I'm too lazy for that.


Is there a way to speed up the AutoMask creation?
I only use SD (704x396) clips as the input, but even then it takes almost 20 minutes to create the mask for a 2 and a half hour source clip. (Core i5 3rd generation CPU with 8GB of RAM, AVS+ with MT enabled using 4 threads.).

There is, instant analysis can be done with Analyze=4 or Analyze=3.
For "4" you need to enter frame number (for example Fr1=123) where logo is in a black/dark background. Frame numbers you can see in MeGUI or VirtualDub.
For "3" you need to enter black/dark and white/bright frames (Fr1 and Fr2).
If logo stays in that background longer than a second then you can add another parameter "FrS=3".

Default is Analyze=1 - ~3% of the clip, you can use Trim to limit it more.

Using MT will slow down encoding with InpaintDelogo, and will definitely slowdown Analyze part, if you are getting 20 mins with Prefetch(4) then removing it would speed Analyze up to 4 mins.
Try to measure encoding fps without MT. You are not using VirtualDub for that?

VoodooFX
9th September 2019, 23:53
Here is benchmarks AVS+ vs Classic AVS:

AVS+ 2915 AVS ST 2.6.0.6

InpaintDelogo, Turbo=0 45 fps 44 fps
InpaintDelogo, Turbo=3 304 fps 194 fps
InpaintDelogo, Turbo=2 497 fps 250 fps
InpaintDelogo, Turbo=1 736 fps 298 fps
s_Ex_Logo 5288 fps 3940 fps

manolito
10th September 2019, 01:29
Thanks for these benchmarks, but as I said before, they do not mean a thing to me. If the overall speed including decoding, AVS script plus encoding gives me an identical speed for Turbo=1 and Turbo=3, why in the world would I try to use the method which supposedly results in a lower quality? Makes no sense to me...

For the AutoMask feature when I want to get a better speed I was under the impression (from reading the doc) that I cannot use the "Analyze" parameter when I use the "Mode=Inpaint" parameter. And this is the only mode I ever use.

I tested it using "AutoMask=1" and "Analyze=1" and "Mode=Inpaint" in the command for creating the mask, and indeed the "Analyze=1" parameter was ignored. Creating the mask took just as long as without the "Analyze=1" parameter, and the resulting mask looked the same.

VoodooFX
10th September 2019, 02:06
Automask=1 is like separate function it only generates a base mask.

Only these parameters are used for Automask=1:
"Analyze" (and its sub-parameters, except "ReAnalyze"), "aMix", "mask" and "Loc" parameters will be used.

Mode is delogo parameter, it is silently ignored when Automask=1.

manolito
10th September 2019, 20:37
Still streamlining my workflow for InpaintDelogo, this time I used a typical real-world captured movie from German DVB-T2 (1080p @50fps, HEVC), duration was 100 minutes. I always convert these captures to 702x396 @25fps AVC. For InpaintDelogo I only use the Inpaint mode, I have no use for the Deblend or Both modes.

This is what I found so far:

Trying to use AutoMask to create the base mask was frustrating. It uses "Analyze=1" by default which means that it uses 3% of the source to create the mask. For my source file this is unusable, I canceled the process after 40 minutes. I got it working by increasing the "every" parameter in "SelectRangeEvery" from 33 to 400. Values above 400 caused the mask to deteriorate, but for this source 400 was perfect. It took 3 minutes to create a perfect mask. But of course this may be different for other source files.

The other and faster way is to use "Analyze=4" and specify a frame where the logo is above a perfect black background. I believe that for only using Inpaint it does not make sense to use "Analyze=3" because I will not do any color deblends.

Next problem was that my conversion crashed when I had activated MT mode. So far I have solved it by forcing InpaintLogo to MT_SERIALIZED, let's see if this helps permanently. Turning off MT mode is an option, but this drops my speed from 29fps to 25fps.

Still very happy with the resulting quality, even with Turbo=1 it is way way better than for LogoAway, and it is also faster.


Cheers
manolito

johnmeyer
10th September 2019, 20:44
I haven't yet tried InpaintDelogo, but for opaque masks is there any benefit to having it auto-create the mask? Or, is it able to track bugs which move? If so, that would be very useful. But, for static bugs, it only takes a few seconds to paint a mask, so there's no benefit in waiting minutes (or more) for the auto-creation.s

For semi-transparent bugs, auto-creation is mandatory, of course.

manolito
10th September 2019, 20:59
Just curious, but how do you make a BMP B/W mask at the required size and resolution in just a few seconds? I sure cannot do this, so using an AutoMask feature which only takes a few minutes doesn't sound too bad to me. And the other option when you can find a frame with the logo above a black background is lightning fast.

I always treat semi-transparent logos as if they were opaque, I'm too impatient I guess...

VoodooFX
10th September 2019, 22:29
If you know how to use PhotoShop then it is fast doing same thing as Automask=1: save dark frame, load it into PS then with Levels get mask, but if you already have black frame then there is no point wasting seconds/minutes with external programs when you will have same in milliseconds with Automask=1.

If it is only InpaintDelogo in a script then MT slows down encode. Very quick test, very slow x264 settings (1000 frames):

Only InpaintDelogo / Prefetch(4) - 12fps
Only InpaintDelogo / No MT - 16fps

InpaintDelogo + other 3 heavy filters / Prefetch(4) - 10fps
InpaintDelogo + other 3 heavy filters / No MT - 5fps

We can see that MT fps increase on other filters outweighs fps loss on InpaintDelogo here, or whatever MT does, I'm not an expert on that...
If it crash with Prefetch(4) then use 64bit. Or you can try Prefetch(3).

StainlessS
11th September 2019, 13:43
https://i.postimg.cc/9fFcJcFF/LogoAway.png (https://postimages.org/)


Mani, where did you get above info ?

Might try doing UGlarm thing, and add to s_ExLogo2()

EDIT: I presume that 'distance' is by Pythagoras.

manolito
11th September 2019, 14:24
It comes from here:
https://www.sendspace.com/file/odmobw

It is for version 3.01 (the latest plugin version is 4.01), but this is the last help version I could find...

StainlessS
11th September 2019, 15:04
Thanks Mani, was in plugin docs eh, I was trying to find webpage.

Bout 25% done now, will initially be for SOME avs standard colorspaces only, I will though want avs+ eventually. [will also supply v2.58 plug + x64]

Doin' it summick like this,


Function Uglarm(clip c, [* Avs v2.58 & v2.60 std supports YV12/YUY2/RGB32/RGB24 : Avs+ r2915+ also YV16, YV12, YV24, Y8 *]
\ int LogoX,int LogoY,Int LogoW,Int LogoH, [* ALL coords can be -ve, where RHS/BOT relative, LogoW & LogoH can additionally be 0 where RHS/BOT relative*]
\ int "ClipX"=0,int "ClipY"=0,Int "ClipW"=0,Int "ClipH"=0, [* ClipW, and ClipH coords can be zero or -ve, where RHS/BOT relative (but ClipX:ClipY cannot be -ve) *]
\ float "SAR"=1.0, [* Sample (Pixel) Aspect Ratio (x/y)*]
\ float "BlurPower"=1.0, [* 1.0 -> ??? *]
\ Int "ShowMode"=0 [* 0=Overlay Logo Patch(Clipped Logo), 1=Overlay Logo Patch(Clipped) & Border, 2=DeLogo *]
\ Bool "Blank"=false [* Where ShowMode==2 and Blank==True then Blank to Black any border area (border is outside of Clip args) *]
\ )

EDITED:

EDIT: I'm not taking any pixel Aspect Ratio into account for distance, dont think it worth the (small) effort. [EDIT: See SAR above]

EDIT: ShowMode = 1 Example showing Patch Area (after clipping, in Yellowish), Clipped out area (In Reddish), and border Area in Purplish.
Yellowish + Reddish is original non clipped Logo Coords.

Avisource(".\Parade.avi")
Crop(0,0,Width/4*4,height/4*4) # Make Mod 4

ConvertToRGB24 # Internally Converted to RGB32 and back to RGB24 again [Layer() requirement, supports only YUY2 & RGB32].

LogoX = -100 # Can be -ve, Width relative
LogoY = -100 # Can be -ve, Heigth relative
LogoW = -20 # Can be 0 or -ve, Width relative
LogoH = -20 # Can be 0 or -ve, Height relative

# Clipping Coords (inside is valid graphic, outside of it is border/Letterbox)
ClipX = 0 # Black border area, +ve ONLY
ClipY = 0 # ditto
ClipW = -50 # Can be 0 or -ve, Width relative
ClipH = -50 # Can be 0 or -ve, Height relative

BLURPOWER= 1.0
SHOWMODE = 1
BLANK = False

Uglarm(LogoX,LogoY,LogoW,LogoH,ClipX,ClipY,ClipW,ClipH,BlurPower,ShowMode,BLANK)

https://i.postimg.cc/zXJLG4j2/Uglarm-00.jpg (https://postimages.org/)

Reel.Deel
12th September 2019, 15:29
@VoodooFX

Thank you for this script. I tried it out and I was very pleased with the results.

StainlessS
12th September 2019, 20:23
Function prototype in post #43 updated.

Got the Uglam overlay stuff working fine, but the delogo part was well slow (and did not quite work on initial attempts).
Did some searching and found this source patch file for ffmpeg, cant say it made a lot of sense to me (at first, never used SubVersioning stuff before),
but managed to figure it out a bit but probably a little more time till working OK. Is a fast way to precalc tables for UGLARM interpolation,
unfortunately, they use coords for logo which include the border pixels, and I exclude them, so need a bit of a redo, but getting there.
[also seems to expect valid perimeter pixels all around the logo, whereas I allow for letterbox border overlap of logo, so more changes there too].

Here the patch source code thing that I found on UGLARM search:- https://patchwork.ffmpeg.org/patch/11585/
probably will not make much sense, presume that you are supposed to use some kind of dedicated patch code reader software to be able to understand it.
anyways, I mostly got it figured out [and dropped some dross that was either dormant or did not work].

Anyways, I then (just now) found original source of the Uglarm tables code from ffdshow:- https://sourceforge.net/p/ffdshow-tryout/code/HEAD/tree/trunk/src/imgFilters/TimgFilterLogoaway.cpp
ffdshow stuff makes a lot more sense than the ffmpeg patch file I was working with. Relevant table creation stuff is in TimgFilterLogoaway.cpp functions,


void TimgFilterLogoaway::Tplane::calcUweWeightTable(int w, int h, int power)

void TimgFilterLogoaway::Tplane::uwe(const TlogoawaySettings *cfg)


I've still gotta convert from their definition of logo coords to mine, but at least easier to read.

Leaving this here so I can more easily find it again (ffdshow link), maybe of interest to some others too [incl VDX].
[Also wanna keep record of where I got source from so that I can point to it as per GPL requirements].

Also, here on-line version of Manolito linked LogoAways docs:- http://vander.wojdon.net/virtualdub/ladocs301/logoaway.html

VoodooFX
13th September 2019, 15:20
I'm not taking any pixel Aspect Ratio into account for distance, dont think it worth the (small) effort. [EDIT: See SAR above]


I don't see any practical effect of that, or even theoretical... unless to make a parameters list longer. Thats would be same as adding SAR parameter to Blur() or any other function, or I miss something here!?

StainlessS
13th September 2019, 18:39
I obviously wanted to make the parameter list longer, so as to seem more complicookered, me likes that.

Still not got the damn thing working properley, on last try (using more like the original patch code), it was prodcuing something quite akin
to the mandelbrot stuff, looks well weird. Maybe I see when working, if SAR stuff makes any difference, eliminate if not.
[SAR affects distance calcs for uglarm, so for chroma of eg YUY2 or YV16, should make a fair bit of difference, maybe. SAR auto modified for chroma of YUY2 and YV16].
Although, when I've ever used any delogo thing in eg Vdub, I never bothered with SAR.

EDIT:
https://i.postimg.cc/HLBXTG4m/Uglarm-Client-00.jpg (https://postimages.org/)

https://i.postimg.cc/FsCKF9wD/Uglarm-Client-01.jpg (https://postimages.org/)

EDIT: If there had been a logo in above images, they would certainly have been eliminated.
Had I done above patterns deliberately, I would have been quite proud if it. :)
I bet you mathematicians out there can tell what I'm doin' wrong just by lookin' at it.
EDIT: Gone t' pub.

StainlessS
17th September 2019, 03:33
Uglarm v0.0 Logo Interpolator now posted, Guinea pigs required, Here:- https://forum.doom9.org/showthread.php?t=176891

No idea how it compares to others tested in this thread.

EDIT: Seems a bit slow on YV12 UT_Video FullHD 192x192 logo, bout 11.8 FPS on my crap Core Duo Quad 2.8GHz m/c. [23% CPU usage, x64 version, bout 9FPS x86]

Mani, as you seem to like Uglarm Method, hows bout give it a whirl, with comparison times etc.
(Likely some bugs to iron out, tis still a baby).

StainlessS
29th September 2019, 02:00
Hi VDX, can I request a feature update.
I like to be able to use -ve width and height as in crop, but not quite so keen on being forced to only use -ve values,
so how bout making +ve width and height possible in your loc string thing ?

Below should do it in both your InpaintLoc(), and InpaintDelogo() functions.

InpaintLoc() mod in BLUE

a = int(value(leftstr(loc,posvirg1-1)))
b = int(value(leftstr(rightstr(loc,long-posvirg1),posvirg2-posvirg1-1)))
c = int(value(leftstr(rightstr(loc,long-posvirg2),posvirg3-posvirg2-1)))
d = int(value(rightstr(loc,long-posvirg3)))

c = (c > 0 ) ? a+c-x: c # Added, convert +ve width to -ve width
d = (d > 0 ) ? b+d-y: d # Added, convert +ve height to -ve height

hightlight = blankclip(width=x-a+c,height=y-b+d,color=$96ff2d).converttoRGB32 # EDIT: This depends upon -ve crop values, may do elsewhere in script too.


InpaintDelogo() mod in BLUE

a = int(value(leftstr(loc,posvirg1-1)))
b = int(value(leftstr(rightstr(loc,long-posvirg1),posvirg2-posvirg1-1)))
c = int(value(leftstr(rightstr(loc,long-posvirg2),posvirg3-posvirg2-1)))
d = int(value(rightstr(loc,long-posvirg3)))

c = (c > 0 ) ? a+c-x: c # Added, convert +ve width to -ve width
d = (d > 0 ) ? b+d-y: d # Added, convert +ve height to -ve height


inYV12 = clp.Crop(a,b,c,d).ConvertToYV12
inRGB24 = clp.Crop(a,b,c,d).ConvertToRGB24
inRGB32 = clp.Crop(a,b,c,d).ConvertToRGB32


Instead of converting -ve values to +ve values, I've converted +ve values to your -ve style values, just in case your logic depends upon -ve crop values.


Thankyou in advance.

EDIT:
I now see that you updated since the version script I was using,
Here mod for InpaintLoc() my mod in BLUE, you addition in v1.12 in DarkOrchid [ do similar for InpaintDelogo() ]

a = int(value(leftstr(loc,posvirg1-1)))
b = int(value(leftstr(rightstr(loc,long-posvirg1),posvirg2-posvirg1-1)))
c = int(value(leftstr(rightstr(loc,long-posvirg2),posvirg3-posvirg2-1)))
d = int(value(rightstr(loc,long-posvirg3)))

c = (c > 0 ) ? a+c-x: c # Added, convert +ve width to -ve width
d = (d > 0 ) ? b+d-y: d # Added, convert +ve height to -ve height

Assert (c <= 0 && d <= 0,"""Incorrect "Loc".""")
Assert (a >= 0 && b >= 0,"""Incorrect "Loc".""")
Assert (a%2 == 0 && b%2 == 0 && c%2 == 0 && d%2 == 0,"""Use even numbers for "Loc".""")

hightlight = blankclip(width=x-a+c,height=y-b+d,color=$96ff2d).converttoRGB32

StainlessS
8th December 2019, 13:13
Modified InpaintDelogo_v1.13.avsi.7z @ SendSpace in sig beneath this post. [available for 30 days only, will attach when ascertained that works ok]

# Version 1.11 : 2019/08/31. Public release.
# Version 1.12 : 2019/09/06. Various tweaks. New parameters. "Inflate" and "Deep" changed.
# Version 1.13 : 2019/12/08. Allow -ve LogoX,LogoY, and +ve LogoW,LogoH in Loc string. StainlessS.


# string "Loc" : Select (crop) the part of the picture around the logo.
# Example: Loc="30,420,-540,-30".
# Example: Loc="-200,-100,-30,-20". [ssS: Added, LogoX=Width-200, LogoY=Height-100, LogoX2=Width-30, LogoY2=Height-20]

EDIT: Actually above should be Loc="-200,-100,-30,-20". [ssS: Added, LogoX=Width-200, LogoY=Height-100, LogoX2=Width-30-1, LogoY2=Height-20-1, same as -ve cropping for width and height]

EDIT: OR eg, Loc="-200,-100,30,20". [ LogoX=Width-200, LogoY=Height-100, LogoW=30, LogoH=20]

bugloc2 = (loc == "0,0,-0,-0" || loc == "0,0,0,0") ? true : false # ssS: Added:- || loc == "0,0,0,0"


# assert ( findstr(loc,"-" ) != 0 , """Incorrect "Loc".""") # ssS: Commented OUT, we now allow +ve width and height in loc


Both in InpaintDelogo() and InpaintLoc()
a = (a < 0 ) ? x+a : a # ssS: Added, convert -ve logoX to +ve LogoX
b = (b < 0 ) ? y+b : b # ssS: Added, convert -ve logoY to +ve LogoY
c = (c > 0 ) ? a+c-x: c # ssS: Added, convert +ve width to -ve width
d = (d > 0 ) ? b+d-y: d # ssS: Added, convert +ve height to -ve height



Manolito,

What magic arguments do you use for removing fully opaque logos ?

I've done a mod to VoodooFX InpaintDelogo, v1.13, but dont know how to test it as I cannot get it working.
.

I'm not sure is possible without any kind of analysis, and below will fail if analysis is mandatory ['[I]mask is full' or similar error].

I want to test with something like this.

Import("InpaintDelogo_v1.13.avsi")
WH=512
A=BlankClip(width=WH/2,height=WH/2)
B=A.Invert StackHorizontal(A,B)
StackVertical(Invert)
trim(0,-100) # 100 frames, RGB32

LogoW = Width/2
LogoH = Height/2
LogoX = (Width-LogoW)/2
LogoY = (Height-LogoH)/2

Overlay(Last.BlankClip(Width=LogoW,height=LogoH,color=$8080C0),x=LogoX,y=LogoY) # Make dummy logo

loc=RT_string("%d,%d,%d,%d",LogoX,LogoY,LogoW,LogoH) # location of logo

# Return InpaintLoc(loc) # Mark/overlay logo area with 0.5 transparent light green

#InpaintDelogo(loc=loc,mode="Inpaint",mask="d:\EXLOGO\tmp.bmp",AutoMask=1) # NO Idea what to use here for static fully opaque logo, We do not need any kind of analyse, we know where it is.

#Uglarm(LogoX,LogoY,LogoW,LogoH) # test delogo using Uglarm

Return Last

__END__

InpaintDelogo( mask="d:\EXLOGO\tmp.bmp",
\ Automask=0, aMix=0, Loc=loc,
\ Mode="Inpaint",
\ Analyze=1, Fr1=0, Fr2=0, FrS=0, ReAnalyze=0,
\ dPP=3, dPPm=3, Interp=2, InterpM=0, Deep=2,
\ oPP=6, oPPm=3, oTune=0, KillShape=0, Inflate=1, Turbo=0,
\ Sharpness=45, PreBlur=6.5, PostBlur=4.0, Radius=8.0, prePP=0,
\ GrainPP=2,
\ Show=0, mShow=0, rSize=4)


Baseclip
https://i.postimg.cc/GTKQrxPp/Base0.jpg (https://postimg.cc/GTKQrxPp)

Dummy Logo
https://i.postimg.cc/56krCfv2/Dummy-Logo1.jpg (https://postimg.cc/56krCfv2)

InpaintLoc marked
https://i.postimg.cc/NLdJ3Qdk/In-Paint-Loc.jpg (https://postimg.cc/NLdJ3Qdk)

Uglarm delogo test
https://i.postimg.cc/v4fvZytj/Uglarm.jpg (https://postimg.cc/v4fvZytj)

EDIT: VoodooFX dont seem to have been around lately, no indication on user profile when he/she/it last visited. [no idea why last visit missing from user profile, is usually there]

manolito
8th December 2019, 14:42
When you have "AutoMask=1" in your InpaintDelogo call, then it will only create a mask and not remove any logo. You need to call InpaintDelogo twice, the second time with "AutoMask=0".

For creating the mask you might want to use the "Analyze=4" parameter instead of the default "Analyze=1". But for this you need to specify a frame number with the "Fr1" parameter where the logo is surrounded by black.

Another thing in your script is problematic. Your loc area is identical to the logo size, and this will give you bad results. The loc area must be at least 10 pixels larger than the logo, I use 14 to 16 pixels.

Your changes for the possible loc formats look interesting, but I will probably have no use for the new formats. To determine the loc coefficients I do not use "InpaintLoc" at all, instead I open my clip in VDub and apply the NullTransform filter. From there I can crop the image visually, and VDub shows the coefficients in the correct format which I can enter into my AVS script.


Cheers
manolito

StainlessS
8th December 2019, 15:26
Thanks Mani, guess that this is no good to me at all then, unless we can artificially create a mask in whatever required format.
Currently modding s_ExLogo2(), target is work from v2.58 to avs+ ALL colorspaces [EDIT: except YV411], and nice gauss blurry stuff, with soft edges.

manono
8th December 2019, 20:09
Your changes for the possible loc formats look interesting, but I will probably have no use for the new formats.
I think you're being polite. I took one look and thought to myself, "WTF?". They're fine the way they are.

I'd like to thank the creator for this. It opens almost instantly where when using InPaintFunc as I did before, it took roughly the length of the video to open. And since I work with long movies, mostly, you can imagine the frustration. And the results are better. I've used it twice recently on opaque logos and am very happy with the results.

StainlessS
8th December 2019, 20:43
I also thank VoodooFX for his useful tool.

I think you're being polite. I took one look and thought to myself, "WTF?". They're fine the way they are.

-ve width and height are useful when logo is at RHS or bottom, but less so when at LHS or top,
-ve LogoX and LogoY are useful in the same way as -ve width and height.

Nothing wrong with the way they were, and also nothing wrong with having options.
I did request VoodooFX to make the mod[sept 2019], but he aint been back since then.

Also, Manolito is always polite [well sometimes he is].

EDIT:
Thanks Mani, guess that this is no good to me at all then, unless we can artificially create a mask in whatever required format.
I meant that is no use where single frame delogo required, as analysis stage would find nothing [same where static clip/static logo as in prev test script].

manolito
8th December 2019, 20:46
Yes, the results of the InpaintDelogo plugin blow everything I have tested and used before out of the water...

A few hints:
If you use the "Analyze=1" parameter for the AutoMask creation then 3% of the source clip will be used for analyzing. For a longer movie (duration 90 min or above) this takes a long time. You can use "Trim", but for me I get better results after specifying a lower percentage for analyzing. I edited the InpaintDelogo.avsi file and replaced "every=33" with "every=400", and this is way faster without damaging the mask.

If you use AVS+ and want to use MultiThreading, there are a few catches. As VoodoFX pointed out, the InPaint routines are not really MT friendly. Analyzing the speed with AVSMeter you will find that turning off MT will result in a higher speed. But you may have other filters in your AVS script which do profit from MT, and the overall speed will be higher when using MT.

From my InpaintDelogo tests I found out that it tends to crash quite a bit when using MT. Reducing the prefetch threads did not help, but I got it working without crashes now.

First you need to force MT_SERIALIZED mode for all Inpaint functions:
SetFilterMTMode("InpaintLogo", MT_SERIALIZED)
SetFilterMTMode("DeblendLogo", MT_SERIALIZED)
SetFilterMTMode("AnalyzeLogo", MT_SERIALIZED)
SetFilterMTMode("DistanceFunction", MT_SERIALIZED)
SetFilterMTMode("RequestLinear", MT_SERIALIZED)

And then the InpaintDelogo call must be followed by a RequestLinear call like this:
RequestLinear(rlim=50, clim=50)

This will decrease the possible MT speed gain quite a bit, but for my usual conversions I still get a moderate gain of several fps. And no more crashes for quite some time...


Cheers
manolito

manolito
8th December 2019, 20:48
Also, Manolito is always polite [well sometimes he is].

Should I be offended? :cool:

StainlessS
8th December 2019, 20:58
You are seldom offended when I say such nice things about you [Esp as I was so staunchly defending you :) ].

VoodooFX
9th December 2019, 18:13
I just came to update op, lots of new post I see. :)

So what for these new Loc arguments are for? To use your new plugin with InpaintDelogo, StainlessS? Does it needs some testing?

Yesterday I delogo'ed one video:

https://i.imgur.com/NgbrmFL.png

https://i.imgur.com/M0RP2VE.png

StainlessS
9th December 2019, 19:12
So what for these new Loc arguments are for?

Hi VDX, can I request a feature update.
I like to be able to use -ve width and height as in crop, but not quite so keen on being forced to only use -ve values,
so how bout making +ve width and height possible in your loc string thing ?

Not new arguments, just alternative way of specifiying existing ones. [EDIT: crop() without +ve width,height options, would be a little less perfect]
I dont mind if you remove -ve LogoX,LogoY, sometimes just a little easier to guess relative RHS/BOT, your choice. I've marked all changes in script with 'ssS'.


Does it needs some testing?
Yes please if you would be so kind.

Real good job on you new posted delogo sample, is quite nifty.

I did not know if you were gone for good, nice to see you back again :)

EDIT: The changes were made so as not to foul up your existing logic where code might be reliant upon -ve width,height.

EDIT: This is the only line that I can see that might require a little bit of your time [maybe delay detect until you extract a,b,c,d from loc string, and after conversion to +ve a,b, and -ve c,d].

bugloc2 = (loc == "0,0,-0,-0" || loc == "0,0,0,0") ? true : false # ssS: Added:- || loc == "0,0,0,0"

VoodooFX
9th December 2019, 19:23
Found some old testing files, just need to remember and understand all this new stuff in your plugin.

-ve +ve is confusing as you need to add at least 10px borders from logo edges in InpaintDelogo.
Real minimum I think is 7px or 8px, added some room for user error... that's why 10 in help, it will be best for quality and speed to keep at minimum 8-10px.

StainlessS
9th December 2019, 19:39
Any/all changes that you dont like, remove [or just miss them out all together in v1.14], I can easily make a stub to amend loc from outside of your script, not a problem at all.

The thing I'm currently doing (s_exlogo2) is not in anyway competition for your script, has different intent, I wanna be able to just splat any rectangular problem areas without having to do any analysis.

Found some old testing files, just need to remember and understand all this new stuff in your plugin.

Aint my plugin, is yours, you gets all the blame for everything :)

VoodooFX
9th December 2019, 19:48
By default InpaintDelogo doesn't do any analysis too, only if you want to get the mask automatically or deblend the logo.

TCmullet
27th December 2019, 00:48
I've tried to look over everything and absorb what I could. Your built-in two manuals leave out much. Here's where I'm stuck now:

> 2) Get frames numbers for manual "Analyze".

What do I do with the range of frame numbers that I want the analysis to be based on?

BTW, I will be replacing rm_logo logic. My scripts have commented out code which was used to do the analysis, then further down was my runtime code.

StainlessS
27th December 2019, 11:16
@ TcMullet,

I'm off to bed in a minute, but will come back later.

@ VoodooFX,
I've removed the InPaintDelogo v1.13 pretender script from SendSpace, its gone 4E4. [forever]

Have done a stub function just to manufacture InPaintDelogo style Loc string, add it to your script if your like it, if not then no sweat.


Function MakeLoc(clip c,Int x, Int y, Int w, Int h) { # https://forum.doom9.org/showthread.php?p=1893966#post1893966
/*
Make Loc string for VoodooFX InPaintDelogo.
Input X and Y, where -ve, is relative to c.Width or c.Height, and are converted to +ve X and Y in result string.
Input W and H, where 0 or -ve, is relative c.Width or c.Height [as in Crop()],
Where +ve, are converted to -ve W and H in result string [as required by InPaintDelogo].
Allows to make Loc string programmatically using flexible coord system and not locked into hand editing Loc string.

ColorBars # 640,480
S=MakeLoc( 0, 0, 0, 0) # "0,0,-0,-0"
S=MakeLoc( 540, 380,-40,-40) # "540,380,-40,-40"
S=MakeLoc(-100,-100, 60, 60) # "540,380,-40,-40"
S=MakeLoc( 540, 380, 60, 60) # "540,380,-40,-40"
S=MakeLoc(-100,-100,-40,-40) # "540,380,-40,-40"
*/
c
# First, Ensure/Convert X,Y,W,H ALL +ve
x = (x >= 0) ? x : Width + x
y = (y >= 0) ? y : Height + y
w = (w > 0) ? w : Width - x + w
h = (h > 0) ? h : Height - y + h
# Check validity
Assert(0 <= x < Width ,String(x,"MakeLoc: 0 <= X(%.0f)") + String(Width ," < Width(%.0f)" ))
Assert(0 <= y < Height ,String(y,"MakeLoc: 0 <= Y(%.0f)") + String(Height ," < Height(%.0f)"))
Assert(1 <= w <= Width -x ,String(w,"MakeLoc: 1 <= W(%.0f)") + String(Width ," <= Width-X(%.0f") + String(x ," - %.0f)"))
Assert(1 <= h <= Height-y ,String(h,"MakeLoc: 1 <= H(%.0f)") + String(Height ," <= Height-Y(%.0f") + String(y ," - %.0f)"))
# Output string: +ve X,Y :: -ve W,H, Ensure all (even W=0 and H=0) flagged as -ve eg -0
return String(x,"%.0f") + String(y,",%.0f") + String(Abs(x+w-Width),",-%.0f") +String(Abs(y+h-Height),",-%.0f")
}


EDIT: If you DONT like the -ve x,y options, then can just delete the above lines in RED, and if you do include above without -ve x,y,
then please rename function to some other name, I dont want it to conflict with my stub. [you would likely want to edit the description too of course].

manono
28th December 2019, 00:51
Here's where I'm stuck now:

> 2) Get frames numbers for manual "Analyze".

What do I do with the range of frame numbers that I want the analysis to be based on?

Forget doing an analysis pass. Make your own logo BMP, find the coordinates for the location (10-12 pixels outside of the logo coordinates). and go right to InpaintDelogo. I've been using this script, copied from the manual, with success (adjust for your BMP location and location coordinates):

InpaintDelogo( mask="G:\Jugnu\Logo.bmp",
\ Automask=0, aMix=0, Loc="44,34,-524,-386",
\ Mode="Inpaint",
\ Analyze=1, Fr1=0, Fr2=0, FrS=0)

Others such as manolito, VoodooX, or StainlessS might want to make suggestions. I'm not even sure I need all that, but it works quickly and it works well.

VoodooFX
28th December 2019, 08:11
December is very busy... I don't have much time StainlessS.

I've tried to look over everything and absorb what I could. Your built-in two manuals leave out much. Here's where I'm stuck now:

> 2) Get frames numbers for manual "Analyze".

What do I do with the range of frame numbers that I want the analysis to be based on?

BTW, I will be replacing rm_logo logic. My scripts have commented out code which was used to do the analysis, then further down was my runtime code.

Everything is in the manual, you just need to read it. Some part of it about frames:

3 - Manual analysis. This method is best, but you need one frame where
# logo area is in a solid black/dark background and another in a solid
# white/bright background. Blacker/whiter - better. These two frames must
# be set with "Fr1" & "Fr2" parameters and optional "FrS".

manolito
29th December 2019, 00:01
I agree that using InpaintDelogo can be a little bit confusing at first - I found it confusing even with a lot of experience from other delogo plugins... :o

In this post I will try to remove some of the confusion. To achieve this I will only refer to the "Inpaint" mode which is meant for opaque logos. The two other modes ("Deblend" and "Both") are meant for semi-transparent logos, they try to reconstruct the original pixels behind the semi-transparent logo. This makes these modes much more complex and slower, and I found that the result oftentimes does not justify the effort.

For the "Inpaint" mode only one "base mask" is needed. The additional Alpha and Color masks are not needed at all.

This is the basic work flow:
1. Create a "base mask". This is an image file with the identical size of the source clip where the logo itself is all white and the rest of the image is all black. Save it as a BMP file to your HDD.

2. Determine the coordinates for the "Loc" parameter. The dimensions need to be about 10 pixels larger than the logo, and the format is identical to the AviSynth Crop parameters.

3. Call the "InpaintDelogo" function for the logo removal. Use the parameters for the mask file location and the Loc parameter with the coordinates which you have determined.


The InpaintDelogo plugin includes methods to do the #1 and #2 tasks, but it is in no way required to use these methods. For many users it may be much easier to perform these steps manually without using the plugin functions.

Have a look at manono's script two posts above. He does steps #1 and #2 manually, and his final logo removal call can even be stripped down considerably. His original script can be reduced to:
InpaintDelogo(mask="G:\Jugnu\Logo.bmp", Loc="44,34,-524,-386", Mode="Inpaint")

Especially the "Analyze=1" should not be used here. When the mode is set to "Inpaint" then "Analyze=0" will be forced unconditionally. This is because the base mask is already there, and the "Inpaint" mode does not need additional masks which would need analyzing.

For better speed you can play with the "Turbo" parameter, but this is basically it. If you are familiar with using a photo editor to create the mask then this will be your fastest method.


If your are like me and do not feel comfortable with image editors like PhotoShop then it may be a good idea to use the InpaintDelogo plugin to create the required base mask automatically. The "InpaintDelogo" function needs to be called with the "AutoMask=1" parameter for this. With this parameter the function will ONLY CREATE A MASK, nothing else. To actually remove the logo the function has to be called for a second time without the "AutoMask" parameter.

First you need to determine the "Loc" coordinates and enter them into the "Loc" parameter. Then you need to decide which "Analyze" method you want to use for the mask creation. The best and fastest method for the "Inpaint" mode is "Analyze=4". You need to find a source frame where the logo is surrounded by black. For real world movies such a frame can usually be found at the start of the movie or at the very end. The frame number of such a frame needs to be entered with the "Fr1" parameter.

If you cannot find a source frame where the logo is surrounded by black then you need to use the "Analyze=1" method. With this method 3% of the source will be analyzed for the mask creation. This takes time, especially for HD sources. For longer sources you can use this hack to speed up the mask creation:
If you use the "Analyze=1" parameter for the AutoMask creation then 3% of the source clip will be used for analyzing. For a longer movie (duration 90 min or above) this takes a long time. You can use "Trim", but for me I get better results after specifying a lower percentage for analyzing. I edited the InpaintDelogo.avsi file and replaced "every=33" with "every=400", and this is way faster without damaging the mask.

So if you decide to use the AutoMask feature of the plugin your first call to the "InpaintDelogo" function should look similar to this:
Loc="22,12,-588,-328"
InpaintDelogo(automask=1, analyze=4, fr1=10329, mask="d:\logomask.bmp", Loc=Loc)

Or like this:
Loc="22,12,-588,-328"
InpaintDelogo(automask=1, analyze=1, mask="d:\logomask.bmp", Loc=Loc)

And the second call for the actual logo removal could look similar to this one:
Loc="22,12,-588,-328"
InpaintDelogo(mask="d:\logomask.bmp", Loc=Loc, Mode="Inpaint", Turbo=0)



Hint for better speed if you are downscaling your source:

The logo removal will be much faster if you apply it after the resizer (when downscaling). Of course this also means that you need to use a downscaled image for creating the mask.


Cheers
manolito

manono
29th December 2019, 00:41
His original script can be reduced to:
InpaintDelogo(mask="G:\Jugnu\Logo.bmp", Loc="44,34,-524,-386", Mode="Inpaint")
Thank you very much. I figured it could be streamlined but hadn't gotten around to playing with it as I was just so happy with the way it was working.

If you are familiar with using a photo editor to create the mask then this will be your fastest method.
Which is why I said to forget analyzing the video and just create your own logo BMP. Any photo editor can do the job. I use the freeware PhotoFiltre (http://www.photofiltre.com/).

manolito
29th December 2019, 01:19
Any photo editor can do the job. I use the freeware PhotoFiltre (http://www.photofiltre.com/).

Hey manono,

looks like we have similar preferences. I have been using PhotoFiltre exclusively for many years now. But I still am not an expert with layers and masks, I just don't do much photo editing... :o

Happy New Year
manolito

manono
29th December 2019, 03:02
I just don't do much photo editing...
Me neither. About all I use it for is mask creation for logos and for parts of frames where filters are to be applied, and then its Gaussian Blur filter for feathering when needed.

Oh, and for replacing parts of artifacted frames with bits from nearby good frames. All simple stuff. And all for use in AviSynth scripts.

RieGo
29th December 2019, 10:22
i love this plugin!
my personal workflow (no need to create mask):
-find logo area with InpaintLoc()
-find 30+ frames with logo on black background (mostly at start or end of video)
-find 30+ frames with logo on white(ish) background

InpaintDelogo(mask="tmp.bmp",Automask=1,Loc="x,x,-x,-x", Mode="Both", Analyze=3,Fr1=x,Fr2=x,FrS=3)

now there are 2 things which still are a bit annoying:
-loc parameter would be great to be used as "left,top,width,height" imo
-whenever Automask is enabled, staxrip and probably avisynth doesn't generate a valid output, so i need to first analyze and then disable automask

thanks dev for this great plugin, this really helps a lot!
next improvement would be finding black/white frames on its own :D

manolito
29th December 2019, 14:05
-loc parameter would be great to be used as "left,top,width,height" imo

Have a look at this script by StainlessS:
https://forum.doom9.org/showthread.php?p=1893966#post1893966
It will convert your input to the required format for InpaintDelogo.


-whenever Automask is enabled, staxrip and probably avisynth doesn't generate a valid output, so i need to first analyze and then disable automask

This is not a bug, it's a feature... :D
From the manual:
# Int "Automask" : Generates a base mask of the logo.
# "Analyze" (and its sub-parameters, except "ReAnalyze"), "aMix", "mask" and
# "Loc" parameters will be used.
# "Loc" would be best 10(no less) pixels from the logo edges.
# Needs "mask" defined with path to imaginary bmp picture, that's where
# a base mask will be generated.
# Will re-analyze on every script load. Fastest and best results will be
# with manual "Analyze".
#
# 0 - Off (default).
# 1 - On. Generates a mask, doesn't do anything else when "On".



Cheers
manolito

RieGo
30th December 2019, 11:26
Have a look at this script by StainlessS:
https://forum.doom9.org/showthread.php?p=1893966#post1893966
It will convert your input to the required format for InpaintDelogo.


Thanks! i missed that one :D

JohnDoe
13th May 2020, 16:04
Maybe anyone have a idea for this Problem:

https://forum.doom9.org/showthread.php?t=181432

Thanks!

JohnDoe
31st August 2020, 00:37
I have a film with a single color transparent text watermark, always at the same location. I also have the film in a lower resolution version without watermarks, but with a lower frame rate (and therefore missing frames). I don't want to remove the missing frames, otherwise the film will be more jerky.

I've built a script for myself, which picks out the best fitting frames with help of LumaDifference and use a black/white mask to blend the parts of the lowres movie to the higher res movie to remove the logo. So far so good.

The problem now are the missing frames. I tried to remove the logo from this frames with deblending, which works more or less well. Unfortunately the logo is not very transparent. So i've seen some leftovers.

The film has a black spot with the logo. Unfortunately not a bright spot. That's why i'm using Analyze = 4 instead of 3.

Unfortunately now a slightly flickering is visible on change from the deblended to non deblended frames (caused by the leftovers)

The question now is, if the deblending could be improved by better masks. Theoretically, I should be able to "somehow" calculate better masks because I have the film in a version without the logo (but how said in lower resolution and lower framerate), right? Unfortunately, I just lack the understanding a little.

As far as I understand i need two masks. A transparent mask and a color mask?!?

It is somehow a mystery to me how this calculated color mask, which is calculated from many frames, can work properly for much different frames.

Maybe someone have a idea and can help me.

Unfortunately, I can't give out my film. But I think it's relatively easy to build a small demo for the experts.

The avs script i currently use i've attached here.

Hope the "code" isn't that bad. I'm not yet an Avisynth expert.

VoodooFX
31st August 2020, 14:13
How do you replace parts on same frames if two clips are not same frame rate?

About deblending: I hardly understand what you are doing, so without example I can't give you an advice. Mask creation and deblending should be done only using frames with logo.
txt/avs you can post as text or on pastebin.com because attachments can take some time to get approved.

JohnDoe
31st August 2020, 21:07
Okay.. here the avs script https://pastebin.com/Un9c19D0

My solution to the different frame rates is to convert both videos to a higher frame rate. In this case it is 150Fps .. because 150/25 is 6 and 150/30 is 5 :-) ... A little SelectEvery voodoo ;)

VoodooFX
2nd September 2020, 00:16
If you can't use Analyze=3, then try Analyze=1, it can be better than Analyze=4. Sometimes you can get better deblending masks from Analyze=1 if you limit locations to analyze with trims, similar stuff what is good for Analyze=3, like more solid different luminosity objects passing through logo area ect..

real.finder
21st October 2020, 15:30
hi,

what about make the mask parameter as val? so user can feed it with any mask clip to allow moving logo mask

also is ExInpaint instead of AvsInpaint will be better? from what I see ExInpaint is faster and give better output in some usages

StainlessS
21st October 2020, 17:48
Not sure but I think that ExInpaint is less temporally stable than AvsInpaint, better for still image but not video.

real.finder
21st October 2020, 18:17
Not sure but I think that ExInpaint is less temporally stable than AvsInpaint, better for still image but not video.

so that mean ExInpaint use temporal dimension (The previous and next frame)? in stab3 (https://github.com/realfinder/AVS-Stuff/blob/9d659c02ae77bf5e823ff68f9a00a621264f87fc/avs%202.5%20and%20up/StabilizationToolsPack.avsi#L417) using stab3(mirror=15,FillBorder=2,use_exinpaint=true) will give better stability than stab3(mirror=15,FillBorder=2) (which use AvsInpaint)

StainlessS
21st October 2020, 18:35
I think that ExInpaint is purely spatial, it predicts missing parts based on spatial structure elsewhere in the same image.
If video, then spatial predictions can be quite a lot different to adjacent frames [but indiviual frames, might look good].

I've no idea what Stab() does.

real.finder
21st October 2020, 19:00
I've no idea what Stab() does.

http://avisynth.nl/index.php/Stab

it made black borders by default, so the Stab2 and Stab3 has some solutions for it

VoodooFX
22nd October 2020, 13:18
hi,

what about make the mask parameter as val? so user can feed it with any mask clip to allow moving logo mask

also is ExInpaint instead of AvsInpaint will be better? from what I see ExInpaint is faster and give better output in some usages
What I have seen from examples, ExInpaint is good for the images, that would make it bad for video. I could add separate function for it, for images.

Not sure what the use scenario would be with "val". Is there new code for an object tracking or an object recognition? How is that half python Avisynthtrackin code? Anyone tried it? Can it be incorporated to something useful?

I remember trying Stab, but couldn't manage to get the results, so dunno what it actually does...

StainlessS
22nd October 2020, 13:47
I tried Avisynthtrackin a little bit,
[original StarWars] on C3PO walking towards camera alone over the sand dunes.
Worked reasonably well, but IIRC required occasional user nudge/tweak to keep it working.
For above to have worked, it must continuously vary tracking stuff as C3PO got bigger and bigger as well as moving in frame.

Probably too much bother to be useful though.

real.finder
22nd October 2020, 14:04
What I have seen from examples, ExInpaint is good for the images, that would make it bad for video. I could add separate function for it, for images.

Not sure what the use scenario would be with "val". Is there new code for an object tracking or an object recognition? How is that half python Avisynthtrackin code? Anyone tried it? Can it be incorporated to something useful?

I remember trying Stab, but couldn't manage to get the results, so dunno what it actually does...

val in avs is not new, with it you can make the parameter accept any type of things, you can see how SMDegrain deal with prefilter parameter for example

VoodooFX
22nd October 2020, 14:06
While I'm at this thread, one comparison for the history; somewhere here in forum is semi-manual "Delogo" avs script which was aiming to do better than vdub plugin, I didn't tried it (don't like manual scripts), but from examples I have seen it did better job than other methods at the time. Here few comparison screenshots:

Original:
https://images2.imgbox.com/06/2f/Xsm8fxWn_o.png

DeLogo (avs script):
https://images2.imgbox.com/28/8d/7FuGUZKv_o.png

InpaintDelogo:
https://images2.imgbox.com/9b/52/QUcQYPzA_o.png

Original:
https://images2.imgbox.com/24/be/e6UFFL0E_o.png

DeLogo (avs script):
https://images2.imgbox.com/92/6e/XUOVe3s7_o.png

InpaintDelogo:
https://images2.imgbox.com/a7/96/FYNHENz7_o.png

VoodooFX
22nd October 2020, 16:44
val in avs is not new, with it you can make the parameter accept any type of things, you can see how SMDegrain deal with prefilter parameter for example
I meant what to do with those "any type of things"?

real.finder
22nd October 2020, 18:56
I meant what to do with those "any type of things"?

as I said "so user can feed it with any mask clip to allow moving logo mask" since now it only accept image mask path

and maybe I will add InpaintDelogo to stab3 since ExInpaint crash in x64 after refresh in avspmod and AvsInpaint give flickering borders

test codes
last.ExInpaint(FillBorders_stabi(pad=2,maskonly=true,thr=30).mt_expand(U=-255,v=-255))
last.InpaintLogo(FillBorders_stabi(pad=2,maskonly=true,thr=30).mt_expand())


so maybe your script will help if it work with mask clip :)

VoodooFX
22nd October 2020, 20:29
Ah, that's why. I would look into it if there was generally working script/plugin for an actual moving logo detection/tracking. Filling borders doesn't give an incentive when that's not a small tweak. :)
Script is using same AvsInpaint, I wouldn't expect different results. How wide those borders are and why not cut them off?

real.finder
22nd October 2020, 21:22
Ah, that's why. I would look into it if there was generally working script/plugin for an actual moving logo detection/tracking. Filling borders doesn't give an incentive when that's not a small tweak. :)
Script is using same AvsInpaint, I wouldn't expect different results. How wide those borders are and why not cut them off?

for moving logo, I think if the move not random then user can make mask using http://avisynth.nl/index.php/Animate and the logo

the borders width depend on the shaking fix and the stab settings, cut them off not always a good idea especially when you deal with 480p input that you have to cut the black borders in it and then use stab(), and it's worst if it have a big black borders up and down (16:9 in 4:3)

VoodooFX
25th October 2020, 22:14
I tried Avisynthtrackin a little bit,
[original StarWars] on C3PO walking towards camera alone over the sand dunes.
Worked reasonably well, but IIRC required occasional user nudge/tweak to keep it working.
For above to have worked, it must continuously vary tracking stuff as C3PO got bigger and bigger as well as moving in frame.

Probably too much bother to be useful though.

If it can track an object with the changing shapes, then it should track movement of the static shape object much better, no? What if such object jumps long distances? I personally don't have time to test it, left comment there https://forum.doom9.org/showthread.php?p=1926710#post1926710, maybe someone interested in such logos will give it a go.

Somewhere I've seen that you wrote some motion blending script to isolate a moving logo, did you tried to adapt it to InpaintDelogo? Every time I look at the code of ID it makes my head spin for a bit... :)
How reliable such isolation is?

...it's worst if it have a big black borders up and down (16:9 in 4:3)
That's way beyond of practical use. Imo practical threshold would be somewhere bellow ~20px.

Now I'm trying to remove a static animated logo, a running timer, that would be a bias to what you are asking for.

real.finder
26th October 2020, 01:11
That's way beyond of practical use. Imo practical threshold would be somewhere bellow ~20px.

Now I'm trying to remove a static animated logo, a running timer, that would be a bias to what you are asking for.

indeed, but I didn't mean that, I was mean after crop them and use stab

and thanks about trying support it

VoodooFX
2nd November 2020, 19:24
and thanks about trying support it
I started tinkering around it; so you want to supply there a whole clip aka dynamic mask or just a one frame mask?

There is lots of changes accumulated in the script over the year, I'll publish it after I'll add all new stuff to the manual.
I hate writing manuals, but there is no point releasing without them... :D

real.finder
2nd November 2020, 21:06
I started tinkering around it; so you want to supply there a whole clip aka dynamic mask or just a one frame mask?

There is lots of changes accumulated in the script over the year, I'll publish it after I'll add all new stuff to the manual.
I hate writing manuals, but there is no point releasing without them... :D

supply a whole clip aka dynamic mask, or it's will be better if both :)

VoodooFX
5th November 2020, 18:36
Added support for dynamic/static mask clips, just need to optimize the script for the dynamic clips.

I noticed that multi-threading now works, it runs x3-x4 faster with Prefetch(4), not sure why, is it because some changes in new LSMASH indexer or AVS+ 3.5?

kedautinh12
6th November 2020, 00:15
Added support for dynamic/static mask clips, just need to optimize the script for the dynamic clips.

I noticed that multi-threading now works, it runs x3-x4 faster with Prefetch(4), not sure why, is it because some changes in new LSMASH indexer or AVS+ 3.5?

Where your download link new ver??

VoodooFX
6th November 2020, 14:31
Encountered some weird random bug (LSMASH 20200728 + AVS+ 3.4 r2923), first I thought that's some frame inaccuracy but probably it's bug in AVS+/Overlay or AVSinpaint, need to investigate it more. Is there some script/plugin which would compare frames from two separate video files (expected to be identical) and return frame numbers of not identical frames? Or any ideas how to do such comparison?

Where your download link new ver??
It will be posted when it's ready.

VoodooFX
8th November 2020, 01:46
No ideas how to make such comparison, that would really help to pin point the bug?

Here I made another run with few steps on the output to see more what is going on and accidentally noticed this on one frame ("before" bug was different and much severe):
Proper:
https://images2.imgbox.com/80/42/mF55E4gZ_o.png
Bug:
https://images2.imgbox.com/5f/5b/xdueHoVk_o.png

Here it didn't influenced much the end result (left/bottom), but how in the hell top/right corner mask is red, feathered and "12" visible when it goes through Greyscale.Levels(127,1,128,0,255)...

poisondeathray
8th November 2020, 02:35
Is there some script/plugin which would compare frames from two separate video files (expected to be identical) and return frame numbers of not identical frames? Or any ideas how to do such comparison?


WriteFileIf with a runtime function expression like lumadifference . But there was some bugs in avs+ 3.x with this. It works in 2.6 classic. There was some discussion about this somewhere IIRC. Not sure what changed or what the exact syntax change was

Something like this works in avs+ 2.6 classic

.
.
.

Subtract(clip1,clip2)
WriteFileIf (last, "log.log", "LumaDifference(clip1, clip2)>0", "current_frame", """ ":" """, "AverageLuma")


Other approaches would be psnr . You can print out per frame PSNR in ffmpeg (should be infinity for identical frames), but that prints out every frame value. Maybe some spreadsheet or grep function to reduce to only different frames

StainlessS
8th November 2020, 05:53
but how in the hell top/right corner mask is red, feathered and "12" visible when it goes through Greyscale.Levels(127,1,128,0,255)...

Dont see why it should make it red, however should for YUV use

Greyscale.Levels(127,1,128,0,255,coring=false)...

VoodooFX
8th November 2020, 18:50
Dont see why it should make it red, however should for YUV use
Greyscale.Levels(127,1,128,0,255,coring=false)...

It's random/non-reproducible bugs, when using Prefetch(4). Masking and Levels(127,1,128,0,255) happens in RGB32.

WriteFileIf with a runtime function expression like lumadifference . But there was some bugs in avs+ 3.x with this. It works in 2.6 classic. There was some discussion about this somewhere IIRC. Not sure what changed or what the exact syntax change was

Something like this works in avs+ 2.6 classic
Subtract(clip1,clip2)
WriteFileIf (last, "log.log", "LumaDifference(clip1, clip2)>0", "current_frame", """ ":" """, "AverageLuma")

Thanks mate, that works perfectly. I edited it a bit so I can copy/paste log to SelectEvery:

Subtract(clip1,clip2)
WriteFileIf (last, "log.log", "LumaDifference(clip1, clip2)>0", "current_frame", """ ", \" """)

AvS 2.60(2.6.0.6) & AvS+ 3.5 (r3106) produced identical logs, AvS+ was 20% faster.

I run comparison on stacked output with 4 steps (like in screenshot in the previous page), so, Prefetch(4) vs no Prefetch:
Detected discrepancies in 157 frames from 134237 frames, almost all of them in the top/right mask, in 18 frames those mask are ok but discrepancies are in the final step(bottom/left, but no visible differences).

Here is some examples of the bugged masks (it should be B/W with white numbers, last two digits shouldn't be visible), stacked original clip & one mask:

https://images2.imgbox.com/ca/ad/n9FYMKWk_o.png https://images2.imgbox.com/af/3b/p7sw5uLL_o.png https://images2.imgbox.com/a1/3d/2JNsCOBa_o.png

https://images2.imgbox.com/59/c5/xyjen4Kz_o.png https://images2.imgbox.com/49/53/DG2zockZ_o.png https://images2.imgbox.com/e7/0f/V30pe7R5_o.png

https://images2.imgbox.com/0a/aa/6JUDcQif_o.png https://images2.imgbox.com/25/d6/pRWl1UjQ_o.png https://images2.imgbox.com/9c/56/P6bjRjvx_o.png

https://images2.imgbox.com/85/6f/IXiTWaN8_o.png https://images2.imgbox.com/6e/ba/EB1gupeN_o.png

Now I need to run more tests to isolate the problem.

poisondeathray
8th November 2020, 20:20
What format was source video ? Did you try threads=1 for LSmash ? Or other source filters to rule out some issue upstream ?

To be clear, was the issue only with Prefetch(4) ? Is no prefetch ok ? Or other values ?

I recall some discussion about source filter threads and seeking accuracy issues vs. host CPU threads , but I think that was for ffms2

VoodooFX
9th November 2020, 13:28
Like I suspected it's something with Overlay, tested and same on AvS+ 3.4, 3.5.1, 3.6.0, 3.6.1.
Here is minimized and ready to run test scripts (extract to C:\) or preview included test results https://anonfiles.com/F7E0hdo2p0 or https://we.tl/t-J95N1CsfUz (7 days)

What format was source video ? Did you try threads=1 for LSmash ? Or other source filters to rule out some issue upstream ?

To be clear, was the issue only with Prefetch(4) ? Is no prefetch ok ?
Isn't "threads=1" parameter for ffms2!? No-Prefetch is ok. I dunno working alternatives for LSMASH, and whatever source filter outputs it shouldn't bypass binarization of the frames.

pinterf
11th November 2020, 19:03
Like I suspected it's something with Overlay, tested and same on AvS+ 3.4, 3.5.1, 3.6.0, 3.6.1.
Here is minimized and ready to run test scripts (extract to C:\) or preview included test results https://anonfiles.com/F7E0hdo2p0

"Bad gateway", expired perhaps?

StainlessS
11th November 2020, 19:10
Same here, 502 Bad gateway. nginx.
Maybe that nginx thing is the block on your location for download, (cant remember what its called).
Can anybody launch successful download ?

EDIT: The Bad Gateway page is showing as Sweden in FlagFox. [dont know if relevant]

VoodooFX
11th November 2020, 19:48
"Bad gateway", expired perhaps?
Still works on my side. Here is another link: https://we.tl/t-J95N1CsfUz

poisondeathray
11th November 2020, 20:08
Isn't "threads=1" parameter for ffms2!? No-Prefetch is ok. I dunno working alternatives for LSMASH, and whatever source filter outputs it shouldn't bypass binarization of the frames.

LSmash has threads=blah parameter too. But non frame accurate runs will account for differences between repeated tests, when prefetch is used


I repeated test with x64 version - I think the problem is lsmash threads=auto vs. threads=1 for x64. I think it' s similar to the aforementioned ffms2 threads bug with prefetch


EDIT - multiple consec runs can result in different results, even with source filter threads=1 . One run can show PSNR inf, but another something lower. Something else is going on...

It even occurs when source is encoded to I-frame UTVideo, and using AVISource instead; multiple runs can show different results when prefetch is used. So not source filter related

VoodooFX
11th November 2020, 20:46
I repeated test with x64 version - I think the problem is lsmash threads=auto vs. threads=1 for x64.

I tested threads=1 like you did, only with 32bit and got one frame bugged, so bug is there with threads=1 too. It makes less chance for bug to occur, 5mins is too short test for this condition.

Looking at those bugged masks I think it's something with buffer/memory, just a guess, I'm not into lower level programming.

poisondeathray
11th November 2020, 20:48
I tested threads=1 like you did, only with 32bit and got one frame bugged, so bug is there with threads=1 too.

Yes, it's almost "random", see my edits above . One run can be perfect, but the next a few frames off, the next perfect again. It's not source filter related

poisondeathray
11th November 2020, 21:05
If you change the script to use mt_merge (and full range YUV masks , PC matrix if converting from RGB), 10/10 runs are the same with prefetch=4. So that suggests it is something with overlay and prefetch

pinterf
11th November 2020, 21:51
Yes, it's almost "random", see my edits above . One run can be perfect, but the next a few frames off, the next perfect again. It's not source filter related
Here is my minimalized script.
# Load VirtualDub, Press F2, go to frame 2-3-4 and back, refresh, step between frames left and right
# suddenly a garbage is seen
DynamicMask = BlankClip(1000, 128, 128, pixel_type="RGB32")
WhiteClip = BlankClip(DynamicMask,color=$FFFFFF)
BlackClip = BlankClip(DynamicMask,color=$000000)
BlackClip.Overlay(WhiteClip, Mask=BlackClip)
Prefetch(4)

Thank you for giving me the opportunity to work on it :)

VoodooFX
12th November 2020, 11:09
Here is my minimalized script.

Thank you for giving me the opportunity to work on it :)

Yep, Vdub2 reveals this bug on the first frames. Have fun with it. ;)

pinterf
12th November 2020, 12:24
Please check a (hopefully) fixed Avisynth build (https://forum.doom9.org/showthread.php?p=1928109#post1928109)

VoodooFX
26th November 2020, 18:43
There is some bug with high resolutions like 1920x1080 and AvsInpaint, if a mask is close to the left/right side then AvsInpaint hangs at start (no error).

Here is the bug simulator:

x=BlankClip(length=1000, width=1920, height=1080, color=$000000, pixel_type="YV12")

mask = BlankClip(x, length=1).Subtitle("Sample", text_color=$FFFFFF, x=8).Levels(180,1,181,0,255, coring=false)
# mask = BlankClip(x, length=1).Subtitle("Sample", text_color=$FFFFFF, x=519).Levels(180,1,181,0,255, coring=false) # Working position, moving the mask 1px to left("x=518") - hangs.

# x.InpaintLogo(mask, PreBlurSize=0.9, PostBlurSize=0.9) # Droping the blur kernels to 0.9 - no hangs.
x.InpaintLogo(mask)

EDIT:
Bug should be fixed in AvsInpaint v1.3

VoodooFX
28th November 2020, 18:05
New version released (updated the first post):


# Version 1.11 : 2019/08/31. First public release.
# Version 1.12 : 2019/09/06. Various tweaks. New parameters. "Inflate" and "Deep" changed.
# Version 1.13 : 2019/12/08. Allow -ve LogoX,LogoY, and +ve LogoW,LogoH in Loc string (by StainlessS).
# Version 1.14 : [non public] "Fr1"/"Fr2" are renamed to "FrB"/"FrW". "GrainPP" is off by default.
# Version 1.15 : [non public] New mode for "InterpM", (-1) takes mask from new "iTune" parameter.
# Version 1.16 : [non public] New "diPP" & "diPPm" parameters.
# Version 1.17 : [non public] New "iTinflate" & "oTinflate" parameters. Interp/iTune mask to "mShow".
# Version 1.18 : [non public] New "EdgePP", "EdgePos" & "EdgeWide" parameters. EdgeMask to "mShow".
# Version 1.19 : [non public] New "IntSpd" parameter for "Interp" & the slow modes for "EdgePP".
# Version 1.20 : [non public] "Turbo" presets moved from soft to hard. iTune & Edge masks to "Show".
# Version 1.21 : [non public] Added support for the mask clips and a dynamic mask.
# Added basic auto generation of a dynamic mask (aka "DynMask=2").
# New parameters: "DynMask", "DynInflate", "DynTune", "KillNoise", "maskPatch".
# Version 1.22 : [non public] Optimized speed for a dynamic mask, MaskTools2 required.
# Version 1.23 : [non public] Added auto generation of a dynamic mask with ClipBlend (aka "DynMask=3").
# New parameters: "Dyn3Seq", "ClpBlend", "DynPostTune", "Dyn3buffer".
# Version 1.24 : 2020/11/28. Various tweaks. "Show" 3 & 4. Updated the manual with the new stuff.


One example of the dynamic logo/delogo is in the thread there -> Detect Position of Watermark in movie and remove with logo inpaint (https://forum.doom9.org/showthread.php?p=1929302#post1929302)

maybe your script will help if it work with mask clip :)
Check if it helps anything.

real.finder
28th November 2020, 18:34
New version released (updated the first post)
Check if it helps anything.

thanks! but it's still in "Attachments Pending Approval", can you upload it else where?

VoodooFX
28th November 2020, 19:53
Here are screens for another dynamic logo removal:

https://thumbs2.imgbox.com/2a/9b/7aj4bVy8_t.jpg (https://imgbox.com/7aj4bVy8) https://thumbs2.imgbox.com/a4/0e/8mbBUL3z_t.jpg (https://imgbox.com/8mbBUL3z)


12s GIF sample (stacked: original, dynamic mask, delogo output):

https://i.imgur.com/hq0JbO2.gif

manono
28th November 2020, 22:11
It's approved now. As I don't read every post in every forum, if you have something needing approval, you can PM me if you like.

StainlessS
29th November 2020, 01:47
In your [@ VoodooFX] post #118 attachment [12s GIF sample], I earlier saw a white flash in bottom image part, it is now gone.
[maybe at end of repeated loop]
EDIT: attachment update, ? EDIT: your shit, is "The Shit" (well good man) :)

VoodooFX
29th November 2020, 04:03
Maybe some flashback. :)

Nothing changed, just removed a pastebin link when manono approved the attachment on the first post.

manolito
29th November 2020, 07:35
Thanks for the new version... :thanks:

I have been very happy with the previous version, using only limited capabilities of the plugin. Only Inpaint mode and Analyze=4 for mask creation. Blew everything else out of the water for me.

Out of curiosity I used the new version for a few test conversions. I am not interested in the Dynamic Mask stuff, I just want to know if some of the "Various Tweaks" make a difference for me. The change which sticks out is that GrainPP is now OFF by default. I already made two conversions using the new version, and they looked beautiful. But then again the sources were not noisy at all, need to test it with grainy sources, too.

Thanks again, Cheers
manolito

real.finder
29th November 2020, 13:30
Check if it helps anything.

it did better in some cases and worse in some others, anyway I will add it in stab3

VoodooFX
29th November 2020, 14:03
it's did better in some cases and worse in some others, anyway I will add it in stab3
If you compare both script and plain plugin with defaults then script has better tuned defaults. Should be compared when running video result at normal fps, not looking at the static frames.
But those are optimized for normal logos, in your case you have only one side to interpolate, I'm sure that for this special case you can find better settings.



I am not interested in the Dynamic Mask stuff, I just want to know if some of the "Various Tweaks" make a difference for me. The change which sticks out is that GrainPP is now OFF by default.

Shouldn't be any visible changes to the old stuff, I encountered very few sources where "GrainPP" helps, so it's off by default as it's slow filter and can make artifacts standout a bit more for no reason.
"Various Tweaks" - just some "bug" catch asserts or speedup for the new stuff here and there, like at the last minute I added a conversion to Y8 for ClipBlend as it runs much faster without chroma present.

SkyBlue19
1st January 2021, 10:35
Hi All,

Happy New Year to you. I've been playing around with Inpaint Delogo, following the guide in the avsi file, the breakdown by manolito and this thread.

Here is before:

https://i.imgur.com/QynBHHz.png

Here is after:

https://i.imgur.com/Y1O9T94.png

As you can see it is mostly gone but there is a red smudge remaining. Can anyone suggest what I can do to remove that red smudge - if anything? I appreciate it is going into the black bar at the top but that isn't an issue for me as I am doing some color correction afterwards and will re-black it then.

Here is the first part of my script to generate the mask:

InpaintDelogo(mask="C:\Desktop\xxx.bmp",Automask=1, aMix=0, Loc="1150,10,-78,-652",Mode="Inpaint",Analyze=3, FrB=38604, FrW=132193, FrS=0)

And here is the second part for the logo removal:

Loc="1150,10,-78,-652"
InpaintDelogo(mask="C:\Desktop\xxx.bmp", Loc=Loc, Mode="Inpaint", Turbo=0)

Can anyone suggest anything? Or indeed anything to further improve the logo removal, not just the red smudge?

Many thanks

PS - I am a very basic avisynth user :)

VoodooFX
1st January 2021, 16:46
You asked me same yesterday by pm. :)

Cut black bars before doing anything, edit mask to cover that red bleed, maybe that bleed can be deblended in "both" mode.

https://i.imgur.com/3bEnoZV.png

SkyBlue19
3rd January 2021, 00:02
Ah different name and different site - small world :) I tried to expand the loc coordinates but that didn't seem to make much difference so I edited the bmp produced in stage one and drew some extra white pixels at the bottom, which has now got rid of the red smudge. Unfortunately "both" made it look at lot worse but I am happy now, looks great. Thanks again

katzenjoghurt
28th April 2021, 23:59
I played around with this super-promising script for some days now.
I wasn't happy with the result... my inprinted region always had some nasty "embossing" effect. The regions were very alive and with enough motion you could even read the text of the logo.

The result got better when cranking up post-blur and/or the radius... but it was never really great and the encoding times got unbearable.

Only now I realized that the script (or its defaults) don't like UHD resolution too much but it performs really well in FHD.
I guess that's due to the fact its parameters work with absolute pixels and maybe some internal values do so too.

So here is what I got:
https://i.imgur.com/50uBKuq.png

Both were encoded with the same default parameters:
InpaintDelogo(mask="V:\Logos\Test\Pack\ABC-Testlogo-Mask-FullHD.bmp",Automask=0,Loc="1370,32,-58,-982", Mode="Inpaint")
InpaintDelogo(mask="V:\Logos\Test\Pack\ABC-Testlogo-Mask-4k.bmp",Automask=0,Loc="2750,72,-126,-1966", Mode="Inpaint")

FullHD Source: https://youtu.be/KkX9Paq_LeA
FullHD with Logo: https://youtu.be/MfCvNclkj_o
FullHD Inpaint: https://youtu.be/YM1ouZyGDV8
UHD Source: https://youtu.be/GgE79UaAH2E
UHD with Logo: https://youtu.be/C-aLEDI65MM
UHD Inpaint: https://youtu.be/Pmo-TNh45q8

The clip is anything but perfect to show the problem but it gets most noticeable in the last 4secs of the UHD Inpaint clip.

edit:
Added a second example:
FullHD with Logo: https://youtu.be/8BLaVDqtuPA
FullHD Inpaint: https://youtu.be/vPNMzbtpaoA
UHD Inpaint: https://youtu.be/JEDn6bGiaGg


Attachments:
Masks (converted to PNGs due to size) and Overlays used to bake into videos.

VoodooFX
29th April 2021, 08:11
If with defaults you could cover every video source and logos, then parameters wouldn't be needed at all.
Your examples shows that problem is: 1) Not using parameters. 2) Upscaling is a bad thing. :)

On your 2x upscale you need to increase these at least, to get somewhat similar results to results on original:
inflate=2
radius=16

PS
Do you have real UHD with logo example, or you are just playing around with the synthetic tests!?

katzenjoghurt
29th April 2021, 09:21
Hi VoodooFX.

Of course I originally tried to delogo some UHD material and the result always came with that „emboss“ like effect you see in the comparison table I started playing around.

In fact the effect is even much more distracting there than I could simulate it with my iPad’s FHD camera and the upscales. But it was still visible and the very same problem.
It‘s not just visible in my synthetic tests. :)

But it would make sense to increase radius and inflate for UHD, yes. Just... as I mentioned the encoding times become pretty unbearable when cranking up radius/Post-Blur which lead to a better result for me. Didn‘t try inflate though yet.

What I do when programming computer games and working with blur shaders is doing the blur on a lower resolution to save performance. But no clue if that would work here without getting noticeable jaggies.

I‘ll do some more tests and look for some copyright-free real UHD clips.

VoodooFX
30th April 2021, 09:41
You can share short examples from copyrighted clips too, legally it's called "fair use".
From my side I could only increase max radius on 'mPPo', but I think smoothing 7 pixels around edges should be enough for UHD too.

loonvf
15th July 2021, 07:45
Hi All,

I'm trying to see if InpaintDelogo can solve my video problem too.
However I'm not successfull finding AVSInpaint.dll anywhere.
Any idea where to get the 32 and 64 bit versions of this dll

Thanks in advance,

loonvf

kedautinh12
15th July 2021, 07:49
Here:
https://github.com/pinterf/AvsInpaint/releases

kedautinh12
15th July 2021, 07:50
Avswiki if you find other plugins
http://avisynth.nl/index.php/External_filters

VoodooFX
15th July 2021, 16:07
However I'm not successfull finding AVSInpaint.dll anywhere.

All links are in the script, that is where you should look when you are trying any script, just open it with any text reader.

GMJCZP
26th July 2021, 16:49
Hello, where is the logo database located? These days I saw him but I no longer remember where he is.

VoodooFX
27th July 2021, 01:30
Hello, where is the logo database located? These days I saw him but I no longer remember where he is.
I don't know anything about the logo database.

GMJCZP
27th July 2021, 02:54
I don't know anything about the logo database.

Sorry, a link to a page with a database of logos from various television channels was published in another Doom9 post, but since I can't remember which one it is, I've made the comment here. I am so sorry.

StainlessS
27th July 2021, 12:36
database of logos
Maybe first few posts of this thread [EDIT: MeteorRain, DelogoHD]
is what you're lookin' for:- https://forum.doom9.org/showthread.php?t=176658

If not then google

"logo" NEAR "database" site:forum.doom9.org

given link is top of the link list of the google search.

GMJCZP
28th July 2021, 12:22
Effectively, it's DelogoHD, is here:

https://down.7086.in/lgd/

Thank you very much Mr. StainlessS aka TinMan!

kedautinh12
28th July 2021, 12:53
This link deprived SSTV and SSTV+

VoodooFX
28th July 2021, 22:58
Database can be build for InpaintDelogo too, here are the logo deblending masks for Arsenal VODs:

https://images2.imgbox.com/4a/14/Vn5mOtFB_o.png
Arsenal (not perfect analysis, but it's pretty good) (https://drive.google.com/file/d/1a0ufZ1KhqtB5AdIhEDB8KJZdBEByR8cR/view?usp=sharing)

Example how filename corresponds to settings:
Filename - "arsenal_4-3.bmp_InpaintDelogo_1500-56-334-936_A3_1-2-3.ebmp".
Notice naming rule - "Basemask_InpaintDelogo_Loc coordinates_Analyze_FrB-FrW-FrS".
If InpaintDelogo finds ebmp file corresponding to the settings then it won't do analyze/generate the masks, it would just use the masks from that file.

This command would find the logo deblending masks named as the example above:
InpaintDelogo( mask="D:\arsenal_4-3.bmp", Loc="1500,56,-334,-936", Mode="Deblend", Analyze=3, FrB=1, FrW=2, FrS=3, Deep=0)

VoodooFX
14th August 2021, 02:52
New v1.30, tuned to remove subtitles.
Relevant thread: https://forum.doom9.org/showthread.php?p=1949702

To remove subtitles in this case used:
InpaintDelogo(Loc="50,600,-50,-14", DynMask=3, DynTune=-4, DynInflate=4, Dyn3Seq=13, ClpBlend=11, Show=5)

Before:
https://i.imgur.com/qcVEKHU.jpg

After:
https://i.imgur.com/hrvr0ZI.jpeg

StainlessS
14th August 2021, 16:18
Thats quite amazing VX,
is it necessary for InPaintDeLogo call for each and every text sub, yes ?

Or can you just supply a mask same len as whole clip with detected logo in 'fine red' [255,0,0],
or can you also supply in planar Y channel, and as same size as input frame, or as entire subs
target locate area, where all subs live over entire clip.
[cant remember how InpaintDelogo works]

johnmeyer
14th August 2021, 19:56
That is a pretty amazing result.

GMJCZP
15th August 2021, 03:30
It is simply amazing!

VoodooFX has lived up to its name to "killing" subtitles, awesome! If I had this tool at my fingertips a few years ago I wouldn't have had to place a solid box on hardsubs of some series that I translated.

Is there a tutorial to apply this?

Edit: The jewel in the crown would be to extract these subtitles to an SRT file.

VoodooFX
15th August 2021, 08:48
It is simply amazing!

VoodooFX has lived up to its name to "killing" subtitles, awesome! If I had this tool at my fingertips a few years ago I wouldn't have had to place a solid box on hardsubs of some series that I translated.

Actually it's not good on sources like this anime, because video is too static, levels are above TV range, fansubs don't follow standards like minimum 1 second duration nor minimum 1 frame between subs... and I don't see point in bothering with them, better to join fansubs community and get unsubbed source there.

StainlessS' "DetectSub_MI" method should be much better for this case (but script is not finished for the end use).

You could use ssa subtitles, there is option to add soft black box.


Is there a tutorial to apply this?

There is help about parameters in the script.


The jewel in the crown would be to extract these subtitles to an SRT file.
This is what I'm mostly interested in, and it greatly helped in the process to convert hardsubs to softsubs, maybe one day I'll write tutorial how to do it.

VoodooFX
15th August 2021, 09:19
Thats quite amazing VX,
is it necessary for InPaintDeLogo call for each and every text sub, yes ?

Or can you just supply a mask same len as whole clip with detected logo in 'fine red' [255,0,0],
or can you also supply in planar Y channel, and as same size as input frame, or as entire subs
target locate area, where all subs live over entire clip.
[cant remember how InpaintDelogo works]

No, you can supply whole mask clip (B/W), full range YV12 is expected, I think "mask=maskClip" should do it, resolution must be same as "Loc" area/setting (it can be full frame).
What you want to do?

Btw, I'm interested in detection method you done in "DetectSub_MI", would it be possible to detect subs in a mask and extract them to images? One image per sub with time range in the filename, for example like "0_00_56_958__0_00_57_957.tiff".

GMJCZP
15th August 2021, 15:03
Actually it's not good on sources like this anime, because video is too static, levels are above TV range, fansubs don't follow standards like minimum 1 second duration nor minimum 1 frame between subs... and I don't see point in bothering with them, better to join fansubs community and get unsubbed source there.

StainlessS' "DetectSub_MI" method should be much better for this case (but script is not finished for the end use).

You could use ssa subtitles, there is option to add soft black box.


There is help about parameters in the script.


This is what I'm mostly interested in, and it greatly helped in the process to convert hardsubs to softsubs, maybe one day I'll write tutorial how to do it.

Thanks for your answers.

In regards to extracting hardsubs here are some links:

https://www.videoconverterfactory.com/tips/extract-hardcoded-subtitles.html

http://redonesubs.blogspot.com/p/extracting-hardsubs.html?m=1

Long ago I used Subrip but the time to teach the program is somewhat high.

StainlessS
15th August 2021, 16:06
No, you can supply whole mask clip (B/W), full range YV12 is expected, I think "mask=maskClip" should do it, resolution must be same as "Loc" area/setting (it can be full frame).
Thanks.
What you want to do?
Dont know, just wantin' to know what is required at the moment.

I'm interested in detection method you done in "DetectSub_MI",
From here [about an earlier version of the script, but mostly same] :- https://forum.doom9.org/showthread.php?p=1780125#post1780125

The script basically extracts from RGB color value eg $FEFEFE, the individual R,G,B components of both Text and Halo, then calculates the range limits for
each channel using CHANVAR (just saves user from specifying min and max for each color channel individually for both text and halo).
The ShowRed, etc lines isolate pixels that fall within the acceptable ranges for all 3 channels for text, and then AND's them together so result is pixels where all 3 channels are in acceptable range. Same is then done for HALO.

The for next loop, Expands (swells) the text [edit: by halo HALO_W,HALO_H] so as to swell into the halo region (both horizontally and vertically), and then expands the halo to swell into the text region [edit: by TEXT_W,TEXT_H]. (These are two swelled frames shown in diagnostic as TEXT and HALO frames).
Finally, the expanded/swelled frames are AND'ed together for the diagnostic shown DETECT frame.
This detect frame therefore contains white pixels where text/halo were valid colors, and because of the AND'ed swellings, it also shows where both
text and halo swelled 'into' each other ie where they were adjacent to each other (allows to ignore randomly positioned pixels which just happen to be the
sort after colors).

The FindSub routine just checks the scan area using RT_YInRangeLocate() to see if there is a suspect area of white(good) pixels of sufficient 'bulk'.



would it be possible to detect subs in a mask and extract them to images? One image per sub with time range in the filename, for example like "0_00_56_958__0_00_57_957.tiff".
thinkin' bout it.

VoodooFX
17th August 2021, 05:58
...Finally, the expanded/swelled frames are AND'ed together for the diagnostic shown DETECT frame.
This detect frame therefore contains white pixels where text/halo were valid colors, and because of the AND'ed swellings, it also shows where both
text and halo swelled 'into' each other ie where they were adjacent to each other (allows to ignore randomly positioned pixels which just happen to be the
sort after colors).

The FindSub routine just checks the scan area using RT_YInRangeLocate() to see if there is a suspect area of white(good) pixels of sufficient 'bulk'.
Are you going to finish it? I think DETECT frames expanded ~3-5 times should be good as a final mask to remove subs in this case (where there is a clear outline around subs), probably such mask wouldn't look good if outline is only at right/bottom or outline is thin.
There could be potential of somehow merging DynMask=3 method from InpaintDelogo with DetectSub_MI's DETECT'ed area cords/range.


thinkin' bout it.
That would be great, I could provide samples for tests if needed.

StainlessS
17th August 2021, 14:58
Are you going to finish it?
Hope so, however bit pushed for time.

Here what I've done so far, [this is really for testing purposes], not sure I've dont it correctly.


###
# DSub_MI, Based on DetectSub.MI.avsi":- https://forum.doom9.org/showthread.php?p=1782036#post1782036
###
# req RT_Stats v2.00 Beta 02, GScript, Grunt, CallCmd, MaskTools v2.0.
# RT_Stats v2.00 Beta2 first posted here:- http://forum.doom9.org/showthread.php?p=1782028#post1782028
#
###

Function Hit_Marker(int W, Int H, Bool "Hit", Int "BW", Int "BH",Int "PW",Int "PH",Bool "YV12",Bool "Mod2") {
Hit=Default(hit,False) BW=Max(Default(BW,W/8),1) BH=Max(Default(BH,H/8),1)
BW2=(W>4)?BW*2:BW BH2=(H>4)?BH*2:BH
PW=Max(Default(PW,BW/8),1) PH=Max(Default(PH,BH/8),1) is26 = VersionNumber>=2.6
YV12=(!is26) ? True : Default(YV12,False) Mod2=Default(Mod2,True) Mod = (YV12||Mod2) ? 2 : 1
CanvasW=(W+Mod-1)/Mod*Mod CanvasH=(H+Mod-1)/Mod*Mod
Rpn= RT_String("x %d < x %d >= | y %d < | y %d >= | x %d < x %d >= | & y %d < y %d >= | & ",BW,W-BW,BH,H-BH,BW2,W-BW2,BH2,H-BH2)
Rpn= (Hit) ? Rpn + RT_String("x %d < x %d >= | y %d < | y %d >= | | ",PW,W-PW,PH,H-PH) : Rpn
Rpn= Rpn + RT_String("x %d < y %d < & & 255 0 ?",W,H)
Blankclip(width=CanvasW,height=CanvasH,Length=1,pixel_type=YV12?"YV12":"Y8").Killaudio
return mt_lutspa(relative = false,yExpr=Rpn, chroma = "-128")
}


Function ChrIsStar(String S) {return RT_Ord(S)==42}
Function ChrIsNul(String S) {return RT_Ord(S)== 0} # End of String
Function ChrIsHash(String S) {return RT_Ord(S)==35} # #
Function ChrIsDigit(String S) {C=RT_Ord(S) return C>=48&&C<=57}
Function ChrEatWhite(String S) {i=1 C=RT_Ord(S,i) While(C==32||C>=8&&C<=13) {i=i+1 C=RT_Ord(S,i)} return i>1?MidStr(S,i):S}
Function ChrEatDigits(String S) {i=1 C=RT_Ord(S,i) While(C>=48&&C<=57) {i=i+1 C=RT_Ord(S,i)} return i>1?MidStr(S,i):S}

Function CnvStr(clip c) {
Return c.IsRGB24?"ConvertToRGB24":c.IsRGB32?"ConvertToRGB32":c.IsYUY2?"ConvertToYUY2":c.IsYV12?"ConvertToYV12"
\ :c.IsYV16?"c.ConvertToYV16":c.IsYV24?"c.ConvertToYV24":c.IsY8?"c.ConvertToY8":""
}

Function DetSub_Override(string Override,string DB) {
if(ChrIsStar(Override)) {OverRide=MidStr(OverRide,2)
} else {
Assert(Exist(OverRide),RT_String("%sOverRide File does not exist",myName))
OverRide=RT_ReadTxtFromFile(Override)
}
LINES=RT_TxtQueryLines(OverRide)
for(i=0,LINES-1) {
SS=ChrEatWhite(RT_TxtGetLine(Override,i))
S=SS
if(!ChrIsNul(S) && !ChrIsHash(S)) {
if(ChrIsDigit(S)) {
StartF = RT_NumberValue(S)
EndF=StartF
S=ChrEatWhite(ChrEatDigits(S))
if(ChrIsComma(S)){S=MidStr(S,2) S=ChrEatWhite(S)}
if(ChrIsDigit(S)) {
EndF=RT_NumberValue(S)
S=ChrEatDigits(S)
if(EndF==0) { EndF=FrameCount-1}
Assert(StartF<=EndF,RT_String("%sError StartFrame(%d) > EndFrame(%d)",myName,StartF,EndF))
}
for(n=StartF,EndF) {RT_DBaseSetField(DB,n,0,3)}
}
S=ChrEatWhite(S)
if(ChrIsHash(S)) {S=""}
Assert(ChrIsNul(S),RT_String("%s *** NON-PARSE *** Error in Override Line %d\n'%s'",myName,i+1,SS))
}
}
return 0
}


Function DetSub(clip c,string "Override",
\ Int "X",Int "Y",Int "W",Int "H",
\ Int "Text_w",Int "Text_h",Int "TextCol",Int "TextTol",
\ Int "Halo_L",Int "Halo_T",Int "Halo_R",Int "Halo_B",Int "HaloCol",Int "HaloTol",
\ Int "THysCNT",Int "HHysCNT",Int "DHysCNT",
\ Int "Baffle_w",Int "Baffle_h",Float "Thresh_w",Float "Thresh_h",Bool "ReScan",
\ String "DB") {
myName="DetSub: "
c
IsPlus=FindStr(VersionString,"AviSynth+")!=0
Assert(RT_FunctionExist("GScriptClip"),myName+"Essential GRunT plugin installed, http://forum.doom9.org/showthread.php?t=139337")
Assert(IsPlus||RT_FunctionExist("GScript"),myName+"Essential GScript plugin installed, http://forum.doom9.org/showthread.php?t=147846")
Assert(RT_FunctionExist("CallCmd"),myName+"Essential CallCmd plugin installed, http://forum.doom9.org/showthread.php?t=166063")
Assert(RT_FunctionExist("mt_expand"),myName+"Essential MaskTools v2 plugin installed, http://forum.doom9.org/showthread.php?t=98985")
Override=Default(OverRide,"")
X=Default(X,10) Y=Default(Y,Height-120) W=Default(W,-10) H=Default(H,-8)
W=(W<=0)?Width-X+W:W H=(H<=0)?Height-Y+H:H
Text_w=Default(Text_w,3) Text_h=Default(Text_h,3)
TextCol=Default(TextCol,$FCFCFC) TextTol=Default(TextTol,$030303)
Halo_L=Default(Halo_L,3) Halo_T=Default(Halo_T,4) Halo_R=Default(Halo_R,5) Halo_B=Default(Halo_B,6)
HaloCol=Default(HaloCol,$030303) HaloTol=Default(HaloTol,$030303)
Text_Tol_B=BitAnd(TextTol,$FF) TextTol=BitRShiftU(TextTol,8) Text_Tol_G=BitAnd(TextTol,$FF) TextTol=BitRShiftU(TextTol,8) Text_Tol_R=BitAnd(TextTol,$FF)
Halo_Tol_B=BitAnd(HaloTol,$FF) HaloTol=BitRShiftU(HaloTol,8) Halo_Tol_G=BitAnd(HaloTol,$FF) TextTol=BitRShiftU(HaloTol,8) Halo_Tol_R=BitAnd(HaloTol,$FF)
THysCNT=Default(THysCNT,0) HHysCNT=Default(HHysCNT,0) DHysCNT=Default(DHysCNT,0)
Baffle_w=Default(Baffle_w,0) Baffle_h=Default(Baffle_h,0)
Thresh_w=Default(Thresh_w,0.0) Thresh_h=Default(Thresh_h,0.0) ReScan=Default(ReScan,False)
DB=Default(DB,"") UserDB=(DB!="")
DB=(!UserDB) ? "~"+RT_LocalTimeString+".DB" : DB
DB=RT_GetFullPathName(DB)
VW=Width VH=Height
CNVS=CnvStr(c)
Assert(CNVS!="",RT_String("%sRGB24, RGB32, YUY2, YV12, YV16, YV24,and Y8 Only",myName))
/* Fields
0) Status, 0=Unknown (unvisited), 1=Sub, 2 Not sub, 3 User OverRide
1) X
2) Y
3) W
4) H
*/
RT_DBaseAlloc(DB,FrameCount,"iiiii")
RT_DBaseSetID(DB,0,c.FrameCount,c.FrameRate,VW,VH,X,Y,W,H)
if(OverRide!="") {DetSet_Override(Override,DB)}

LogoC=crop(0,Y,0,H) # Full width logo area

rgb=LogoC.ConvertToRGB32.Crop(X,0,W,0).ResetMask # Valid Logo Area only, Reset Alpha to White
TxtInRng=rgb.ColorKeyMask(TextCol,Text_Tol_R,Text_Tol_G,Text_Tol_B).ShowAlpha(Pixel_Type="Y8") # Set TextCol in range pixels to black
HalInRng=rgb.ColorKeyMask(HaloCol,Halo_Tol_R,Halo_Tol_G,Halo_Tol_B).ShowAlpha(Pixel_Type="Y8") # Set HaloCol in range pixels to black
TxtInRng=TxtInRng.Invert # Text In-range pixels white, else black
HalInRng=HalInRng.Invert # Halo In-range pixels white, else black

Text2 = TxtInRng
# Swell Text by Halo thickness [Including Halo Drop Shadow]
HALO_MAX=Max(HALO_L,HALO_T,HALO_R,HALO_B)
for(i=1,HALO_MAX) {
HorFlg=(i<=HALO_L?1:0)+(i<=HALO_R?2:0) VerFlg=(i<=HALO_T?1:0)+(i<=HALO_B?2:0)
if(HorFlg+VerFlg==6) {Text2=Text2.Mt_Expand(mode="square")
} else {
if(HorFlg==3) {Text2=Text2.Mt_Expand(mode="horizontal") HorFlg=0}
if(VerFlg==3) {Text2=Text2.Mt_Expand(mode="vertical") VerFlg=0}
if(HorFlg!=0) {Text2=Text2.Mt_Expand(mode=HorFlg==1? " 1 0 0 0" : " -1 0 0 0")}
if(VerFlg!=0) {Text2=Text2.Mt_Expand(mode=VerFlg==1? " 0 1 0 0" : " 0 -1 0 0")}
}
}

Text3=Text2
Text4=Text3
# reduce Text strays a little
if(THysCNT>0) {
For(i=1,THysCNT) {Text3=Text3.MT_Inpand(mode="both")}
Text4=Text3.MT_Hysteresis(Text2)
}

Halo2 = HalInRng
# Swell Halo by Text thickness
TEXT_MAX=Max(TEXT_W,TEXT_H)
for(i=1,TEXT_MAX) {
HorFlg=(i<=TEXT_W?1:0) VerFlg=(i<=TEXT_H?1:0)
if(HorFlg+VerFlg==2) {Halo2=Halo2.Mt_Expand(mode="square")
} else {
if(HorFlg!=0) {Halo2=Halo2.Mt_Expand(mode="horizontal") }
if(VerFlg!=0) {Halo2=Halo2.Mt_Expand(mode="vertical") }
}
}

Halo3=Halo2
Halo4=Halo3
# reduce Halo strays a little
if(HHysCNT>0) {
For(i=1,HHysCNT) {Halo3=Halo3.MT_Inpand(mode="both")}
Halo4=Halo3.MT_Hysteresis(Halo2)
}

Det1=Mt_Logic(Text4,Halo4,"and")
Det2=Det1
Det3=Det2
if(DHysCNT>0) {
For(i=1,DHysCNT) {Det2=Det2.MT_Inpand(mode="both")}
Det3=Det2.MT_Hysteresis(Det1)
}
SSS="""
n = current_frame
Status = RT_DBaseGetField(DB,n,0)
if(Status==0) { # Unknown Status
Status = (Det3.RT_YInRangeLocate(Baffle_w=Baffle_w,Baffle_h=Baffle_h,lo=255,hi=255,Thresh_w=Thresh_w,Thresh_h=Thresh_h,ReScan=ReScan)) ? 1 : 2
if(Status==1) { RT_DBaseSet(DB,n,Status,X+YIRL_X,Y+YIRL_Y,YIRL_W,YIRL_H) }
else { RT_DBaseSetField(DB,n,0,Status) }
}
if(Status==1) {
SUB_X = RT_DBaseGetField(DB,n,1) SUB_Y = RT_DBaseGetField(DB,n,2)
SUB_W = RT_DBaseGetField(DB,n,3) SUB_H = RT_DBaseGetField(DB,n,4)
SUB_W=(SUB_W+1)/2*2 SUB_H=(SUB_H+1)/2*2
OverLay(Last.BlankClip(color=$FF00FF,width=SUB_W,height=SUB_H),x=SUB_X,y=SUB_Y-Y,opacity=0.25)
}
Return Last
"""
LogoC=LogoC.GScriptClip(SSS, local=true, args="Det3,DB,X,Y,W,H,Baffle_w,Baffle_h,Thresh_w,Thresh_h,ReScan")
Mrk=LogoC.BlankClip(Length=1,Width=W,Height=H,Color=$FF00FF)
Msk=Hit_Marker(W,H,True,8,8,1,1)
LogoC=LogoC.Overlay(Mrk,Mask=Msk,x=X,y=0,Opacity=0.5)
LogoC=LogoC.AddBorders(0,22,0,0,$F0F080).Subtitle("LogoArea (Full width)",y=2)
Det3=Det3.Eval(CnvS).AddBorders(X,0,Width-X-W,0).AddBorders(0,22,0,0,$F0F080).Subtitle("Detect3 : DETECT FINAL, [Detect2.MT_Hysteresis(Detect1)]",y=2)
Det2=Det2.Eval(CnvS).AddBorders(X,0,Width-X-W,0).AddBorders(0,22,0,0,$F0F080).Subtitle("Detect2 : [Detect1 Inpand by DHysCNT, reduce stray pixels]",y=2)
Det1=Det1.Eval(CnvS).AddBorders(X,0,Width-X-W,0).AddBorders(0,22,0,0,$F0F080).Subtitle("Detect1 : Text4 AND Halo4",y=2)
Text4=Text4.Eval(CnvS).AddBorders(X,0,Width-X-W,0).AddBorders(0,22,0,0,$F0F080).Subtitle("Text4 : [Text3.MT_Hysteresis(Text2)]",y=2)
Text3=Text3.Eval(CnvS).AddBorders(X,0,Width-X-W,0).AddBorders(0,22,0,0,$F0F080).Subtitle("Text3 : [Text2 Inpand by THysCNT, reduce stray pixels]",y=2)
Text2=Text2.Eval(CnvS).AddBorders(X,0,Width-X-W,0).AddBorders(0,22,0,0,$F0F080).Subtitle("Text2 : [Swell Text1 by Halo thickness]",y=2)
TxtInRng=TxtInRng.Eval(CnvS).AddBorders(X,0,Width-X-W,0).AddBorders(0,22,0,0,$F0F080).Subtitle("Text1 : [TextInRange via TEXTCOL & TEXTTOL]",y=2)
Halo4=Halo4.Eval(CnvS).AddBorders(X,0,Width-X-W,0).AddBorders(0,22,0,0,$F0F080).Subtitle("Halo4 : [Halo3.MT_Hysteresis(Halo2)]",y=2)
Halo3=Halo3.Eval(CnvS).AddBorders(X,0,Width-X-W,0).AddBorders(0,22,0,0,$F0F080).Subtitle("Halo3 : [Halo2 Inpand by HHysCNT, reduce stray pixels]",y=2)
Halo2=Halo2.Eval(CnvS).AddBorders(X,0,Width-X-W,0).AddBorders(0,22,0,0,$F0F080).Subtitle("Halo2 : [Swell Halo1 by Text thickness]",y=2)
HalInRng=HalInRng.Eval(CnvS).AddBorders(X,0,Width-X-W,0).AddBorders(0,22,0,0,$F0F080).Subtitle("Halo1 : [HaloInRange via HALOCOL & HALOTOL]",y=2)
StackVertical(LogoC,Det3,Det2,Det1,Text4,Halo4,Text3,Halo3,Text2,Halo2,TxtInRng,HalInRng)
Return Last
}

############################

HARDFN="hard sub - 01 WEBdlRip 720p, 23.976.mkv.AVI" # converted to AVI via ffmpeg
HARDFN=HARDFN.RT_GetFullPathName

AVISource(HARDFN)
killaudio


# Subtitle coords
X = 40
Y = Height-140
W = -X
H = -8
# Text, Halo color
TEXTCOL = $EDEEF4 # R 230->245[$ED:$8] ::: G 230->247 [$EE:$9]::: B 233->255 [$F4:$B]
TEXTTOL = $08090B # Text RGB channels can vary by as much as TEXTTOL, eg TEXTTOL $010203 is Red Tolerance $01, Grn Tolerance $02, Blue Tolerance $03.
HALOCOL = $10313D # R 7->26[$10:$A] ::: G 37->62[$31:$D] ::: B 55->68[$3D:7]
HALOTOL = $0A0D07 # Halo RGB channels can vary by as much as HALOTOL, eg HALOTOL $010203 is Red Tolerance $01, Grn Tolerance $02, Blue Tolerance $03.
# Text pixel width,height
TEXT_W = 4 # minimum text pixel 'thickness' Horizontal (horizontal thickness of vertical strokes)
TEXT_H = 4 # minimum text pixel 'thickness' Vertical (vertical thickness of horizontal strokes)
# Halo pixel width,height
HALO_L = 2 # Left Halo width in pixels
HALO_R = 2 # Right Halo width in pixels
HALO_T = 2 # Top Halo height in pixels
HALO_B = 2 # Bot Halo height in pixels
# Mt_Hysteresis (reduce stray pixels):- http://forum.doom9.org/showthread.php?p=1780589#post1780589
THYSCNT = 2 # Text Mask Mt_Hysteresis inpand count (prior to mt_hysteresis), Dont Mt_Hysteresis if 0
HHYSCNT = 2 # Halo Mask Mt_Hysteresis inpand count (prior to mt_hysteresis), Dont Mt_Hysteresis if 0
DHYSCNT = 2 # Detect clip Mt_Hysteresis inpand count (prior to mt_hysteresis), Dont Mt_Hysteresis if 0

######

THRESH_W = -(Text_w+(Halo_L+Halo_R)/2) # -ve, specifies Abs(Pixel width) {Else +ve = Percent width 0.0->100.0%) {0.0=any pixel in range)
THRESH_H = -(Text_h+(Halo_T+Halo_B)/2) # -ve, specifies Abs(Pixel Height) {Else +ve = Percent width 0.0->100.0%) {0.0=any pixel in range)
#
BAFFLE_W = Text_w+Halo_L+Halo_R # Width of outermost Vertical edges.
BAFFLE_H = Text_h+Halo_T+Halo_B # Height of outermost Horizontal edges.
#
RESCAN = true # Switching on might get rid of the odd stray pixel (most likely not).
#
DB = "MyDB.DB" # If Named, then DB not deleted on exit. (Maybe DBase used by other scripts later)
OverRide = "" # ""=Not used, "*..." multiline string of ranges, "OverRide.txt"=Text file of ranges.

#OverRide="OverRide.txt"

/*
OverRide="""* # <<=== NOTE Asterisk (STAR). Example String OverRide (1st char is '*'). Ranges OverRidden to NO SUBTITLE
10 100 # A comment, SPACE or COMMA Separator
200,300 # 200 to 300. NOTE -ve frame count NOT supported.
3000,0 # 3000 till last frame.
"""
*/

DetSub(Last,Override=Override,
\ x=X,y=Y,w=W,h=H,
\ Text_w=TEXT_W,Text_h=TEXT_H,TextCol=TEXTCOL,TextTol=TEXTTOL,
\ Halo_L=HALO_L,Halo_T=HALO_T,Halo_R=HALO_R,Halo_B=HALO_B,HaloCol=HALOCOL,HaloTol=HALOTOL,
\ THysCnt=THYSCNT,HHysCnt=HHYSCNT,DHysCnt=DHYSCNT,
\ Baffle_w=BAFFLE_W,Baffle_h=BAFFLE_H,Thresh_w=THRESH_W,Thresh_h=THRESH_H,ReScan=RESCAN,
\ db=DB)


In VDub2, can set to 100% and using mouse scroll image in window. [EDIT: If eg monitor Full HD or less]

https://i.postimg.cc/wRRTbdTZ/Det-Sub-00.png (https://postimg.cc/wRRTbdTZ)

Something to play with. [EDIT: Avs+ only]

EDIT: TEXTTOL and HALOTOL instead of TEXTVAR and HALOVAR, separate tolerance per channel.
Script & image updated.

VoodooFX
18th August 2021, 14:50
Here what I've done so far

Thanks, the script looks more readable now, maybe I'll be able to steal some ideas now. :)

Is there real advantage of TOL over VAR (I kinda liked a simple setting)?

StainlessS
18th August 2021, 22:12
EDIT: Here are the supplementary script functions.


###
# DSub_MI, Based on DetectSub.MI.avsi":- https://forum.doom9.org/showthread.php?p=1782036#post1782036
###
# Req Avs+, RT_Stats v2.00 Beta 02, GScript, Grunt, CallCmd, MaskTools v2.0. RemoveGain or RGTools.
# RT_Stats v2.00 Beta2 first posted here:- http://forum.doom9.org/showthread.php?p=1782028#post1782028
#
###

Function Hit_Marker(int W, Int H, Bool "Hit", Int "BW", Int "BH",Int "PW",Int "PH",Bool "YV12",Bool "Mod2") {
/*
Req RT_Stats & mt_tools v2. http://forum.doom9.org/showthread.php?t=174527
Creates a marker mask WxH, for use with Overlay as Mask arg.
Intended for use via some kind of detector to show detection Hit, or Miss.
Returns Single frame clip with null audio, the marker top left hand side is aligned to 0,0.
Default return clip colorspace is Y8 for Avisynth v2.6 and above, or YV12 if defunct version.
Args:-
W,H, Size of marker mask (can be odd), return clip dimensions are rounded up to next multiple of 2 if YV12 return clip.
Bare minimum usable size is 4x4 with defaulted BW, BH, PW, PH.
HIT, Default False, returns marker as angled corners (Thickness set by BW and BH).
True, returns marker as angled corners + outer perimeter where perimeter thickness set by PW and PH.
BW, Default Max(W/8,1). Horizontal thickness of the marker corners.
BH, Default Max(H/8,1). Vertical thickness of the marker corners.
PW, Default Max(BW/8,1). Horizontal thickness of the vertical perimeter.
PH, Default Max(BH/8,1). Vertical thickness of the horizontal perimeter.
YV12, Default False if Avisynth version 2.6 or greater(Y8), else true(YV12). Selects return clip colorspace.
Mod2, Default True. If Y8 then round odd dimensions up modulo 2 (the mask is still WxH).

Example:-
Import("Hit_Marker.avs")
WW=128 HH=WW HIT=True
BlankClip
Yell=Last.BlankClip(Width=WW,Height=HH,Length=1,Color=$FFFF00)
Return OverLay(Yell,x=(Width-WW)/2,y=(Height-HH)/2,mask=Hit_Marker(WW,HH,HIT))
*/
Hit=Default(hit,False) BW=Max(Default(BW,W/8),1) BH=Max(Default(BH,H/8),1)
BW2=(W>4)?BW*2:BW BH2=(H>4)?BH*2:BH
PW=Max(Default(PW,BW/8),1) PH=Max(Default(PH,BH/8),1) is26 = VersionNumber>=2.6
YV12=(!is26) ? True : Default(YV12,False) Mod2=Default(Mod2,True) Mod = (YV12||Mod2) ? 2 : 1
CanvasW=(W+Mod-1)/Mod*Mod CanvasH=(H+Mod-1)/Mod*Mod
Rpn= RT_String("x %d < x %d >= | y %d < | y %d >= | x %d < x %d >= | & y %d < y %d >= | & ",BW,W-BW,BH,H-BH,BW2,W-BW2,BH2,H-BH2)
Rpn= (Hit) ? Rpn + RT_String("x %d < x %d >= | y %d < | y %d >= | | ",PW,W-PW,PH,H-PH) : Rpn
Rpn= Rpn + RT_String("x %d < y %d < & & 255 0 ?",W,H)
Blankclip(width=CanvasW,height=CanvasH,Length=1,pixel_type=YV12?"YV12":"Y8").Killaudio
return mt_lutspa(relative = false,yExpr=Rpn, chroma = "-128")
}


Function ChrIsStar(String S) {return RT_Ord(S)==42}
Function ChrIsNul(String S) {return RT_Ord(S)== 0} # End of String
Function ChrIsHash(String S) {return RT_Ord(S)==35} # #
Function ChrIsDigit(String S) {C=RT_Ord(S) return C>=48&&C<=57}
Function ChrEatWhite(String S) {i=1 C=RT_Ord(S,i) While(C==32||C>=8&&C<=13) {i=i+1 C=RT_Ord(S,i)} return i>1?MidStr(S,i):S}
Function ChrEatDigits(String S) {i=1 C=RT_Ord(S,i) While(C>=48&&C<=57) {i=i+1 C=RT_Ord(S,i)} return i>1?MidStr(S,i):S}

Function DetSub_Override(string Override,string DB) {
if(ChrIsStar(Override)) {OverRide=MidStr(OverRide,2)
} else {
Assert(Exist(OverRide),RT_String("%sOverRide File does not exist",myName))
OverRide=RT_ReadTxtFromFile(Override)
}
LINES=RT_TxtQueryLines(OverRide)
for(i=0,LINES-1) {
SS=ChrEatWhite(RT_TxtGetLine(Override,i))
S=SS
if(!ChrIsNul(S) && !ChrIsHash(S)) {
if(ChrIsDigit(S)) {
StartF = RT_NumberValue(S)
EndF=StartF
S=ChrEatWhite(ChrEatDigits(S))
if(ChrIsComma(S)){S=MidStr(S,2) S=ChrEatWhite(S)}
if(ChrIsDigit(S)) {
EndF=RT_NumberValue(S)
S=ChrEatDigits(S)
if(EndF==0) { EndF=FrameCount-1}
Assert(StartF<=EndF,RT_String("%sError StartFrame(%d) > EndFrame(%d)",myName,StartF,EndF))
}
for(n=StartF,EndF) {RT_DBaseSetField(DB,n,0,3)}
}
S=ChrEatWhite(S)
if(ChrIsHash(S)) {S=""}
Assert(ChrIsNul(S),RT_String("%s *** NON-PARSE *** Error in Override Line %d\n'%s'",myName,i+1,SS))
}
}
return 0
}

StainlessS
19th August 2021, 14:37
/*

function Prototype:
DetSub(clip c,Int "X"=-10,Int "Y"=Height-120,Int "W"=-10,Int "H"=-8,
\ Int "Text_w"=3,Int "Text_h"=3,Int "TextCol"=$FCFCFC,Int "TextTol"=$030303,
\ Int "Halo_L"=3,Int "Halo_T"=3,Int "Halo_R"=3,Int "Halo_B"=3,Int "HaloCol"=$030303,Int "HaloTol"=$030303,
\ int "BackColor"=$00FF00,Int "ClipIx"=0,string "Matrix"="rec601",String "DB"="",string "Override"="")

Matrix, for src conversion to RGB32.

ClipIx select which sub clip to return, [DetSub, output always RGB32 with Alpha = known state $FF (opaque)]
0) = Full detect Info clip, same width as input clip.
1->15) = Other sub clip, dimensions X,Y,W,H.

*/
Function DetSub(clip c,Int "X",Int "Y",Int "W",Int "H",
\ Int "Text_w",Int "Text_h",Int "TextCol",Int "TextTol",
\ Int "Halo_L",Int "Halo_T",Int "Halo_R",Int "Halo_B",Int "HaloCol",Int "HaloTol",
\ int "BackColor",Int "ClipIx",string "Matrix",String "DB",string "Override") {
myName="DetSub: "
c
IsPlus=FindStr(VersionString,"AviSynth+")!=0
Assert(RT_FunctionExist("GScriptClip"),myName+"Essential GRunT plugin installed, http://forum.doom9.org/showthread.php?t=139337")
Assert(IsPlus||RT_FunctionExist("GScript"),myName+"Essential GScript plugin installed, http://forum.doom9.org/showthread.php?t=147846")
Assert(RT_FunctionExist("CallCmd"),myName+"Essential CallCmd plugin installed, http://forum.doom9.org/showthread.php?t=166063")
Assert(RT_FunctionExist("mt_expand"),myName+"Essential MaskTools v2 plugin installed, http://forum.doom9.org/showthread.php?t=98985")
Assert(RT_FunctionExist("RemoveGrain"),myName+"Essential RemoveGrain installed.")
X=Default(X,10) Y=Default(Y,Height-120) W=Default(W,-10) H=Default(H,-8)
W=(W<=0)?Width-X+W:W H=(H<=0)?Height-Y+H:H
Text_w=Default(Text_w,3) Text_h=Default(Text_h,3)
TextCol=Default(TextCol,$FCFCFC) TextTol=Default(TextTol,$030303)
Halo_L=Default(Halo_L,3) Halo_T=Default(Halo_T,3) Halo_R=Default(Halo_R,3) Halo_B=Default(Halo_B,3)
HaloCol=Default(HaloCol,$030303) HaloTol=Default(HaloTol,$030303)
Text_Tol_B=BitAnd(TextTol,$FF) TextTol=BitRShiftU(TextTol,8) Text_Tol_G=BitAnd(TextTol,$FF) TextTol=BitRShiftU(TextTol,8) Text_Tol_R=BitAnd(TextTol,$FF)
Halo_Tol_B=BitAnd(HaloTol,$FF) HaloTol=BitRShiftU(HaloTol,8) Halo_Tol_G=BitAnd(HaloTol,$FF) HaloTol=BitRShiftU(HaloTol,8) Halo_Tol_R=BitAnd(HaloTol,$FF)
BackColor=Default(BackColor,$00FF00) # Background for Det4, DETECT FINAL
Matrix = Default(Matrix,"Rec601")
Ix = Default(ClipIx,0)
Assert(0 <= Ix <=15,MyName+"0 <= ClipIx <=15")
DB=Default(DB,"") UserDB=(DB!="")
DB=(!UserDB) ? "~"+RT_LocalTimeString+".DB" : DB
DB=RT_GetFullPathName(DB)
Override=Default(OverRide,"")
###
# Mt_Hysteresis (reduce stray pixels):- http://forum.doom9.org/showthread.php?p=1780589#post1780589
# Text Mask Mt_Hysteresis inpand count (prior to mt_hysteresis), Dont Mt_Hysteresis if 0
THYSCNT = Min(TEXT_W,TEXT_H)/2 - 1
# Halo Mask Mt_Hysteresis inpand count (prior to mt_hysteresis), Dont Mt_Hysteresis if 0
HHYSCNT = Min(HALO_L,HALO_R,HALO_T,HALO_B)/2 - 1
# Detect clip Mt_Hysteresis inpand count (prior to mt_hysteresis), Dont Mt_Hysteresis if 0
DHYSCNT = Min(TEXT_W+HALO_L+HALO_R,TEXT_H+HALO_T+HALO_B)/2 - 1
###### Subs detect position
THRESH_W = -(Text_w+(Halo_L+Halo_R)/2) # -ve, specifies Abs(Pixel width) {Else +ve = Percent width 0.0->100.0%) {0.0=any pixel in range)
THRESH_H = -(Text_h+(Halo_T+Halo_B)/2) # -ve, specifies Abs(Pixel Height) {Else +ve = Percent width 0.0->100.0%) {0.0=any pixel in range)
BAFFLE_W = Text_w+Halo_L+Halo_R # Width of outermost Vertical edges.
BAFFLE_H = Text_h+Halo_T+Halo_B # Height of outermost Horizontal edges.
RESCAN = true # Switching on might get rid of the odd stray pixel (most likely not).
###
VW=Width VH=Height
/* Fields
0) Status, 0=Unknown (unvisited), 1=Sub, 2 Not sub, 3 User OverRide
1) X # Coords relative the Subtitles X,Y,W,H Detect Area
2) Y
3) W
4) H
*/
RT_DBaseAlloc(DB,FrameCount,"iiiii")
RT_DBaseSetID(DB,0,c.FrameCount,c.FrameRate,VW,VH,X,Y,W,H)
if(OverRide!="") {DetSet_Override(Override,DB)}

FullWidSubC=ConvertToRGB32(matrix=Matrix).crop(0,Y,0,H) # Full width Subs area

Area=FullWidSubC.Crop(X,0,W,0).ResetMask # Valid Subs Area only, Reset Alpha to White
Text1=Area.ColorKeyMask(TextCol,Text_Tol_R,Text_Tol_G,Text_Tol_B).ShowAlpha(Pixel_Type="Y8") # Set TextCol in range pixels to black
Halo1=Area.ColorKeyMask(HaloCol,Halo_Tol_R,Halo_Tol_G,Halo_Tol_B).ShowAlpha(Pixel_Type="Y8") # Set HaloCol in range pixels to black
Text1=Text1.Invert # Text In-range pixels white, else black
Halo1=Halo1.Invert # Halo In-range pixels white, else black

Text2 = Text1.RemoveGrain(2)
Halo2 = Halo1.RemoveGrain(2)


Text3 = Text2
# Swell Text by Halo thickness [Including Halo Drop Shadow]
HALO_MAX=Max(HALO_L,HALO_T,HALO_R,HALO_B)
for(i=1,HALO_MAX) {
HorFlg=(i<=HALO_L?1:0)+(i<=HALO_R?2:0) VerFlg=(i<=HALO_T?1:0)+(i<=HALO_B?2:0)
if(HorFlg+VerFlg==6) {Text3=Text3.Mt_Expand(mode="square")
} else {
if(HorFlg==3) {Text3=Text3.Mt_Expand(mode="horizontal") HorFlg=0}
if(VerFlg==3) {Text3=Text3.Mt_Expand(mode="vertical") VerFlg=0}
if(HorFlg!=0) {Text3=Text3.Mt_Expand(mode=HorFlg==1? " 1 0 0 0" : " -1 0 0 0")} # ? Expand_Left : Expand_Right
if(VerFlg!=0) {Text3=Text3.Mt_Expand(mode=VerFlg==1? " 0 1 0 0" : " 0 -1 0 0")} # ? Expand_Up : Expand_Down
}
}

Text4=Text2
Text5=Text3
# reduce Text strays a little
if(THysCNT>0) {
For(i=1,THysCNT) {Text4=Text4.MT_Inpand(mode="both")}
Text5=Text4.MT_Hysteresis(Text3)
}

Halo3 = Halo2
# Swell Halo by Text thickness
TEXT_MAX=Max(TEXT_W,TEXT_H)
for(i=1,TEXT_MAX) {
HorFlg=(i<=TEXT_W?1:0) VerFlg=(i<=TEXT_H?1:0)
if(HorFlg+VerFlg==2) {Halo3=Halo3.Mt_Expand(mode="square")
} else {
if(HorFlg!=0) {Halo3=Halo3.Mt_Expand(mode="horizontal") }
if(VerFlg!=0) {Halo3=Halo3.Mt_Expand(mode="vertical") }
}
}

Halo4=Halo2
Halo5=Halo3
# reduce Halo strays a little
if(HHysCNT>0) {
For(i=1,HHysCNT) {Halo4=Halo4.MT_Inpand(mode="both")}
Halo5=Halo4.MT_Hysteresis(Halo3)
}

Detect1=Mt_Logic(Text5,Halo5,"and")
Detect2=Detect1
Detect3=Detect2
Ocr1=Text2
if(DHysCNT>0) {
For(i=1,DHysCNT) {Detect2=Detect2.MT_Inpand(mode="both")}
Detect3=Detect2.MT_Hysteresis(Detect1)
Ocr1=Detect2.MT_Hysteresis(Mt_Logic(Text2,Detect3,"and"))
}


SSS1="""
n = current_frame
Status = RT_DBaseGetField(DB,n,0)
if(Status==0) { # Unknown Status
Status = (Detect3.RT_YInRangeLocate(Baffle_w=Baffle_w,Baffle_h=Baffle_h,lo=255,hi=255,Thresh_w=Thresh_w,Thresh_h=Thresh_h,ReScan=ReScan)) ? 1 : 2
if(Status==1) {
RT_DBaseSet(DB,n,Status,YIRL_X,YIRL_Y,YIRL_W,YIRL_H)
}
RT_DBaseSetField(DB,n,0,Status)
}
Return Last
"""
FullWidSubC=FullWidSubC.GScriptClip(SSS1, local=true, args="Detect3,DB,Baffle_w,Baffle_h,Thresh_w,Thresh_h,ReScan",after_frame=true)
Grn=Detect3.BlankClip(Pixel_Type="RGB32",color=BackColor)
Ocr2=Grn.Overlay(Grn.BlankClip(color=$000000),Mask=Detect3.RemoveGrain(2)).Overlay(Ocr1,Mask=Ocr1)

SSS2="""
n = current_frame
Status = RT_DBaseGetField(DB,n,0)
if(Status==1) {
SUB_X = RT_DBaseGetField(DB,n,1) SUB_Y = RT_DBaseGetField(DB,n,2)
SUB_W = RT_DBaseGetField(DB,n,3) SUB_H = RT_DBaseGetField(DB,n,4)
OverLay(Last.BlankClip(color=$FF00FF,width=SUB_W,height=SUB_H),x=X+SUB_X,y=SUB_Y,opacity=0.25)
}
Return Last
"""
FullWidSubC=FullWidSubC.GScriptClip(SSS2, local=true, args="Detect3,DB,X",after_frame=true)
Mrk=FullWidSubC.BlankClip(Length=1,Width=W,Height=H,Color=$FFFF0000)
Msk=Hit_Marker(W,H,True,8,8,1,1)
FullWidSubC=FullWidSubC.Overlay(Mrk,Mask=Msk,x=X,y=0,Opacity=0.5)
FullWidSubC=FullWidSubC.AddBorders(0,22,0,0,$F0F080).Subtitle("0] SubsArea (Search area in Red, detected subs in purple)",y=2)
Ocr2_T=Ocr2.AddBorders(X,0,Width-X-W,0,BackColor).AddBorders(0,22,0,0,$F0F080).Subtitle("1] OCR2 : [GreenC.Overlay(Blackness.Mask=Detect3.RemoveGrain(2)).Overlay(Ocr1,Mask=Ocr1)]",y=2)
Ocr1_T=Ocr1.ConvertToRGB32.AddBorders(X,0,Width-X-W,0,$000000).AddBorders(0,22,0,0,$F0F080).Subtitle("2] OCR1 : [Detect2.MT_Hysteresis(Mt_Logic(Text2,Detect3,'and'))]",y=2)
Detect3_T=Detect3.ConvertToRGB32.AddBorders(X,0,Width-X-W,0,$000000).AddBorders(0,22,0,0,$F0F080).Subtitle("3] Detect3 : [Detect2.MT_Hysteresis(Detect1), reduce stray pixels]",y=2)
Detect2_T=Detect2.ConvertToRGB32.AddBorders(X,0,Width-X-W,0,$000000).AddBorders(0,22,0,0,$F0F080).Subtitle(String(DHysCNT,"4] Detect2 : [Detect1 Inpand by DHysCNT(%.0f))]"),y=2)
Detect1_T=Detect1.ConvertToRGB32.AddBorders(X,0,Width-X-W,0,$000000).AddBorders(0,22,0,0,$F0F080).Subtitle("5] Detect1 : Text5 AND Halo5",y=2)
Text5_T=Text5.ConvertToRGB32.AddBorders(X,0,Width-X-W,0,$000000).AddBorders(0,22,0,0,$F0F080).Subtitle("6] Text5 : [Text4.MT_Hysteresis(Text3), reduce stray pixels]",y=2)
Text4_T=Text4.ConvertToRGB32.AddBorders(X,0,Width-X-W,0,$000000).AddBorders(0,22,0,0,$F0F080).Subtitle(String(THysCNT,"7] Text4 : [Text2 Inpand by THysCNT(%.0f)]"),y=2)
Text3_T=Text3.ConvertToRGB32.AddBorders(X,0,Width-X-W,0,$000000).AddBorders(0,22,0,0,$F0F080).Subtitle("8] Text3 : [Swell Text2 by Halo thickness]",y=2)
Text2_T=Text2.ConvertToRGB32.AddBorders(X,0,Width-X-W,0,$000000).AddBorders(0,22,0,0,$F0F080).Subtitle("9] Text2 : [UnDot, Text1.RemoveGrain(2)]",y=2)
Text1_T=Text1.ConvertToRGB32.AddBorders(X,0,Width-X-W,0,$000000).AddBorders(0,22,0,0,$F0F080).Subtitle("10] Text1 : [TextInRange via TEXTCOL & TEXTTOL]",y=2)
Halo5_T=Halo5.ConvertToRGB32.AddBorders(X,0,Width-X-W,0,$000000).AddBorders(0,22,0,0,$F0F080).Subtitle("11] Halo5 : [Halo4.MT_Hysteresis(Halo3), reduce stray pixels]",y=2)
Halo4_T=Halo4.ConvertToRGB32.AddBorders(X,0,Width-X-W,0,$000000).AddBorders(0,22,0,0,$F0F080).Subtitle(String(HHysCNT,"12] Halo4 : [Halo2 Inpand by HHysCNT(%.0f)]"),y=2)
Halo3_T=Halo3.ConvertToRGB32.AddBorders(X,0,Width-X-W,0,$000000).AddBorders(0,22,0,0,$F0F080).Subtitle("13] Halo3 : [Swell Halo2 by Text thickness]",y=2)
Halo2_T=Halo2.ConvertToRGB32.AddBorders(X,0,Width-X-W,0,$000000).AddBorders(0,22,0,0,$F0F080).Subtitle("14] Halo2 : [UnDot, Halo1.RemoveGrain(2)]",y=2)
Halo1_T=Halo1.ConvertToRGB32.AddBorders(X,0,Width-X-W,0,$000000).AddBorders(0,22,0,0,$F0F080).Subtitle("15] Halo1 : [HaloInRange via HALOCOL & HALOTOL]",y=2)
C0=StackVertical(FullWidSubC,Ocr2_T,Ocr1_T,Detect3_T,Detect2_T,Detect1_T,Text5_T,Text4_T,Text3_T,Text2_T,Text1_T,Halo5_T,Halo4_T,Halo3_T,Halo2_T,Halo1_T)
Ix==0?C0:Ix==1?Ocr2:Ix==2?Ocr1:Ix==3?Detect3:Ix==4?Detect2:Ix==5?Detect1:Ix==6?Text5:Ix==7?Text4:Ix==8?Text3:Ix==9?Text2:Ix==10?Text1:Ix==11?Halo5:Ix==12?Halo4:Ix==13?Halo3:Ix==14?Halo2:Halo1
Return ConvertToRGB32(Matrix="PC601").ResetMask # Alpha = $FF
}

############################

HARDFN="hard sub - 01 WEBdlRip 720p, 23.976.mkv.AVI" # converted to AVI via ffmpeg
HARDFN=HARDFN.RT_GetFullPathName

AVISource(HARDFN)
killaudio

# Subtitle coords
X = 58
Y = Height-118
W = -X
H = -16
# Text, Halo color

TEXTCOL = $F3F3F3
TEXTTOL = $0E0E0E

HALOCOL = $102A37
HALOTOL = $121212

# Setting all below too narrow[eg all 2 on test sample], produces odd effect where subs shown are actually mid way between text and halo, looks pretty good result but wrong.
# Also has peculiar property where seems to ignore random garbage in result adjacent to subs.
# Text pixel width,height
TEXT_W = 4 # minimum text pixel 'thickness' Horizontal (horizontal thickness of vertical strokes)
TEXT_H = 4 # minimum text pixel 'thickness' Vertical (vertical thickness of horizontal strokes)
# Halo pixel width,height
HALO_L = 3 # Left Halo width in pixels
HALO_R = 3 # Right Halo width in pixels
HALO_T = 3 # Top Halo height in pixels
HALO_B = 3 # Bot Halo height in pixels

BACKCOLOR = $00FF00 # Background for OCR2 bar

MATRIX = "Rec601"
ClipIx = 0 # 0=full metric clip[Full width, H height].
# 1 -> 15, other clip[Size X,Y,W,H]. always RGB32 result.
##################
DB = "MyDB.DB" # If Named, then DB not deleted on exit. (Maybe DBase used by other scripts later)
OverRide = "" # ""=Not used, "*..." multiline string of ranges, "OverRide.txt"=Text file of ranges.
#OverRide="OverRide.txt"

/*
OverRide="""* # <<=== NOTE Asterisk (STAR). Example String OverRide (1st char is '*'). Ranges OverRidden to NO SUBTITLE
10 100 # A comment, SPACE or COMMA Separator
200,300 # 200 to 300. NOTE -ve frame count NOT supported.
3000,0 # 3000 till last frame.
"""
*/

DetSub(x=X,y=Y,w=W,h=H,
\ Text_w=TEXT_W,Text_h=TEXT_H,TextCol=TEXTCOL,TextTol=TEXTTOL,
\ Halo_L=HALO_L,Halo_T=HALO_T,Halo_R=HALO_R,Halo_B=HALO_B,HaloCol=HALOCOL,HaloTol=HALOTOL,
\ backColor=BACKCOLOR,clipIx=ClipIx,Matrix=MATRIX,db=DB,Override=Override)


[Below, click twice]
https://i.postimg.cc/xkzd1GsX/Det-Sub-00.png (https://postimg.cc/xkzd1GsX)

EDIT: function Prototype in code block fixed.

VoodooFX
20th August 2021, 10:44
EDIT: significant re-write.
That is 7th version I've saved... :thanks:
This last one doesn't come with the user part.
So, "Detect3" is a final removal mask and "Detect4" is just to show what it covers? Could you add output for a final text mask without halo (that could be used for OCR purpose)?

Today I'll try to play with this sample too.

StainlessS
20th August 2021, 12:37
Not sure that I understand, outputs whole image set [ClipIx=0] or ClipIx= 1->14, 14 different masks, see either post #157 or #158 images, ClipIx in subclip title text,
eg for green bar [ClipIx=1]
1] Detect4 : DETECT FINAL, [FullWidSubC.BlankClip.Overlay(FullWidSubC.Mask=Detect3.RemoveGrain(2))]


DetSub(clip c,x="10",y="Height-120",w="-10",h="-8",
\ Text_w="3",Text_h="3",TextCol="$FCFCFC",TextTol=$030303",
\ Halo_L="3",Halo_T="3",Halo_R="3",Halo_B="3",HaloCol=HALOCOL,HaloTol=HALOTOL,
\ backColor="$00FF00",ClipIx="0",Matrix="rec601",db="",Override="")


This last one doesn't come with the user part.
What user part are we talkin' bout ?

EDIT:
Damn, I forgot that Green bar, non-green parts, text/halo is original pixels, I need to 'sorta' binarize before making green bar.

VoodooFX
20th August 2021, 13:49
I did few experiments with InpaintDelogo's DynMask=3, probably I can make it from 'not good' to 'usable' for this sample.

Not sure that I understand, outputs whole image set [ClipIx=0] or ClipIx= 1->14, 14 different masks, see either post #157 or #158 images...

First(FINAL) mask doesn't look like a mask...
Text2 looks like best to OCR, but it's not cleaned from all the dots, maybe another "UnDot" pass would help.

What user part are we talkin' bout?

About settings used. I found them at the top, before they were at the bottom.

StainlessS
20th August 2021, 15:57
About settings used. I found them at the top, before they were at the bottom.
OK, sorry.

First(FINAL) mask doesn't look like a mask...
Well the idea is to be able to extract from it both Text and Halo separately, with Green being the 'other guys'.

Posts #157 updated.


EDIT: So long as there is only ever 2 lines of subs, then would be better to reduce search area height to avoid encroaching noise above and below.

https://i.postimg.cc/RVQFXgzJ/Det-Sub-00-00.png (https://postimg.cc/pprRdYrP)
EDIT: Changed to [Images not updated]

# Subtitle coords
X = 58
Y = Height-118
W = -X
H = -16


EDIT: Images updated.

StainlessS
21st August 2021, 14:10
VX,
I have a rough idea how to select best Sub image from each detected Sub range.
Roughly, scan for each image in range, detecting image with least white text, excess white being crud round the edges, choose that image. (there can only be excess crud halo if excess crud text. <sort of>)
Well thats the idea, maybe work, maybe not.
I think we've polluted your important thread a bit with this, so I suggest you delete posts back to about #151, and I'll delete mine back to wherever you choose too.
The only other person posting back to #151, was kedautinh12 with a "thanks Stain" remark, perhaps he/she/they/them/it would be good enough to delete too.
I'll post new thread with current script and continue there if I have any success, will of course require multiple passes scripts.
[Which could possibly be automated into single script. <to export subs images for OCR, or InpaintDelogo>]
EDIT: Maybe also output frames file with Subs range and frameno of best subs in range.

EDIT:
(there can only be excess crud halo if excess crud text. <sort of>)
That aint quite right, but we'll try figure that out when we need to. [at least we know where we are tryin' to get to next]

EDIT: Logical AND of all white over the range [for text] and logical AND of all the black over range [for halo] - should maybe do it.

StainlessS
21st August 2021, 14:33
You can be 'it' if you want, your choice :)

Ever since I was a young child, I have known that I was different.
I'm not really a boy, [gosh! its so hard to say it out aloud], I'm really a helicopter.
There I said it, feel much better now, whizz whizz, whirr whirr.

EDIT: Was 'Cousin It' really an it ? with all that there hair is hard to tell. [Adams family was way ahead of 'its' time :) ]

VoodooFX
21st August 2021, 16:33
StainlessS,

I don't mind, it's related stuff and thread is quiet anyway, plus I don't like when stuff gets deleted, then I get nightmares that something important is gone. A separate thread for a separate script is the good idea, I'll find it. :)

PS:
Today I started injecting the yesterdays experiments to InpaintDelogo, almost done, but a friend crashed in with the firewater, so maybe tomorrow...

PS2:
If sub range can be detected then I would do on it something like:

function AvgAll2(clip c) { c.FrameCount() <= 1 ? c : Merge(AvgAll2(c.SelectEven()), AvgAll2(c.SelectOdd())) }
clp.AvgAll2().mt_binarize(threshold=254)

Roger, out.

StainlessS
21st August 2021, 19:21
Dang, had not realized but aint no clear frames between some subs, nuther spanner in the works.
Gone hunting spanners.

EDIT: Found some spanners.
DetSub - W.I.P:- https://forum.doom9.org/showthread.php?t=183148

StainlessS
22nd August 2021, 19:56
Function Prototype in post #157 fixed [totally messed it up :( ].




Function Prototype:
DetSub(clip c,Int "X"=-10,Int "Y"=Height-120,Int "W"=-10,Int "H"=-8,
\ Int "Text_w"=3,Int "Text_h"=3,Int "TextCol"=$FCFCFC,Int "TextTol"=$030303,
\ Int "Halo_L"=3,Int "Halo_T"=3,Int "Halo_R"=3,Int "Halo_B"=3,Int "HaloCol"=$030303,Int "HaloTol"=$030303,
\ int "BackColor"=$00FF00,Int "ClipIx"=0,string "Matrix"="rec601",String "DB"="",string "Override"="")


But suggest using updated scripts here [DetSub - W.I.P]:- https://forum.doom9.org/showthread.php?t=183148

VoodooFX
22nd August 2021, 22:33
New v1.31 tuned to deal much better with this last anime example:

# Version 1.31 : 2021/08/22. New: "KillBlobs", "preBlobs", "RePass". Updated: "DynInflate", "KillNoise".


Short comparison vs DSub_MI (slowed to 10fps, duration: 54 seconds):

https://i.imgur.com/iQlmSUf.gif

Better quality video instead of gif: https://imgur.com/yb4g2Hi
Full sample, Scripts, User script to run comparison:https://drive.google.com/file/d/1joXmOQtSnKMuYHWie5zbVeZn3jma3132/view?usp=sharing


InpaintDelogo ( RePass=1 ) - 148 FPS
InpaintDelogo ( RePass=2 ) - 112 FPS (insignificantly less artifacts)
DSub_MI (from this thread) - 174 FPS

InpaintDelogo sometimes has artifacts just before subtitle appears/changes because it does temporal shenanigans and this sample is a bad case for it.
Artifacts could be reduced further with some subs detection added, now it doesn't do any detection.

StainlessS
22nd August 2021, 22:53
Impressive :)

VoodooFX
23rd August 2021, 11:11
Noticed that deblob makes letter "M" disappear at ~1975 frame, for comparison use safer "preBlobs=-1" option, there will be a bit more artifacts.

PS:
Forgot to mention that "KillNoise" now needs RgTools.

EDIT:

I've observed a random bug running that comparison example (had one more InpaintDelogo's instance stacked), one or two clips from stacked output starts showing garbled mask, refreshing preview in AvsPmod fixes it.

StainlessS
24th August 2021, 12:19
Just thought I'de point out something I posted [and forgot about] some time ago. [Was IanB idea]

https://forum.doom9.org/showthread.php?p=1912309#post1912309

When using detector on Blended Group Detect clip, a simple Sharpen(1.0) whacks up the flimsey text to Y=255 [or maybe it was R,G,B all up to 255, probably both as used PC.601].
So, in most cases the text should be easily found unless something else somehow survives blending [ie static full white chunk of something].
EDIT: Usually set Lo threshold to about 222, so 255 text big help for detector. [Of course the blurred/blended parts of frame aint got much in the way of edges to sharpen, so almost free of potential probs]
EDIT: I wonder if Delogo type plugs do a Sharpen() when looking for opaque white logo on blended frame average, it would defo be beneficial.


But, will have to point out that any colors/tolerance has also to be provided with source sharpened, kinda awkward. [EDIT: also darken black-ish halo]

EDIT: "Blended Group Detect clip" = ClipBlend.
Maybe less useful if text thickness much greater than 2, only flimsy text.

EDIT:
[Was IanB idea]
Actually, seems like might have been my idea, [dont wanna blame IanB for anything I did], IanB idea was for something else,
and I just forgot and confused the two things.

VoodooFX
24th August 2021, 13:57
Just thought I'de point out something I posted [and forgot about] some time ago. [Was IanB idea]...

I remember it, that is the thread where I got idea for the dynamic mask method 3 aka "DynMask=3", I remember experimenting with Sharpen but I probably didn't find it useful (or universally applicable).
But I forgot that there already you posted some scripts to detect logo, probably because I didn't try them...

VoodooFX
25th August 2021, 17:43
# Version 1.32 : 2021/08/25. Fixed illogical Y8/YV12 conversions in the dynamic mask routines. ~20% faster.
# External dynamic mask expected to be Y8.
I've no idea why it was like that, hopefully I didn't break anything.

Benchmarks re-run with v1.32:

InpaintDelogo ( RePass=1 ) - 177 FPS
InpaintDelogo ( RePass=2 ) - 144 FPS (insignificantly less artifacts)
DSub_MI (from this thread) - 176 FPS

kedautinh12
25th August 2021, 17:56
Thanks, hope InpainDelogo will easy to use in the future :D

VoodooFX
25th August 2021, 18:00
Thanks, hope InpainDelogo will easy to use in the future :D

As you can see with time more parameters gets added, so it can only go to "harder to use" direction. ;)

StainlessS
26th August 2021, 06:16
The more parameters, the more fun :eek:


Btw, I'm interested in detection method you done in "DetectSub_MI", would it be possible to detect subs in a mask and extract them to images? One image per sub with time range in the filename, for example like "0_00_56_958__0_00_57_957.tiff".

something like this?


avisource("c:\clip.avi")
global f=framerate(last)
logfile="c:\smpte.txt"
writefile(logfile,"showsmpte(current_frame,f)")

function showsmpte(int cf,float fr) #cf=current_frame,fr=framerate
{
hh=int(cf/3600/fr)
mm=int((cf-hh*3600*fr)/60/fr)
ss=int((cf-hh*3600*fr-mm*60*fr)/fr)
ff=int((cf-hh*3600*fr-mm*60*fr-ss*fr))
smpte=string(hh,"%02.0f")+":"+string(mm,"%02.0f")+":"+string(ss,"%02.0f")+":"+string(ff,"%0"+string(int(log(fr)/log(10)))+".0f")
smpte
}


EDIT:
Above number of digits in last [frames] section of returned string dont quite work right, below fixes it and mod.

Function Frame2SMPTE(int Frameno,float Fps,int "digits",bool "File") { # ssS Mod of fn by tsp:- https://forum.doom9.org/showthread.php?p=551000#post551000
ch = Default(File,false) ?"_":":"
digits = Default(digits, int(log(max(Fps,1))/log(10))+1) # Log10 v2.60+, [Log10(n) = Log(n) / Log(10)]
hh=int(Frameno/3600/Fps) mm=int((Frameno-hh*3600*Fps)/60/Fps)
ss=int((Frameno-hh*3600*Fps-mm*60*Fps)/Fps) ff=int((Frameno-hh*3600*Fps-mm*60*Fps-ss*Fps))
#return RT_String("%02d%s%02d%s%02d%s%0*d",hh,ch,mm,ch,ss,ch,digits,ff)
return String(hh,"%02.0f")+ch+string(mm,"%02.0f")+ch+string(ss,"%02.0f")+ch+string(ff,"%0"+string(digits)+".0f")
}



blankclip(Length=100000,fps=50)
ShowSMPTE
SSS="""
subtitle(Frame2SMPTE(current_frame,FrameRate,digits=3,File=true)) # Use File format '_' instead of ":", and Force 3 digits in last frames section
"""
Scriptclip(SSS)


EDIT: Handy function

Function nDigits(Int n) { return Int(Log10(Max(n,1)))+1 } # ssS, Log10 v2.60+ [ Log10(n) = Log(n)/Log(10) ]



Function nDigits(Int n) { return int(Log(Max(n,1))/Log(10))+1 } # ssS, v2.58 Ver$

StainlessS
26th August 2021, 19:00
VX,
Any idea how to get rid of them there really helpful frame numbering whotsits output by ImageWriter ?

eg
"0_00_56_958__0_00_57_957.tiff".

instead of
"0_00_56_958__0_00_57_957000123.tiff".

[when frame number is non 0]

Been annoying me since forever.

EDIT: Tryin' to implement your required SMPTE thingy, only problem is above nasty stuff.

EDIT: OK, I managed to do it when frame was 0, so I can frig it up with trim to get it to work ok. [I think]

EDIT: Yeah I can do it, sorry for bothering you.

VoodooFX
26th August 2021, 22:39
I managed to do it only with trim. Like this:
Trim(0,-1).ConvertToRGB().ImageWriter("d:\saved_img" + "%.0d.bmp",0,-1,"bmp")

StainlessS
26th August 2021, 22:55
Thanks, more or less the same here.

T is single frame.

if(SMPTE) {
FNam=Frame2SMPTE(S,fps,3,true) +"__" + Frame2SMPTE(E,fps,3,true)
T.ImageWriter(ImageDir+"\"+FNam+"%.0d.%s",0,-1,ImgType).RT_YankChain(n=0) # Force Write image
} else {
T.Loop.ImageWriter(ImageDir+"\SUBS_%06d"+"."+Imgtype, i, i,ImgType).RT_YankChain(n=i) # Force Write image
}

Got SMPTE working see other thread.

EDIT: Has to be single frame clip and have the "%.0d" thing to work without "000000" bit.

VoodooFX
31st August 2021, 22:20
v1.33 tuned to reduce artifacts in the mask for this anime sample (once again).
New settings to create a mask from halo and it's used to cleanup a mask for text.

# Version 1.33 : 2021/08/31. New: "DynMask3H", "ModeSH", "TuneH1", TuneH2", "TuneH3", "KillNoiseH, "rePassH".
# Updated: "Show", "DynTune".

Benchmark (sample is in some post above):
InpaintDelogo - 152 FPS
DSub_MI 0.0.7 - 148 FPS


InpaintDelogo(Loc="0,0,-0,-0",
\ oPP=0,
\ DynMask=3, DynTune=220,
\ Dyn3Seq=12, ClpBlend=10, DynPostTune=1, Dyn3buffer=0,
\ KillBlobs=-4, preBlobs=-1, KillNoise=5,
\ DynMask3H=50, TuneH1=4, TuneH2=2, TuneH3=1,
\ Show=4)


There is hardly any artifact left, maybe it's not possible to cleanup it further, unless there is a function like magic wand and it would fill contiguous space like that:

From:
https://i.imgur.com/ZuUpEny.png
To:
https://i.imgur.com/a7eUtoT.png

VoodooFX
22nd September 2021, 00:42
# Version 1.34 : 2021/09/21. New: "Extract" parameter to extract subtitles to images for OCR.
# New: 'SubsMask2Img()' func (mod of StainlessS's 'DetSub_Extract()').
# Note: This version needs AviSynth+.


Sample from there: https://drive.google.com/file/d/1joXmOQtSnKMuYHWie5zbVeZn3jma3132

Extraction in one go:
InpaintDelogo(Loc="0,0,-0,-0",
\ oPP=0,
\ DynMask=3, DynTune=220,
\ Dyn3Seq=12, ClpBlend=10, DynPostTune=1, Dyn3buffer=0,
\ KillBlobs=-4, preBlobs=-1, KillNoise=5,
\ DynMask3H=50, TuneH1=4, TuneH2=2, TuneH3=1,
\ Extract=1, ImgDir="D:\Images",
\ Show=4)
https://i.imgur.com/dZeumm7.png


Extraction with intermediate file:

Encoding the mask to lossless x264 ("--preset ultrafast --range pc --cabac -q0") took 28 seconds (set Extract=0 in above example).
Then:
SubsMask2Img(ImgDir="D:\Images")
https://i.imgur.com/wvSmA3S.png

Shinkiro
29th September 2021, 10:18
VoodooFX and StainlessS Thanks! This is a very useful expansion of the script capabilities.
I have a powershel script for converting received images into srt subtitles, using text recognition software Tesseract

Softsabber_Tesseract.ps1
function fmt($name){ $name -replace '_',':' -replace ':(?=\d\d\d)',',' -replace '::',' --> ' }
dir *.png |% {$c=1} {tesseract $_ output -l rus; $c; fmt $_.basename; (gc output.txt); ++$c } >Soft_Sub.srt
someone might need

VoodooFX
29th September 2021, 21:27
VoodooFX Thanks! This is a very useful expansion of the script capabilities.
I have a powershel script for converting received images into srt subtitles, using text recognition software Tesseract

Thx for the script. Don't forget StainlessS, he done heavy lifting to make it happen.
I got few ideas for getting a cleaner mask, need to test them out in practice, maybe I'll implement them in new DynMask=4 method [if it's better or faster].

I found Subtitle Edit's nOCR feature better and faster than Tesseract.

Shinkiro
29th September 2021, 21:50
Thx for the script. Don't forget StainlessS, he done heavy lifting to make it happen.
Corrected that unfortunate inaccuracy.:)
I found Subtitle Edit's nOCR feature better and faster than Tesseract.
Can it recognize italics and render it into text? because Tesseract has a problem with that.

VoodooFX
29th September 2021, 22:25
Can it recognize italics and render it into text? because Tesseract has a problem with that.

Yes, it's like a binary image compare, but different. Tesseract produces many errors and correct them takes lots of time, when after nOCR I got result with no errors.

VoodooFX
5th October 2021, 04:01
# Version 1.36 : 2021/10/04. Added auto generation of the dynamic mask for subtitles with halo (aka "DynMask=4").
# Updated: "KillNoise", and some other tweaks.

Faster, better, simpler - "DynMask=4" method:
InpaintDelogo(Loc="0,0,-0,-0",
\ oPP=0,
\ DynMask=4, DynTune=220, DynMask4H=60, KillNoise=-5,
\ Show=4)

~30% faster than "DynMask=3" + "DynMask3H" method. Artifact at ~3073 frame is gone, one dot is still present at ~3159, so I won't be happy till it's there. :D


...converting received images into srt subtitles, using text recognition software Tesseract...

Could you share to pastebin the output from your Tesseract (OCR subs from that anime sample)?

Shinkiro
5th October 2021, 10:39
Could you share to pastebin the output from your Tesseract (OCR subs from that anime sample)?

https://pastebin.com/kWzxLUMm (model fast)
https://pastebin.com/r9ia78qy (model best) this model gave off some garbage in some places.
Tesseract adds some sort of sign at the end of each line, I manually remove it.
He's having some trouble identifying the letter I

VoodooFX
7th October 2021, 23:52
(model best) this model gave off some garbage in some places.
He's having some trouble identifying the letter I

Are these done with Tesseract 4/5 neural nets LSTM? Did you tried inverted images (SE inverts them automatically when Tesseract 5 is selected)?

Tesseract in Subtitle Edit can detect italics.
Here are my tests (I deleted all SE's dictionaries to prevent auto-correction and to see pure Tesseract):

Tesseract 3:
https://pastebin.com/7BX287Fp
InpaintDelogo(Loc="0,0,-0,-0", oPP=0, DynMask=4, DynTune=220, DynMask4H=60, KillNoise=-5, Show=4, Extract=1, ImgDir="D:\Images")

Tesseract 5 (original, no LSTM):
https://pastebin.com/BLc5b09t
InpaintDelogo(Loc="0,0,-0,-0", oPP=0, DynMask=4, DynTune=220, DynMask4H=60, KillNoise=-5, Show=4, DynMaskUp=2, Extract=1, ImgDir="D:\Images")

I think T5 likes bigger images, I used "DynMaskUp"(new parameter in v1.37) instead of "ImgSize", dunno if it helps, I think that for nOCR it should.

VoodooFX
28th October 2021, 21:10
# Version 1.40 : 2021/10/28. Some speed optimizations. AvsInpaint v1.3 is required.
# Version 1.39 : 2021/10/23. Various improvements.
# Version 1.38 : 2021/10/22. Fixed: Bug with "SubSuspect" parameter.
# Version 1.37 : 2021/10/07. New: "DynMaskUp" parameter.

VoodooFX
8th November 2021, 03:25
# Version 1.45 : 2021/11/07. Fixed: Automask wasn't working if coords were "0,0,0,0".
# Version 1.44 : 2021/11/05. Refactored multipass deblending code.
# Version 1.43 : 2021/11/03. Fixed: One pass Deblend didn't see A/C masks from multi pass. Changed: "Deep".
# Version 1.42 : 2021/11/03. Fixed: A/C masks file name if coord is "-0".
# Version 1.41 : 2021/11/03. Fixed: "Show=1" was broken with "Deblend" since v1.18.

VoodooFX
10th November 2021, 22:41
@StainlessS
Maybe you could spot something why func below doesn't run on Avs 2.6 (it runs OK on Avs+)?
Posting here to not litter your thread. Relevant link: https://forum.doom9.org/showthread.php?p=1956968#post1956968

Error at clp2x2: "Crop: Top and Left must be more than 0".



function Analyze5FX(clip clp, val "mask", int "Mode", int "Analyze5Th", string "Ignore", int "Show") {
mask = default (mask , "")
Mode = default (Mode , 1 )
Analyze5Th = default (Analyze5Th , 15)
Ignore = default (Ignore , "none")
Show = default (Show , 0)

Assert (!(Mode < 1 || Mode > 2), """"Mode" value must be between 1 and 2.""")
Assert (!(Analyze5Th < 1 || Analyze5Th > 255), """"Analyze5Th" value must be between 1 and 255.""")
Assert (!(Show < 0 || Show > 2), """"Show" value must be between 0 and 2.""")
Assert ((Ignore == "top" || Ignore == "bottom" || Ignore == "left" || Ignore == "right" || Ignore == "none"), """"Ignore" string must be 'top', 'bottom', 'left', 'right' or 'none'.""")

VW = clp.Width
VH = clp.Height
Th = Analyze5Th
mask = (IsClip(mask)) ? mask.ConvertToY8(matrix="PC.709").MTballoon2PX(2) : nop
clpS = clp.ScriptClip("subtitle(string(current_frame))")

# Construct a clip to check thresholds (for deblending analysis) #
#================================================================#

if(Mode == 1) {
# Get coords of the logo mask
VFX2="""
Status = (mask.RT_YInRangeLocate(Baffle=1,lo=255,hi=255)) ? 1 : 2
if(Status==1) {
RT_DBaseSet(Analyze5DB,0,Status,YIRL_X,YIRL_Y,YIRL_W,YIRL_H)
} else {
RT_DBaseSetField(Analyze5DB,0,0,Status)
}
return Last
"""
Analyze5DB = ("~InpaintDelogo_Analyze5_"+RT_LocalTimeString+".DB").RT_GetFullPathName
RT_DBaseAlloc(Analyze5DB,1,"iiiii")

Parse = mask.GScriptClip(VFX2, local=true, args="mask,Analyze5DB", after_frame=true)
Parse.RT_ForceProcess

Assert (!(RT_DBaseGetField(Analyze5DB,0,0) == 2), "Mask image is invalid.")
mX = RT_DBaseGetField(Analyze5DB,0,1)
mY = RT_DBaseGetField(Analyze5DB,0,2)
mW = RT_DBaseGetField(Analyze5DB,0,3)
mH = RT_DBaseGetField(Analyze5DB,0,4)
RT_FileDelete(Analyze5DB)

# Convert X,Y,W,H coords to L,T,-R,-B coords
mL = mX
mT = mY
mR = -VW + mW + mX
mB = -VH + mY + mH
Assert (!(mL < 8 && -1*mR < 8 || mT < 8 && -1*mB < 8), "Mask image or Loc is invalid.")

# Coords mod2 round up
mL = mL + (mL % 2)
mT = mT + (mT % 2)
mR = mR - (mR % 2)
mB = mB - (mB % 2)

# Crop 2x2 pxs area from above or below the logo and make a background from it
mid = (VW-mL+mR)/2+mL
mid = mid + (mid % 2)
clp2x2 = (mT >= -1*mB) ? clp.crop(mid-2, mT-2, -1*(VW-mid), -VH+mT+2) : clp.crop(mid-2, VH+mB-2, -1*(VW-mid), mB+2)
clpB = clp2x2.PointResize(VW, VH)

Msk1 = mask.MTballoon2PX(2).mt_logic(mask, mode="xor") # 2px wide mask around logo (+2px offset from the base mask)
clp5 = clpB.Overlay(clp, mask=Msk1)

} else {

# Construct a clip to check thresholds (for Automask=1) #
#=======================================================#

cT = clp.crop(4, 4, -4, -1*(VH-6))
cB = clp.crop(4, VH-6, -4, -4)
cL = clp.crop(4, 4, -1*(VW-6), -4)
cR = clp.crop(VW-6, 4, -4, -4)

if(Ignore == "top") {
cT = cB
} else if (Ignore == "bottom") {
cB = cT
} else if (Ignore == "left") {
cL = cR
} else if (Ignore == "right") {
cR = cL
}

wc = StackHorizontal(cr,cl).TurnLeft
hc = StackVertical(ct,cb)

if(wc.width > hc.width) {
hc = hc.PointResize(wc.width, hc.height)
out = StackVertical(wc,hc)
} else if(wc.width < hc.width) {
wc = wc.PointResize(hc.width, wc.height)
out = StackVertical(wc,hc)
} else {
out = StackVertical(wc,hc)
}
clp5 = (Show == 2) ? out.PointResize(VW, VH) : out
}

# Delete frames above thresholds (that leaves us with the suitable frames for analysis) #
#=======================================================================================#

# Mod of Gavino's DeleteFrames() - https://forum.doom9.org/showthread.php?t=163107
clp5
fc = FrameCount()
res = BlankClip(clp, length=0)
condition = "YPlaneMinMaxDifference >" +String(Th)+ " || UPlaneMinMaxDifference >" +String(Round(Th/2))+ " || VPlaneMinMaxDifference >" +String(Round(Th/2))
current_frame = 0

while (current_frame < fc) {
while (Eval(condition) && current_frame < fc) {
current_frame = current_frame+1
}
if (current_frame < fc) { # not at end
start = current_frame # start of wanted section
while (!Eval(condition) && current_frame < fc) {
current_frame = current_frame+1
}
clpX = (Show == 1) ? clpS : (Show == 2) ? clp5 : clp # 0: Original frames, 1: Original frames + frameNo, 2: Constructed clips (Mode=2 clip is upsized for show)
res = res + clpX.Trim(start, start-current_frame)
}
}
Assert (!(res.FrameCount < 2), """No frames found to analyze, increase "Analyze5Th".""")
return res
}



EDIT:
Clip: https://drive.google.com/file/d/1PdtRWcTztQgxPQalk_FgOJYSCiQKPuRW/view?usp=sharing
Mask: https://i.imgur.com/WieMHwJ.png
Test script:

GImport("c:\Analyze5FX.avs")
x = LSMASHVideoSource("D:\899.mp4")
x = x.crop(1124,24,-52,-636).Trim(30,100) # trimed for speed
mask = ImageSource("D:\mask.bmp",0,0)

# Mode 1 test
m0 = x.Analyze5FX(mask=mask, mode=1, show=0)
m1 = x.Analyze5FX(mask=mask, mode=1, show=1)
m2 = x.Analyze5FX(mask=mask, mode=1, show=2)
mu = Stackhorizontal(m0.AddBorders(0,0,2,0,$000000), m0)
md = Stackhorizontal(m1.AddBorders(0,0,2,0,$000000), m2)
Stackvertical(mu.AddBorders(0,0,0,2,$000000), md)

StainlessS
10th November 2021, 23:41
Thanks for the source files.

Confirm, you are trying to get data for only current_frame, yes, [in Analyze5FX] ?

If so, then dont really want to use RT_ForceProcess, which scans entire clip.
Can use RT_YankChain [force single frame process].


RT_YankChain(clip,int "n"=current_frame,int "delta"=0)
Compile/runtime clip function.
n (default = current_frame) frame number.
delta (default = 0), frame number offset.
Forcibly process the filter graph chain for frame n + delta. Makes intention more explicit than eg RT_AverageLuma(n=i,w=1,h=1).
See also RT_GraphLink().
eg, Below, TmpA plays no part in output clip and so bitmap would not be written. Uncomment the RT_YankChain line and it will.
a=Colorbars.ShowFrameNumber
TmpA = a.subtitle("TestA").ImageWriter("TestA_", type="BMP")
#RT_YankChain(TmpA,n=42) # Uncomment to forcibly write frame 42 of TmpA to bitmap
return MessageClip("All Done")

VoodooFX
10th November 2021, 23:55
Confirm, you are trying to get data for only current_frame, yes, [in Analyze5FX] ?

If so, then dont really want to use RT_ForceProcess, which scans entire clip.
Can use RT_YankChain [force single frame process].


In if(Mode == 1) block only process that one frame (image mask), I'll change that to RT_YankChain.
I think GScriptClip there is not needed, nothing is used there from the return, is it possible to get RT_YInRangeLocate coords vars directly into function without RT_DBase thingy there?

EDIT:
Just realized Analyze5FX is using some stuff from InpaintDelogo.avsi, so you need to load that too.
Or just replace [I]MTballoon2PX(2) with mt_expand().mt_expand()

StainlessS
11th November 2021, 00:08
is it possible
Instead of

if(Mode == 1) {
# Get coords of the logo mask
VFX2="""
Status = (mask.RT_YInRangeLocate(Baffle=1,lo=255,hi=255)) ? 1 : 2
if(Status==1) {
RT_DBaseSet(Analyze5DB,0,Status,YIRL_X,YIRL_Y,YIRL_W,YIRL_H)
} else {
RT_DBaseSetField(Analyze5DB,0,0,Status)
}
return Last
"""
Analyze5DB = ("~InpaintDelogo_Analyze5_"+RT_LocalTimeString+".DB").RT_GetFullPathName
RT_DBaseAlloc(Analyze5DB,1,"iiiii")

Parse = mask.GScriptClip(VFX2, local=true, args="mask,Analyze5DB", after_frame=true)
Parse.RT_ForceProcess

Assert (!(RT_DBaseGetField(Analyze5DB,0,0) == 2), "Mask image is invalid.")
mX = RT_DBaseGetField(Analyze5DB,0,1)
mY = RT_DBaseGetField(Analyze5DB,0,2)
mW = RT_DBaseGetField(Analyze5DB,0,3)
mH = RT_DBaseGetField(Analyze5DB,0,4)
RT_FileDelete(Analyze5DB)

This should be about right

if(Mode == 1) {
# Get coords of the logo mask
if(!(mask.RT_YInRangeLocate(Baffle=1,lo=255,hi=255))) {
Assert (FALSE, "Mask image is invalid.")
}
mX = YIRL_X
mY = YIRL_Y
mW = YIRL_W
mH = YIRL_H


Oops, messed up, fixed.
EDIT: A bit more tinker. [Baffle might be a bit low]

EDIT: Or,

if(Mode == 1) {
# Get coords of the logo mask
Assert (mask.RT_YInRangeLocate(Baffle=1,lo=255,hi=255), "Mask image is invalid.")
mX = YIRL_X
mY = YIRL_Y
mW = YIRL_W
mH = YIRL_H


EDIT: Baffle, about thickness of text + halo. [maybe slightly less]

VoodooFX
11th November 2021, 00:28
This should be about right

But RT_YInRangeLocate must be in runtime script.

StainlessS
11th November 2021, 00:34
Yeah, I'm tryin' to figure out what you are trying to do, give me a bit of time.

VoodooFX
11th November 2021, 00:42
Yeah, I'm tryin' to figure out what you are trying to do, give me a bit of time.

No rush here, I wrote it a month ago, still need to rewrite some InpaintDelogo's conditional madness to fit this func in.
It selects frames to do similar autoanalysis like AviUtl tool, just a bit better as we supply a base mask and scan area very close around logo (mode=1), mode=2 should be almost same as in AviUtl tool (except that it can deal with logos on the border with Ignore parameter. [actually I dunno exactly what AviUtl does, but it should be something similar]

StainlessS
11th November 2021, 01:20
OK, some backward steps here,

You seem to be wantin to handle some stuff in runtime and some other in frameserve periods, maybe you can figure out what you want from this

if(Mode == 1) {
VFX2="""
if(mask.RT_YInRangeLocate(Baffle=1,lo=255,hi=255)) {
# Convert X,Y,W,H coords to L,T,-R,-B coords
mL = YIRL_X
mT = YIRL_Y
mR = -VW + mL + YIRL_W
mB = -VH + mT + YIRL_H

RT_DBaseSet(Analyze5DB,current_frame,1, mL,mT,mR,mB) # Write VoodooFX style coords to DB

} else {
RT_DBaseSetField(Analyze5DB,current_frame,0,2)
Assert (FALSE, "Mask image is invalid.") # Not really a good place for Assert()
}
return Last
"""
Analyze5DB = ("~InpaintDelogo_Analyze5_"+RT_LocalTimeString+".DB").RT_GetFullPathName
RT_DBaseAlloc(Analyze5DB,Mask.FrameCount,"iiiii") # Alloc DBase records, number of frames in mask clip
mask.GScriptClip(VFX2, local=true, args="mask,Analyze5DB", after_frame=true)
Parse.RT_ForceProcess # FORCE PROCESS ENTIRE CLIP

# mL, mT etc not available here in frameserver (non-runtime) section. (so below will not work]

Assert (!(mL < 8 && -1*mR < 8 || mT < 8 && -1*mB < 8), "Mask image or Loc is invalid.") # Not really a good place for Assert()

# Coords mod2 round up # Maybe move into GSCriptClip, before write to DBase, later available in DBase.
mL = mL + (mL % 2)
mT = mT + (mT % 2)
mR = mR - (mR % 2)
mB = mB - (mB % 2)

# Crop 2x2 pxs area from above or below the logo and make a background from it
mid = (VW-mL+mR)/2+mL
mid = mid + (mid % 2)
clp2x2 = (mT >= -1*mB) ? clp.crop(mid-2, mT-2, -1*(VW-mid), -VH+mT+2) : clp.crop(mid-2, VH+mB-2, -1*(VW-mid), mB+2)

clpB = clp2x2.PointResize(VW, VH)



Msk1 = mask.MTballoon2PX(2).mt_logic(mask, mode="xor") # 2px wide mask around logo (+2px offset from the base mask)
clp5 = clpB.Overlay(clp, mask=Msk1)

} else {

The GScriptclip stuff force processes entire length of mask clip,
stuff after that seems to wanna access coords (which are only accessable in runtime script), maybe you can slot some of it into the Gscriptscript part.

Any good at all ?

EDIT: Maybe instead of Assert, write eg -1 as status to DBase, to detect error later, or something ???
EDIT: clp2x2 = (mT >= -1*mB) ? clp.crop(mid-2, mT-2, -1*(VW-mid), -VH+mT+2) : clp.crop(mid-2, VH+mB-2, -1*(VW-mid), mB+2)

Are above two parts same size, and same size as clp ? [EDIT: no not same size as clp, Scriptclip output MUST be same size as input]
If so, then I can maybe slot into GSCriptClip. [if not, then no idea].

Probably gone to bed soon. ZZZZzzzzzzz.....

VoodooFX
11th November 2021, 01:47
I don't see reason why we need to move all this stuff to GScriptClip, I think I would even get rid of GScriptClip...

Is it related to "Crop: Top and Left must be more than 0" error (on Avs 2.6!, func runs OK on Avs+)?

StainlessS
11th November 2021, 02:00
If you need coords, then you need runtime.

Maybe something like this [it dont work, but maybe roughly what is required]

if(Mode == 1) {
VFX2="""
if(!mask.RT_YInRangeLocate(Baffle=1,lo=255,hi=255)) {
RT_DBaseSetField(Analyze5DB,current_frame,0,2)
Assert (FALSE, "Mask image is invalid.") # Not really a good place for Assert()
}
VW = Last.Width
VH = Last.Height
# Convert X,Y,W,H coords to L,T,-R,-B coords
mL = YIRL_X
mT = YIRL_Y
mR = -VW + mL + YIRL_W
mB = -VH + mT + YIRL_H
Assert (!(mL < 8 && -1*mR < 8 || mT < 8 && -1*mB < 8), "Mask image or Loc is invalid.") # Not really a good place for Assert()
# Coords mod2 round up
mL = mL + (mL % 2)
mT = mT + (mT % 2)
mR = mR - (mR % 2)
mB = mB - (mB % 2)
RT_DBaseSet(Analyze5DB,current_frame,1, mL,mT,mR,mB) # Write VoodooFX style coords to DB
# Crop 2x2 pxs area from above or below the logo and make a background from it
mid = (VW-mL+mR)/2+mL
mid = mid + (mid % 2)
clp2x2 = (mT >= -1*mB) ? Last.crop(mid-2, mT-2, -1*(VW-mid), -VH+mT+2) : Last.crop(mid-2, VH+mB-2, -1*(VW-mid), mB+2)
Return clp2x2.PointResize(VW, VH) # Same size as input clip
"""
Analyze5DB = ("~InpaintDelogo_Analyze5_"+RT_LocalTimeString+".DB").RT_GetFullPathName
RT_DBaseAlloc(Analyze5DB,Mask.FrameCount,"iiiii") # Alloc DBase records, number of frames in mask clip
clpB = clp.GScriptClip(VFX2, local=true, args="mask,Analyze5DB", after_frame=true)
clpB.RT_ForceProcess # FORCE PROCESS ENTIRE CLIP

Msk1 = mask.MTballoon2PX(2).mt_logic(mask, mode="xor") # 2px wide mask around logo (+2px offset from the base mask)
clp5 = clpB.Overlay(clp, mask=Msk1)

# RT_FileDelete(Analyze5DB)

} else {

ZZZZZZzzzzz......

EDIT:
Or if you dont need coords again later, then ony 1 frame at a time, no force process, no DB.

if(Mode == 1) {
VFX2="""
if(!mask.RT_YInRangeLocate(Baffle=1,lo=255,hi=255)) {
Assert (FALSE, "Mask image is invalid.") # Not really a good place for Assert()
}
VW = Last.Width
VH = Last.Height
# Convert X,Y,W,H coords to L,T,-R,-B coords
mL = YIRL_X
mT = YIRL_Y
mR = -VW + mL + YIRL_W
mB = -VH + mT + YIRL_H
Assert (!(mL < 8 && -1*mR < 8 || mT < 8 && -1*mB < 8), "Mask image or Loc is invalid.") # Not really a good place for Assert()
# Coords mod2 round up
mL = mL + (mL % 2)
mT = mT + (mT % 2)
mR = mR - (mR % 2)
mB = mB - (mB % 2)
# Crop 2x2 pxs area from above or below the logo and make a background from it
mid = (VW-mL+mR)/2+mL
mid = mid + (mid % 2)
clp2x2 = (mT >= -1*mB) ? Last.crop(mid-2, mT-2, -1*(VW-mid), -VH+mT+2) : Last.crop(mid-2, VH+mB-2, -1*(VW-mid), mB+2)
Return clp2x2.PointResize(VW, VH) # Same size as input clip
"""
clpB = clp.GScriptClip(VFX2, local=true, args="mask,Analyze5DB", after_frame=true)

Msk1 = mask.MTballoon2PX(2).mt_logic(mask, mode="xor") # 2px wide mask around logo (+2px offset from the base mask)
clp5 = clpB.Overlay(clp, mask=Msk1)

} else {


OOps, changed clp to Last inside GSCriptClip's. [using clp as input to GScriptClip]

EDIT: I get "No frames found to analyze, increase "Analyze5Th"." [with the top code block]

VoodooFX
11th November 2021, 02:20
EDIT: I get "No frames found to analyze, increase "Analyze5Th"." [with the top code block]
Yes, same error, no frames on output for some reason.
Btw, I had to remove Analyze5DB from GScriptClip(VFX2, local=true, args="mask,Analyze5DB", after_frame=true).

EDIT:
Your edit run OK on Avs+, but it run OK there before too.
Maybe Gavino's thingy needs to be in it's own GSCriptClip too for Avs 2.6?
Or easier just to say goodbye to 2.6, I don't use it anyway. :devil:

StainlessS
11th November 2021, 02:23
Btw, I had to remove Analyze5DB
Yes of course, forgot that and did not try that block.
So, you dont need coords later then.
EDIT: And does the mod seem OK-ish, for what you want.

EDIT: Tomorrow is another day ... toodle pip.

VoodooFX
11th November 2021, 02:32
EDIT: And does the mod seem OK-ish, for what you want.

Those asserts won't work from there I think, so only that. For me it's not a problem, but newbies do weird stuff and that would be uncatched.

From Mode=1/2 blocks I need only clip as clp5.

StainlessS
11th November 2021, 02:45
OK, tried with v2.60 std, OK.

IsPlus = FindStr(VersionString.lcase,"avisynth+")!=0
(IsPlus) ? Import(".\Analyze5FX.avs") : GImport(".\Analyze5FX.avs")

x = LSMASHVideoSource(".\899.mp4")
x = x.crop(1124,24,-52,-636).Trim(30,100) # trimed for speed
mask = ImageSource(".\WieMHwJ.png",0,0)

# Mode 1 test

m0 = x.Analyze5FX(mask=mask, mode=1, show=0)
m1 = x.Analyze5FX(mask=mask, mode=1, show=1)
m2 = x.Analyze5FX(mask=mask, mode=1, show=2)
mu = Stackhorizontal(m0.AddBorders(0,0,2,0,$000000), m0)
md = Stackhorizontal(m1.AddBorders(0,0,2,0,$000000), m2)
Stackvertical(mu.AddBorders(0,0,0,2,$000000), md)


with Grunt[GScriptClip], GScript[If/While etc], RT_stats[other stuff] in 2.60 std plugins. [and LSMash]

Really going to bed now. [I hope].
[Same "no frame found to analyse", but no crash]

EDIT: And the entire script as I have it [with the DBase].

function Analyze5FX(clip clp, val "mask", int "Mode", int "Analyze5Th", string "Ignore", int "Show") {
mask = default (mask , "")
Mode = default (Mode , 1 )
Analyze5Th = default (Analyze5Th , 15)
Ignore = default (Ignore , "none")
Show = default (Show , 0)

Assert (!(Mode < 1 || Mode > 2), """"Mode" value must be between 1 and 2.""")
Assert (!(Analyze5Th < 1 || Analyze5Th > 255), """"Analyze5Th" value must be between 1 and 255.""")
Assert (!(Show < 0 || Show > 2), """"Show" value must be between 0 and 2.""")
Assert ((Ignore == "top" || Ignore == "bottom" || Ignore == "left" || Ignore == "right" || Ignore == "none"), """"Ignore" string must be 'top', 'bottom', 'left', 'right' or 'none'.""")

VW = clp.Width
VH = clp.Height
Th = Analyze5Th
mask = (IsClip(mask)) ? mask.ConvertToY8(matrix="PC.709").MTballoon2PX(2) : nop
clpS = clp.ScriptClip("subtitle(string(current_frame))")

# Construct a clip to check thresholds (for deblending analysis) #
#================================================================#

if(Mode == 1) {
VFX2="""
if(!mask.RT_YInRangeLocate(Baffle=1,lo=255,hi=255)) {
RT_DBaseSetField(Analyze5DB,current_frame,0,2)
Assert (FALSE, "Mask image is invalid.") # Not really a good place for Assert()
}
VW = Last.Width
VH = Last.Height
# Convert X,Y,W,H coords to L,T,-R,-B coords
mL = YIRL_X
mT = YIRL_Y
mR = -VW + mL + YIRL_W
mB = -VH + mT + YIRL_H
Assert (!(mL < 8 && -1*mR < 8 || mT < 8 && -1*mB < 8), "Mask image or Loc is invalid.") # Not really a good place for Assert()
# Coords mod2 round up
mL = mL + (mL % 2)
mT = mT + (mT % 2)
mR = mR - (mR % 2)
mB = mB - (mB % 2)
RT_DBaseSet(Analyze5DB,current_frame,1, mL,mT,mR,mB) # Write VoodooFX style coords to DB
# Crop 2x2 pxs area from above or below the logo and make a background from it
mid = (VW-mL+mR)/2+mL
mid = mid + (mid % 2)
clp2x2 = (mT >= -1*mB) ? Last.crop(mid-2, mT-2, -1*(VW-mid), -VH+mT+2) : Last.crop(mid-2, VH+mB-2, -1*(VW-mid), mB+2)
Return clp2x2.PointResize(VW, VH) # Same size as input clip
"""
Analyze5DB = ("~InpaintDelogo_Analyze5_"+RT_LocalTimeString+".DB").RT_GetFullPathName
RT_DBaseAlloc(Analyze5DB,Mask.FrameCount,"iiiii") # Alloc DBase records, number of frames in mask clip
clpB = clp.GScriptClip(VFX2, local=true, args="mask,Analyze5DB", after_frame=true)
clpB.RT_ForceProcess # FORCE PROCESS ENTIRE CLIP

Msk1 = mask.MTballoon2PX(2).mt_logic(mask, mode="xor") # 2px wide mask around logo (+2px offset from the base mask)
clp5 = clpB.Overlay(clp, mask=Msk1)

# RT_FileDelete(Analyze5DB)

} else {

# Construct a clip to check thresholds (for Automask=1) #
#=======================================================#

cT = clp.crop(4, 4, -4, -1*(VH-6))
cB = clp.crop(4, VH-6, -4, -4)
cL = clp.crop(4, 4, -1*(VW-6), -4)
cR = clp.crop(VW-6, 4, -4, -4)

if(Ignore == "top") {
cT = cB
} else if (Ignore == "bottom") {
cB = cT
} else if (Ignore == "left") {
cL = cR
} else if (Ignore == "right") {
cR = cL
}

wc = StackHorizontal(cr,cl).TurnLeft
hc = StackVertical(ct,cb)

if(wc.width > hc.width) {
hc = hc.PointResize(wc.width, hc.height)
out = StackVertical(wc,hc)
} else if(wc.width < hc.width) {
wc = wc.PointResize(hc.width, wc.height)
out = StackVertical(wc,hc)
} else {
out = StackVertical(wc,hc)
}
clp5 = (Show == 2) ? out.PointResize(VW, VH) : out
}

# Delete frames above thresholds (that leaves us with the suitable frames for analysis) #
#=======================================================================================#

# Mod of Gavino's DeleteFrames() - https://forum.doom9.org/showthread.php?t=163107
clp5
fc = FrameCount()
res = BlankClip(clp, length=0)
condition = "YPlaneMinMaxDifference >" +String(Th)+ " || UPlaneMinMaxDifference >" +String(Round(Th/2))+ " || VPlaneMinMaxDifference >" +String(Round(Th/2))
current_frame = 0

while (current_frame < fc) {
while (Eval(condition) && current_frame < fc) {
current_frame = current_frame+1
}
if (current_frame < fc) { # not at end
start = current_frame # start of wanted section
while (!Eval(condition) && current_frame < fc) {
current_frame = current_frame+1
}
clpX = (Show == 1) ? clpS : (Show == 2) ? clp5 : clp # 0: Original frames, 1: Original frames + frameNo, 2: Constructed clips (Mode=2 clip is upsized for show)
res = res + clpX.Trim(start, start-current_frame)
}
}
Assert (!(res.FrameCount < 2), """No frames found to analyze, increase "Analyze5Th".""")
return res
}

EDIT: With return clp5 just before your delete frames stuff, I get this
https://i.postimg.cc/SR46DbDL/R95703761-00.jpg (https://postimages.org/)
Some error message on frame. [too small to read]

VoodooFX
11th November 2021, 03:09
That image doesn't look correct. This is how it looks on avs+:

https://i.imgur.com/Ig5JNGy.png

EDIT:
Both tops are just original frames, the bottom left is original frame + original FrameNo, the bottom right is constructed clip (with defaults should be almost one solid color).

EDIT2:
Just noticed that it's "before your delete frames stuff", clp5 should be constructed clip (shouldn't be actual logo in there, just some different color instead at worst, that's why there are no frames on res output)

StainlessS
11th November 2021, 04:07
OK, I've figured out something I forgot a long time ago [I guess I avoid it automatically, but forgot why I do it].

Using GScript [v2.60 std], Scriptclip (or other runtime stuff), is NOT parsed withing GScript, it uses ScriptClip parsing from v2.60 std, so it dont work
when GImport-ing scripts that uses If/for/while etc withing runtimes script.
You need a function external to scriptclip, but within a Gscript parsed region.

This dont work

GScript("""
Function Test26_A(clip c) {
c
SSS="
if(current_frame % 2 ==0) { # <<<<<<<< Error at curly brace, scriptclip dont know what it is
Subtitle(String(current_frame,"+Chr(34)+"%.0f]"+Chr(34)+"))
}
return last
"
return Scriptclip(SSS)
}
""")

blankclip
test26_A()


but this works fine

GScript("""
Function _LOW_Test26_B(clip c) {
c
if(current_frame % 2 == 0) {
Subtitle(String(current_frame,"%.0f]"))
}
return last
}
""")

Function Test26_B(clip c) {
return c.Scriptclip("_LOW_Test26_B")
}


blankclip
test26_B


Or this if GImport-ed under v2.60 std

Function _LOW_Test26_B(clip c) {
c
if(current_frame % 2 == 0) {
Subtitle(String(current_frame,"%.0f]"))
}
return last
}

Function Test26_B(clip c) {
return c.Scriptclip("_LOW_Test26_B")
}

blankclip
test26_B

_LOW_Test26_B is parsed by Gscript, but called from within v2.60 std Scriptclip.

Also this if GImport-ed

Function Test26_B(clip c) {
Function _LOW_Test26_B(clip c) {
c
if(current_frame % 2 == 0) {
Subtitle(String(current_frame,"%.0f]"))
}
return last
}
return c.Scriptclip("_LOW_Test26_B")
}

blankclip
test26_B

EDIT: the parts in red above [and prev code block] should not be GImported, should be in client script.

defo going to bed now.

The Multi-Instance scripts developed by Martin53 and Gavino, use above style calls with simple single line scriptclip and GScript enabled function.
[I use that style a lot]

Maybe should defo be going onto wiki, cos I'm bound to forget why again.

EDIT: VX, the error occurs at first curly brace, need external lo level function for VFX2.

VFX2="""
if(!mask.RT_YInRangeLocate(Baffle=1,lo=255,hi=255)) { # <<<<<<<<
RT_DBaseSetField(Analyze5DB,current_frame,0,2)
Assert (FALSE, "Mask image is invalid.") # Not really a good place for Assert()
}


So like this [but still not like your images - yet]

function Analyze5FX(clip clp, val "mask", int "Mode", int "Analyze5Th", string "Ignore", int "Show") {
Function _VFX2(clip c,clip mask) {
c
if(!mask.RT_YInRangeLocate(Baffle=1,lo=255,hi=255)) {
Assert (FALSE, "Mask image is invalid.") # Not really a good place for Assert()
}
VW = Last.Width
VH = Last.Height
# Convert X,Y,W,H coords to L,T,-R,-B coords
mL = YIRL_X
mT = YIRL_Y
mR = -VW + mL + YIRL_W
mB = -VH + mT + YIRL_H
if(mL < 8 && -1*mR < 8 || mT < 8 && -1*mB < 8) {
Assert (FALSE, "Mask image or Loc is invalid.") # Not really a good place for Assert()
}
# Coords mod2 round up
mL = mL + (mL % 2)
mT = mT + (mT % 2)
mR = mR - (mR % 2)
mB = mB - (mB % 2)
# Crop 2x2 pxs area from above or below the logo and make a background from it
mid = (VW-mL+mR)/2+mL
mid = mid + (mid % 2)
clp2x2 = (mT >= -1*mB) ? Last.crop(mid-2, mT-2, -1*(VW-mid), -VH+mT+2) : Last.crop(mid-2, VH+mB-2, -1*(VW-mid), mB+2)
Return clp2x2.PointResize(VW, VH) # Same size as input clip
}
mask = default (mask , "")
Mode = default (Mode , 1 )
Analyze5Th = default (Analyze5Th , 15)
Ignore = default (Ignore , "none")
Show = default (Show , 0)

Assert (!(Mode < 1 || Mode > 2), """"Mode" value must be between 1 and 2.""")
Assert (!(Analyze5Th < 1 || Analyze5Th > 255), """"Analyze5Th" value must be between 1 and 255.""")
Assert (!(Show < 0 || Show > 2), """"Show" value must be between 0 and 2.""")
Assert ((Ignore == "top" || Ignore == "bottom" || Ignore == "left" || Ignore == "right" || Ignore == "none"), """"Ignore" string must be 'top', 'bottom', 'left', 'right' or 'none'.""")

VW = clp.Width
VH = clp.Height
Th = Analyze5Th
mask = (IsClip(mask)) ? mask.ConvertToY8(matrix="PC.709").MTballoon2PX(2) : nop
clpS = clp.ScriptClip("subtitle(string(current_frame))")

# Construct a clip to check thresholds (for deblending analysis) #
#================================================================#

if(Mode == 1) {
ARGS="mask"
clpB = clp.GScriptClip("_VFX2("+args+")", local=true, args=ARGS, after_frame=true)

Msk1 = mask.MTballoon2PX(2).mt_logic(mask, mode="xor") # 2px wide mask around logo (+2px offset from the base mask)
clp5 = clpB.Overlay(clp, mask=Msk1)

} else {

# Construct a clip to check thresholds (for Automask=1) #
#=======================================================#

cT = clp.crop(4, 4, -4, -1*(VH-6))
cB = clp.crop(4, VH-6, -4, -4)
cL = clp.crop(4, 4, -1*(VW-6), -4)
cR = clp.crop(VW-6, 4, -4, -4)

if(Ignore == "top") {
cT = cB
} else if (Ignore == "bottom") {
cB = cT
} else if (Ignore == "left") {
cL = cR
} else if (Ignore == "right") {
cR = cL
}

wc = StackHorizontal(cr,cl).TurnLeft
hc = StackVertical(ct,cb)

if(wc.width > hc.width) {
hc = hc.PointResize(wc.width, hc.height)
out = StackVertical(wc,hc)
} else if(wc.width < hc.width) {
wc = wc.PointResize(hc.width, wc.height)
out = StackVertical(wc,hc)
} else {
out = StackVertical(wc,hc)
}
clp5 = (Show == 2) ? out.PointResize(VW, VH) : out
}

# Delete frames above thresholds (that leaves us with the suitable frames for analysis) #
#=======================================================================================#
#return clp5

# Mod of Gavino's DeleteFrames() - https://forum.doom9.org/showthread.php?t=163107
clp5
fc = FrameCount()
res = BlankClip(clp, length=0)
condition = "YPlaneMinMaxDifference >" +String(Th)+ " || UPlaneMinMaxDifference >" +String(Round(Th/2))+ " || VPlaneMinMaxDifference >" +String(Round(Th/2))
current_frame = 0

while (current_frame < fc) {
while (Eval(condition) && current_frame < fc) {
current_frame = current_frame+1
}
if (current_frame < fc) { # not at end
start = current_frame # start of wanted section
while (!Eval(condition) && current_frame < fc) {
current_frame = current_frame+1
}
clpX = (Show == 1) ? clpS : (Show == 2) ? clp5 : clp # 0: Original frames, 1: Original frames + frameNo, 2: Constructed clips (Mode=2 clip is upsized for show)
res = res + clpX.Trim(start, start-current_frame)
}
}
Assert (!(res.FrameCount < 2), """No frames found to analyze, increase "Analyze5Th".""")
return res
}


Client

IsPlus = FindStr(VersionString.lcase,"avisynth+")!=0
(IsPlus) ? Import(".\Analyze5FX.avs") : GImport(".\Analyze5FX.avs")

x = LSMASHVideoSource(".\899.mp4")
x = x.crop(1124,24,-52,-636).Trim(30,100) # trimed for speed
mask = ImageSource(".\WieMHwJ.png",0,0)
x=x.BilinearResize(x.width*4,x.height*4)
mask=mask.BilinearResize(mask.width*4,mask.height*4)


# Mode 1 test

m0 = x.Analyze5FX(mask=mask, mode=1, show=0)
m1 = x.Analyze5FX(mask=mask, mode=1, show=1)
m2 = x.Analyze5FX(mask=mask, mode=1, show=2)
mu = Stackhorizontal(m0.AddBorders(0,0,2,0,$000000), m0)
md = Stackhorizontal(m1.AddBorders(0,0,2,0,$000000), m2)
Stackvertical(mu.AddBorders(0,0,0,2,$000000), md)

VoodooFX
11th November 2021, 08:33
if(current_frame % 2 ==0) { # <<<<<<<< Error at curly brace, scriptclip dont know what it is
Ha, told ya that error is at the first curly bracket (https://forum.doom9.org/showthread.php?p=1956958#post1956958). :)

the parts in red above [and prev code block] should not be GImported, should be in client script.
That's a dealbreaker, but the first working example works. Here is version with less Inception:

User script:

GImport("c:\Analyze5FX.avs")
GImport("c:\InpaintDelogo.avs")
x = LSMASHVideoSource("D:\899.mp4")
x = x.crop(1124,24,-52,-636).Trim(30,100) # trimed for speed
mask = ImageSource("D:\mask.bmp",0,0)

# Mode 1 test
m0 = x.Analyze5FX(mask=mask, mode=1, show=0)
m1 = x.Analyze5FX(mask=mask, mode=1, show=1)
m2 = x.Analyze5FX(mask=mask, mode=1, show=2)
mu = Stackhorizontal(m0.AddBorders(0,0,2,0,$000000), m0)
md = Stackhorizontal(m1.AddBorders(0,0,2,0,$000000), m2)
Stackvertical(mu.AddBorders(0,0,0,2,$000000), md)


Analyze5FX.avs:

Function VFX2(clip mask, string Analyze5DB) {
Status = (mask.RT_YInRangeLocate(Baffle=1,lo=255,hi=255)) ? 1 : 2
if(Status==1) {
RT_DBaseSet(Analyze5DB,0,Status,YIRL_X,YIRL_Y,YIRL_W,YIRL_H)
} else {
RT_DBaseSetField(Analyze5DB,0,0,Status)
}
return Last
}


function Analyze5FX(clip clp, val "mask", int "Mode", int "Analyze5Th", string "Ignore", int "Show") {
mask = default (mask , "")
Mode = default (Mode , 1 )
Analyze5Th = default (Analyze5Th , 15)
Ignore = default (Ignore , "none")
Show = default (Show , 0)

Assert (!(Mode < 1 || Mode > 2), """"Mode" value must be between 1 and 2.""")
Assert (!(Analyze5Th < 1 || Analyze5Th > 255), """"Analyze5Th" value must be between 1 and 255.""")
Assert (!(Show < 0 || Show > 2), """"Show" value must be between 0 and 2.""")
Assert ((Ignore == "top" || Ignore == "bottom" || Ignore == "left" || Ignore == "right" || Ignore == "none"), """"Ignore" string must be 'top', 'bottom', 'left', 'right' or 'none'.""")

VW = clp.Width
VH = clp.Height
Th = Analyze5Th
mask = (IsClip(mask)) ? mask.ConvertToY8(matrix="PC.709").MTballoon2PX(2) : nop
clpS = clp.ScriptClip("subtitle(string(current_frame))")

# Construct a clip to check thresholds (for deblending analysis) #
#================================================================#

if(Mode == 1) {
# Get coords of the logo mask
Analyze5DB = ("~InpaintDelogo_Analyze5_"+RT_LocalTimeString+".DB").RT_GetFullPathName
RT_DBaseAlloc(Analyze5DB,1,"iiiii")
ARGS="Analyze5DB"
Parse = mask.ScriptClip("VFX2("+args+")", local=true, args=ARGS, after_frame=true)
Parse.RT_YankChain(n=0)

Assert (!(RT_DBaseGetField(Analyze5DB,0,0) == 2), "Mask image is invalid.")
mX = RT_DBaseGetField(Analyze5DB,0,1)
mY = RT_DBaseGetField(Analyze5DB,0,2)
mW = RT_DBaseGetField(Analyze5DB,0,3)
mH = RT_DBaseGetField(Analyze5DB,0,4)
RT_FileDelete(Analyze5DB)

# Convert X,Y,W,H coords to L,T,-R,-B coords
mL = mX
mT = mY
mR = -VW + mW + mX
mB = -VH + mY + mH
Assert (!(mL < 8 && -1*mR < 8 || mT < 8 && -1*mB < 8), "Mask image or Loc is invalid.")

# Coords mod2 round up
mL = mL + (mL % 2)
mT = mT + (mT % 2)
mR = mR - (mR % 2)
mB = mB - (mB % 2)

# Crop 2x2 pxs area from above or below the logo and make a background from it
mid = (VW-mL+mR)/2+mL
mid = mid + (mid % 2)
clp2x2 = (mT >= -1*mB) ? clp.crop(mid-2, mT-2, -1*(VW-mid), -VH+mT+2) : clp.crop(mid-2, VH+mB-2, -1*(VW-mid), mB+2)
clpB = clp2x2.PointResize(VW, VH)

Msk1 = mask.MTballoon2PX(2).mt_logic(mask, mode="xor") # 2px wide mask around logo (+2px offset from the base mask)
clp5 = clpB.Overlay(clp, mask=Msk1)

} else {

# Construct a clip to check thresholds (for Automask=1) #
#=======================================================#

cT = clp.crop(4, 4, -4, -1*(VH-6))
cB = clp.crop(4, VH-6, -4, -4)
cL = clp.crop(4, 4, -1*(VW-6), -4)
cR = clp.crop(VW-6, 4, -4, -4)

if(Ignore == "top") {
cT = cB
} else if (Ignore == "bottom") {
cB = cT
} else if (Ignore == "left") {
cL = cR
} else if (Ignore == "right") {
cR = cL
}

wc = StackHorizontal(cr,cl).TurnLeft
hc = StackVertical(ct,cb)

if(wc.width > hc.width) {
hc = hc.PointResize(wc.width, hc.height)
out = StackVertical(wc,hc)
} else if(wc.width < hc.width) {
wc = wc.PointResize(hc.width, wc.height)
out = StackVertical(wc,hc)
} else {
out = StackVertical(wc,hc)
}
clp5 = (Show == 2) ? out.PointResize(VW, VH) : out
}

# Delete frames above thresholds (that leaves us with the suitable frames for analysis) #
#=======================================================================================#

# Mod of Gavino's DeleteFrames() - https://forum.doom9.org/showthread.php?t=163107
clp5
fc = FrameCount()
res = BlankClip(clp, length=0)
condition = "YPlaneMinMaxDifference >" +String(Th)+ " || UPlaneMinMaxDifference >" +String(Round(Th/2))+ " || VPlaneMinMaxDifference >" +String(Round(Th/2))
current_frame = 0

while (current_frame < fc) {
while (Eval(condition) && current_frame < fc) {
current_frame = current_frame+1
}
if (current_frame < fc) { # not at end
start = current_frame # start of wanted section
while (!Eval(condition) && current_frame < fc) {
current_frame = current_frame+1
}
clpX = (Show == 1) ? clpS : (Show == 2) ? clp5 : clp # 0: Original frames, 1: Original frames + frameNo, 2: Constructed clips (Mode=2 clip is upsized for show)
res = res + clpX.Trim(start, start-current_frame)
}
}
Assert (!(res.FrameCount < 2), """No frames found to analyze, increase "Analyze5Th".""")
return res
}


Now same needs to be done with the subs extractor thingy and it should be compatible with Avs 2.6 again (just no autoloading there). :thanks:

EDIT:
Just remembered one thing I didn't understand, if you feed RGB24 clip to that frame deleting block it gave me some error.
condition needs to be changed to condition = "RPlaneMinMaxDifference >" +String(Th), should work with mode=2 (no need for mask there).

EDIT2:
Removed "Double GScript" stuff from Analyze5FX.avs.

StainlessS
11th November 2021, 14:03
Ha, told ya that error is at the first curly bracket.
Clever clogs.

That's a dealbreaker, but the first working example works.
I just meant that you dont [usually] put your entire script including eg Avisource("...") in Plugins, nor do you Import nor GImport an entire script,
so you would not add your "User script" to the GImport script. [that was intended for everybody, not just a capable coder like yourself].

Gotta get some milk [mine sour].

EDIT: I just noticed that you've stolen a CopyRight'ed image of mine for your avatar.

Still not got the damn thing working properley, on last try (using more like the original patch code), it was prodcuing something quite akin
to the mandelbrot stuff, looks well weird.

https://i.postimg.cc/HLBXTG4m/Uglarm-Client-00.jpg (https://postimages.org/)
If there had been a logo in above images, they would certainly have been eliminated.
Had I done above patterns deliberately, I would have been quite proud if it. :)


That is very naughty of you, my legal brief will be in contact shortly. [EDIT: 'Brief', Brit slang for solicitor/lawyer or more specifically barrister]
Its no wonder that you're a "Banned User".

VoodooFX
11th November 2021, 20:31
you've stolen a CopyRight'ed image of mine for your avatar.

Yeap, I'm infamous for stealing the Mandelbrot's abstract art from the museums.
I guess that's why they banned me. There is an old murican proverb (https://www.youtube.com/watch?v=eKgPY1adc0A): Ban me once, shame on... shame on you, the banned can't be banned again. :D

Anyway, here you go:

# Version 1.46 : 2021/11/11. Support for AviSynth v2.6 [with the StainlessS's help].


And there is a "small" price to pay. [I would blame StainlessS]

Notes for AviSynth v2.6 users:
# "InpaintDelogo.avsi" needs to be renamed to "InpaintDelogo.avs",
# and loaded manually in AviSynth script with: GImport("C:\AviSynth 2.5\plugins\InpaintDelogo.avs")
# Subs extraction is up to 600% slower than with AviSynth+!


EDIT:
OH gosh, oh tinboy, YOU [we] broke something in AvsPmod... definitely something weird is going on... I need to get that can of beer now...

StainlessS
11th November 2021, 21:09
GScript("""
Function VFX1_GScript(clip c, string FrameDB, int CropW, int CropH) {
c
n = current_frame
Status = RT_DBaseGetField(FrameDB,n,0)
if(Status == 0) { # Unknown Status
Status = crop(CropW,CropH,-1*CropW,-1*CropH).AverageLuma.Sign
if(Status == 1) { RT_DBaseSet(FrameDB,n,Status) }
}
Return Last
}
""")


Nah, Nah, Nah !!!, I might as well talk to the wall.
When you GImport(), you dont need the GScript thingy, Instead of, not as well as.
[Dont know what effect doubling up on Gscript thingy will have, cant be good]

Nice George Dubya clip, says it all really :)

EDIT:
Also, you can just put the script [avs or avsi] in AvsInit GIMPORT folder, does auto load for scripts [with GSCript("...") wrappers REMOVED].
AvsInit:- https://forum.doom9.org/showthread.php?t=176749&highlight=AvsInit
Not sure, maybe Real.Finder has a similar functioning setup.

EDIT:
Test script

blankClip
ScriptClip("""RT_Subtitle("%d]",current_frame)""")

And Debug output from AvsInit:

00000348 20:27:00 AvsInit:
00000349 20:27:00 AvsInit: Auto load plugins script ENTRY
00000350 20:27:00 AvsInit:
00000351 20:27:00 AvsInit_ShowInfo:
00000352 20:27:00 AvsInit_ShowInfo: AvsInit_Version = 1.10
00000353 20:27:00 AvsInit_ShowInfo: GScript Available = AVS+
00000354 20:27:00 AvsInit_ShowInfo: RT_Stats Version = 2.00Beta13
00000355 20:27:00 AvsInit_ShowInfo: SysInfo Version = 0.127000
00000356 20:27:00 AvsInit_ShowInfo: SysInfo.dll DIR = C:\VideoTools\AvisynthRepository\AVSPLUS370_x86\plugins
00000357 20:27:00 AvsInit_ShowInfo: VersionString = AviSynth+ 3.7.1 (r3482, master, i386)
00000358 20:27:00 AvsInit_ShowInfo: SetMemoryMax = 1024
00000359 20:27:00 AvsInit_ShowInfo: Avisynth Bitness = 32
00000360 20:27:00 AvsInit_ShowInfo: WorkingDir = C:\VideoTools\AvisynthRepository\AVSPLUS370_x86\plugins\
00000361 20:27:00 AvsInit_ShowInfo: ProcessName = C:\NON-INSTALL\VDUB\VDUB2\VirtualDub.exe
00000362 20:27:00 AvsInit_ShowInfo: ParentProcessName = PSPad.exe
00000363 20:27:00 AvsInit_ShowInfo: OSVersionString = Windows 10 (x64) (Build 18363)
00000364 20:27:00 AvsInit_ShowInfo: OSVersionNumber = 10.000000
00000365 20:27:00 AvsInit_ShowInfo: OS Bitness = 64
00000366 20:27:00 AvsInit_ShowInfo: CPUName = Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz / Coffee Lake (Core i7)
00000367 20:27:00 AvsInit_ShowInfo: Cores = 06:12 (Phy:Log)
00000368 20:27:00 AvsInit_ShowInfo: CPU Extensions = MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, FMA3, RDSEED, ADX, AVX, AVX2
00000369 20:27:00 AvsInit_ShowInfo: Total Memory = 32621MB
00000370 20:27:00 AvsInit_ShowInfo: Avail Memory = 29677MB'
00000371 20:27:00 AvsInit_ShowInfo: Screen Res = 1920x1080
00000372 20:27:00 AvsInit_ShowInfo: Screen BitsPerPixel = 32
00000373 20:27:00 AvsInit_ShowInfo: Time = Thursday 11 November 2021 20:27:00[GMT Standard Time]
00000374 20:27:00 AvsInit_ShowInfo: User TEMP Dir = C:\Users\steve\AppData\Local\Temp
00000375 20:27:00 AvsInit_ShowInfo: ComSpec = C:\Windows\system32\cmd.exe
00000376 20:27:00 AvsInit_ShowInfo: Computer Name = OMEN-W10P5
00000377 20:27:00 AvsInit_ShowInfo: User Name = steve
00000378 20:27:00 AvsInit_ShowInfo:
00000379 20:27:00 AvsInit_DImport: Importing ... C:\VideoTools\AvisynthRepository\GIMPORT\DBSC.avsi
00000380 20:27:00 AvsInit_DImport: Importing ... C:\VideoTools\AvisynthRepository\GIMPORT\dither.avsi
00000381 20:27:00 AvsInit_DImport: Importing ... C:\VideoTools\AvisynthRepository\GIMPORT\Favc.avsi
00000382 20:27:00 AvsInit_DImport: Importing ... C:\VideoTools\AvisynthRepository\GIMPORT\InpaintDelogo.avsi
00000383 20:27:00 AvsInit_DImport: Importing ... C:\VideoTools\AvisynthRepository\GIMPORT\JohnFPS.avsi
00000384 20:27:00 AvsInit_DImport: Importing ... C:\VideoTools\AvisynthRepository\GIMPORT\McDegrain.avsi
00000385 20:27:00 AvsInit_DImport: Importing ... C:\VideoTools\AvisynthRepository\GIMPORT\Misc.avsi
00000386 20:27:00 AvsInit_DImport: Importing ... C:\VideoTools\AvisynthRepository\GIMPORT\RoboSplice.avsi
00000387 20:27:00 AvsInit_DImport: Importing ... C:\VideoTools\AvisynthRepository\GIMPORT\SetMTMode.avsi
00000388 20:27:00 AvsInit_DImport: Importing ... C:\VideoTools\AvisynthRepository\GIMPORT\SpotLess.avsi
00000389 20:27:00 AvsInit_DImport: IMPORTED 10 scripts from 'C:\VideoTools\AvisynthRepository\GIMPORT'
00000390 20:27:00 AvsInit_DImport: IMPORTED 0 scripts from 'C:\VideoTools\AvisynthRepository\AVSPLUS370_x86\plugins\GIMPORT'
00000391 20:27:00 AvsInit_DLoadConditional: STARTING DLL SCAN on C:\VideoTools\AvisynthRepository\MACHINE
00000392 20:27:00 AvsInit_DLoadConditional: DePan.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000393 20:27:00 AvsInit_DLoadConditional: DePanEstimate.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000394 20:27:00 AvsInit_DLoadConditional: dfttest.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000395 20:27:00 AvsInit_DLoadConditional: DGDecodeNV.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000396 20:27:00 AvsInit_DLoadConditional: FFMS2.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000397 20:27:00 AvsInit_DLoadConditional: LSMASHSource.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000398 20:27:00 AvsInit_DLoadConditional: masktools2.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000399 20:27:00 AvsInit_DLoadConditional: MedianBlur2.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000400 20:27:00 AvsInit_DLoadConditional: mvtools2.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000401 20:27:00 AvsInit_DLoadConditional: nnedi3.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000402 20:27:00 AvsInit_DLoadConditional: RemoveDirt.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000403 20:27:00 AvsInit_DLoadConditional: TIVTC.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000404 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\2_AVS26x86\0_CPP\DePan.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000405 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\2_AVS26x86\0_CPP\DePanEstimate.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000406 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\2_AVS26x86\0_CPP\dfttest.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000407 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\2_AVS26x86\0_CPP\ffms2.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000408 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\2_AVS26x86\0_CPP\masktools2.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000409 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\2_AVS26x86\0_CPP\MedianBlur2.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000410 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\2_AVS26x86\0_CPP\mvtools2.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000411 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\2_AVS26x86\0_CPP\nnedi3.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000412 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\2_AVS26x86\0_CPP\TIVTC.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000413 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\1_AVS26Stdx86\0_CPP\ffms2.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000414 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\1_AVS26Stdx86\0_CPP\masktools2.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000415 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\1_AVS26Stdx86\0_CPP\mvtools2.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000416 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\1_AVS26Stdx86\0_CPP\nnedi3.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000417 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\1_AVS26Stdx86\0_CPP\RemoveDirt.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000418 20:27:00 AvsInit_DLoadConditional: DGDecode.dll LoadPlugin OK from 0_XP\0_AVS25x86\0_CPP
00000419 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\0_AVS25x86\0_CPP\ffms2.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000420 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\0_AVS25x86\0_CPP\LSMASHSource.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000421 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\0_AVS25x86\0_CPP\masktools2.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000422 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\0_AVS25x86\0_CPP\mvtools2.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000423 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\0_AVS25x86\0_CPP\RemoveDirt.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000424 20:27:00 AvsInit_DLoadConditional: STARTING SCRIPT SCAN on C:\VideoTools\AvisynthRepository\MACHINE
00000425 20:27:00 AvsInit_DLoadConditional: 13 dll's LOADED : 19 dll's SKIPPED : 0 dll's FAILED
00000426 20:27:00 AvsInit_DLoadConditional: 0 scripts LOADED : 0 Scripts SKIPPED : 0 scripts FAILED

VoodooFX
11th November 2021, 21:37
When you GImport(), you dont need the GScript thingy.

That's another problem I guess, now AvsPmod just doesn't start, AvS+ and no GImport there, it just crash at start when trying to autoload InpaintDelogo.avsi. If you rename avsi to avs, start AvsPmod and rename avs back, then AvsPmod loads script and the script works OK... weird... need to investigate.

StainlessS
11th November 2021, 21:53
[after remove the GScript("...") thingy]
You can just put eg "InPaintDelogo_AutoLoader.avsi" into your plugins, something like

InPaintDelogo_AutoLoader.avsi

IsPlus = FindStr(VersionString.lcase,"avisynth+")!=0
(IsPlus) ? Import("SOMEPATH\Analyze5FX.avs") : GImport("SOMEPATH\Analyze5FX.avs") # where SOMEPATH might be ".\VoodooFX" or other.


Its not rocket science. :)

For AvsInit(), just drop the InPaintDelogo.avsi into one of the GIMPORT folders [has one for each version of Avisynth, but most might use the all Avisynth versions GIMPORT folder].

EDIT:
Subs extraction is up to 600% slower than with AviSynth+!
There has gotta be something weird happening there [maybe the double Gscript/GImport thing], not a lot of difference between
Gscript and AVS+ Gscript extensions usually.

EDIT: When I say "has one for each version of Avisynth", I use and intend use with Groucho2004 "Universal Avisynth Installer":- https://forum.doom9.org/showthread.php?t=172124
which allows easy switch to one of multiple versions of avisynth [1 x86, and 1 x64, simultaneous installed].

VoodooFX
11th November 2021, 22:39
AvsPmod crash at start is fixed:

# Version 1.47 : 2021/11/11. Fixed: "Double Gscript".

Same slow on v2.6, but hey now with the AvsInit ad: :)

# Notes for AviSynth v2.6 users:
# Requirement: GScript ( http://avisynth.nl/index.php/GScript ).
# "InpaintDelogo.avsi" needs to be renamed to "InpaintDelogo.avs",
# and loaded manually in AviSynth script with: GImport("C:\AviSynth 2.5\plugins\InpaintDelogo.avs"),
# or use AvsInit for autoloading ( https://forum.doom9.org/showthread.php?t=176749 ).
# Subs extraction is up to 600% slower than with AviSynth+!

VoodooFX
11th November 2021, 22:56
There has gotta be something weird happening there [maybe the double Gscript/GImport thing], not a lot of difference between
Gscript and AVS+ Gscript extensions usually.

I get (v1.47, no double Gscript):
Extract test: 5s in AvS+, 32s in AvS v2.6.
Mask + Extract test: 55s in AvS+, 80s in AvS v2.6.

Files:
https://we.tl/t-942gjNbEso

GImport("c:\InpaintDelogo.avs") # For v2.6
ImgDir = "d:\IMAGES\"

# Extract test:
LWLibavVideoSource("d:\subs_anime_mask.mkv")
SubsMask2Img(ImgDir=ImgDir)

#~ # Mask + Extract test:
#~ LWLibavVideoSource("d:\subs_anime.mkv")
#~ InpaintDelogo(Loc="0,0,-0,-0",
#~ \ oPP=0,
#~ \ DynMask=4, DynTune=220, DynMask4H=60, KillNoise=-5,
#~ \ Show=4, Extract=1, ImgDir=ImgDir)

Danette
14th November 2021, 20:01
I’m not sure that I understand what the purpose of “Dynamic mask” is. Is it intended to mask a changing logo, within a specified Loc="x,x,-x,-x", and within a single video or can it chase an identical logo that is applied to multiple videos, but in slightly different coordinates …or both?

Perhaps this will be clearer if I explain by way of an example of what I want:

I have 100 episodes of a show. The same sized logo appears in each show. However, that logo, while having fixed coordinates within each episode, may be in slightly different coordinates from one episode to another. I would like to have InpaintDelogo find the logo, within a defined Loc="x,x,-x,-x", and apply the mask wherever that logo appears in the defined Loc="x,x,-x,-x". This Loc="x,x,-x,-x" will have the same coordinates for each episode.

VoodooFX
14th November 2021, 22:06
I’m not sure that I understand what the purpose of “Dynamic mask” is. Is it intended to mask a changing logo, within a specified Loc="x,x,-x,-x", and within a single video or can it chase an identical logo that is applied to multiple videos, but in slightly different coordinates …or both?


“Dynamic mask” is a whole B/W mask clip in Y8, same frame length as video and same dimensions as Loc area, "object" can change there every frame, you can supply such mask from external plugin or use some internal methods.
I don't know any identical object recognition plugin for Avisynth, wonkey_monkey mentioned that he has some experimental plugin, but that's it. (EDIT: There is some AvisythTrackin plugin)
There are few internal DynMask methods to do the dynamic masks for some specific objects like bright-nontransparent logos (like subtitles). (EDIT: There is StainlessS's DetSub plugin)

From your description you would need to use a one frame/image mask, if it changes location in another video then you need to create another image mask for that video. If you don't know how to create a mask in Photoshop then you can use "Automask" parameter and its sub-parameters to do it for you.
(EDIT: If logo is non-transparent and moves just one pixel, then with Inflate=2 you probably can do all videos with same mask)

Post some screens of that logo/mask/script and I can advice further on the matter. There is "Show=1" parameter so you could post screen of that too.

Danette
14th November 2021, 23:58
Thanks. I guess we’ll have to wait for AI.

I think you have an exact understanding of my intent, so I’ll do what I used to do with VDub DeLogo which is, as you said, creating new masks whenever an adjustment is needed for a new episode. I can do this, easily, with PhotoImpact. However, I will be using InpaintDelogo, as I’ve convinced myself that it is far better than VDub DeLogo. I was just hoping that a non-manual adjustment capability was buried in there somewhere.

The Inflate=2 won’t be enough. If Inflate=x had the option to go up to about 20 pixels, then I could adapt to that. If it did inflate that much, even better would be inflating by one, or more, of the 4 coordinates. Generally, these logos only drift horizontally, so top and bottom inflation is not needed.

VoodooFX
15th November 2021, 00:55
Thanks. I guess we’ll have to wait for AI.
AI is not necessary for same object recognition.

I will be using InpaintDelogo, as I’ve convinced myself that it is far better than VDub DeLogo.
If there were anything better in VDub'd Delogo then I would have included option for it.

Generally, these logos only drift horizontally, so top and bottom inflation is not needed.
Then it is just few seconds to move it few pixels in the image editors. Inflate just expands a base mask the few pixels to cover possible artifacts at the edges.

Danette
18th November 2021, 02:44
I am now attempting to apply InpaintDelogo(mask="xxxx.bmp", Loc="xxx,xxx,-xxx,-xxx",Mode="Inpaint") to remove the first logo, but have run into a problem. How do I specify that a mask be applied to one or more ranges of frames in a video? For example; if I want to remove the logo that is present between frames 10870 and 11870 and then also between frames 13000 and 14000. This was simple with VDub Delogo, but I cannot find the method for InpaintDelogo.

VoodooFX
18th November 2021, 04:05
I want to remove the logo that is present between frames 10870 and 11870 and then also between frames 13000 and 14000.

Use Trim. Here a basic example how it's done:


o=DGDecode_mpeg2source("D:\clip.d2v")

# Deinterlace before delogo:
c=o.QTGMC().SelectEven()

# Split video with Trim() & delogo on some ranges:
t1=c.Trim(0, 10869)
t2=c.Trim(10870, 11870).InpaintDelogo()
t3=c.Trim(11871, 12999)
t4=c.Trim(13000, 14000).InpaintDelogo()
t5=c.Trim(14001, 999999)

# Then join video back:
t1+t2+t3+t4+t5

Danette
18th November 2021, 05:31
Ugh! I had considered that. That’s fine for one logo and one or two segments in a couple of videos, but if I have 3-4 logos, all in 1-20 different frame segments in a single video, that’s quite an unwieldy mess of script. I could be looking at 20-30 lines, or more, of trim script. Then, multiply that by a couple hundred videos. VDub’s Delogo starts to look really good as the optimal choice, despite somewhat inferior logo removal.

I appreciate your help, but InpaintDelogo does not seem to be a good choice for situations such as mine.

VoodooFX
18th November 2021, 09:59
Ugh! I had considered that. That’s fine for one logo and one or two segments in a couple of videos, but if I have 3-4 logos, all in 1-20 different frame segments in a single video, that’s quite an unwieldy mess of script.

Then you need to learn a bit more about AviSynth. ;)

Dealing with lots of ranges and logos with ClipClop:
V1 = InpaintDelogo( mask="D:\logo1.bmp")
V2 = InpaintDelogo( mask="D:\logo2.bmp")
V3 = InpaintDelogo( mask="D:\logo3.bmp")

Ranges=""" # Various ranges for various logos
1 0,500; 1 3400,3800; 1 4000,4444
2 2020,2500
3 1100,1900
"""

ClipClop(Last,V1,V2,V3,scmd=Ranges,show=false)

Or ClipClop with nicknames:
V1 = InpaintDelogo( mask="D:\logo1.bmp")
V2 = InpaintDelogo( mask="D:\logo2.bmp")
V3 = InpaintDelogo( mask="D:\logo3.bmp")

NickNames =""" # Psuedonyms for clips (clip index number)
Logo1 = 1
Logo2 = 2
Logo3 = 3
"""

Ranges=""" # Various ranges for various logos
Logo1 0,500
Logo3 1100,1900
Logo2 2020,2500
Logo1 3400,3800
Logo1 4000,4444
"""

ClipClop(Last,V1,V2,V3,scmd=Ranges,nickname=NickNames,show=false)

Or RemapFrames:
V1 = InpaintDelogo( mask="D:\logo1.bmp")
V2 = InpaintDelogo( mask="D:\logo2.bmp")
V3 = InpaintDelogo( mask="D:\logo3.bmp")

ReplaceFramesSimple(Last,V1,Mappings="[0 500] [3400 3800] [4000 4444]")
ReplaceFramesSimple(Last,V2,Mappings="[2020 2500]")
ReplaceFramesSimple(Last,V3,Mappings="[1100 1900]")

Danette
18th November 2021, 14:01
Then you need to learn a bit more about AviSynth.

You are making an understatement ...I need to learn a lot more about Avisynth!

Thanks for the lesson. Odd that my searching didn't find any of that approach. I will work with that script to see how well it works for my situation. It looks like it should do the job.

VoodooFX
18th November 2021, 14:39
If some of your ranges/logos overlap then I dunno if ClipClop will do the job properly in those examples. StainlessS should know.
RemapFrames example would need adjustment to do overlaps.

Danette
18th November 2021, 16:00
Yes, the logos are all overlaps, with some instances of three at a time.

VDub Delogo handles them and, I suspect, these, or similar, codes were used.

StainlessS
18th November 2021, 16:04
The later [in SCMD/CMD] range/frame overrides previously specified ranges/frames,
specifying clip index 0, restores to original source [first clip arg].

SCMD="""
1 100,200 # replace range 100 to 200 with range from clip 1
0 50 # but frame 50 restored to source frame
"""


EDIT:
with some instances of three at a time.
Ho Ho ho, good luck with that.

VoodooFX
18th November 2021, 16:37
Yes, the logos are all overlaps, with some instances of three at a time.

Then this should work, I think:

Ranges1="""
1 0,500; 1 3400,3800; 1 4000,4444
"""
Ranges2="""
1 2020,2500
"""
Ranges3="""
1 1100,1900
"""

V1 = InpaintDelogo( mask="D:\logo1.bmp")
ClipClop(Last,V1,scmd=Ranges1,show=false)

V2 = InpaintDelogo( mask="D:\logo2.bmp")
ClipClop(Last,V2,scmd=Ranges2,show=false)

V3 = InpaintDelogo( mask="D:\logo3.bmp")
ClipClop(Last,V3,scmd=Ranges3,show=false)

Or:

V1 = InpaintDelogo( mask="D:\logo1.bmp")
ReplaceFramesSimple(Last,V1,Mappings="[0 500] [3400 3800] [4000 4444]")
V2 = InpaintDelogo( mask="D:\logo2.bmp")
ReplaceFramesSimple(Last,V2,Mappings="[2020 2500]")
V3 = InpaintDelogo( mask="D:\logo3.bmp")
ReplaceFramesSimple(Last,V3,Mappings="[1100 1900]")

Danette
18th November 2021, 20:34
Ho Ho ho, good luck with that.

As a point of curiosity, any idea how Karel Suhajda accomplished this, so easily (from a users standpoint) in VDub? Is VDub simply more dynamic, for code, than Avisynth?



V1 = InpaintDelogo( mask="D:\logo1.bmp")
ReplaceFramesSimple(Last,V1,Mappings="[0 500] [3400 3800] [4000 4444]")
V2 = InpaintDelogo( mask="D:\logo2.bmp")
ReplaceFramesSimple(Last,V2,Mappings="[2020 2500]")
V3 = InpaintDelogo( mask="D:\logo3.bmp")
ReplaceFramesSimple(Last,V3,Mappings="[1100 1900]")


I’ll try this, in the next several days, as it seems that the first code is going to require the same 20-30 script lines, per video, as the trim approach would.

StainlessS
19th November 2021, 03:40
Sorry, I have no idea what Karel Suhajda accomplished, nor how.

VoodooFX
19th November 2021, 22:20
I played a bit with new analyze func, good results so far, but I compared it to AviUtl logoscan and I get there selected significantly different frames, maybe Threshold there doesn't mean MinMax threshold...

Can anyone who can read c++ look there and tell what is done with that Threshold param?

In filter.cpp (https://github.com/makiuchi-d/delogo-aviutl/blob/master/logoscan/filter.cpp) /scanpix.cpp (https://github.com/makiuchi-d/delogo-aviutl/blob/master/logoscan/scanpix.cpp) I see that it's defined as tTHY and then I can't understand what is going on with it there.



I’ll try this, in the next several days, as it seems that the first code is going to require the same 20-30 script lines, per video, as the trim approach would.
20-30 lines in script is usual... Do you write your scripts in MeGUI's editor? If you do then I understand your frustration with that small screen. Get AvsPmod (https://forum.doom9.org/showthread.php?t=175823)!

VoodooFX
21st November 2021, 10:36
Does anyone have wishes/suggestions about delogo and stuff?
I've decided to rewrite automask and deblend, to do it right this time. Incorporating smart analysis into current hacks needs to tweak them, I think for me it's easer just to remove those hacks and do a proper delogo in the first place... They usually work well in normal cases, but not for those poor souls who wants to delogo Nth recompressed videos (where logo/blending is simply damaged by artifacts).
[Those hacks are to work around some flaws in the Karel Suhajda's delogo design, which was copied and consequently flaws were inherited by AvsInpaint].

What about idea to incorporate all masks into one file? That would make it more universal, in case you would want to use masks on other videos with same logo, you would need to change only coords to move all logo masks, but at the current state you can move only by 2 pxs, it's possible to add compatibility to 1px, but lots of stuff then need to be rechecked/rewritten and probably there would be some performance penalty. I'm not sure if it's worth to bother, there are no problems for the savy avs users...

kedautinh12
21st November 2021, 13:15
I wish inpaintdelogo easy to use :D

VoodooFX
21st November 2021, 13:30
I wish inpaintdelogo easy to use :D
There will be even more parameters, but I promise I'll stop after 100. [word of the boy scout] :D

But you never stated what is hard there for you, almost everything there happens automatically, except setting loc of the logo and the analysis frames for deblend, but in v2 analysis stuff will be automated.

Probably you didn't used previous delogo scripts where there were less parameters, and you could change any of them but still that didn't made logo disappear. :D

dot75
21st November 2021, 17:46
hello I would like to hide this parental advisory I understood how to hide the round logo on the other hand it does not work for the advisory

InpaintDelogo( Loc="1018,922,-254,-106)

VoodooFX
21st November 2021, 18:56
hello I would like to hide this parental advisory I understood how to hide the round logo on the other hand it does not work for the advisory

InpaintDelogo( Loc="1018,922,-254,-106)

Hi, upload your attachment to imgur.com or to other image hosting site.

dot75
21st November 2021, 19:24
Hi, upload your attachment to imgur.com or to other image hosting site.

https://imgur.com/a/llDwuXB

VoodooFX
21st November 2021, 19:52
And where is the mask image? Post your full script too and version of InpaintDelogo.
Btw, your Loc doesn't leave minimum 10pxs space at the top and right sides, use "1018,920,-248,-106".

dot75
21st November 2021, 20:01
InpaintDelogo( mask="H:\Mask8.bmp",
\ Automask=0, aMix=-0,Loc="1672,914,-184,-100",
\ Mode="Inpaint",
\ Analyze=3, FrW=54, FrS=0,dPP=0,Show=0,Inflate=2)

for parental advisor
InpaintDelogo( Loc="1018,920,-248,-106",DynMask=3, DynInflate=4, Dyn3Seq=13, ClpBlend=11, Show=5)

VoodooFX
21st November 2021, 20:07
And version of InpaintDelogo?
DynMask=3 is probably not a correct method here.

dot75
21st November 2021, 20:08
And version of InpaintDelogo?
DynMask=3 is probably not a correct method here.

yes 1.48

VoodooFX
21st November 2021, 20:32
What means "does not work"?
That round logo looks like it's transparent so correct would be to deblend it. For text use inpaint, you can do both logos in one go with mode="Both".
Why you use Dynamic=3? Why Dyn3Seq=13, is logo there for only half second? Show=5 doesn't do delogo, it only shows you a mask.

dot75
21st November 2021, 20:43
What means "does not work"?
That round logo looks like it's transparent so correct would be to deblend it. For text use inpaint, you can do both logos in one go with mode="Both".
Why you use Dynamic=3? Why Dyn3Seq=13, is logo there for only half second? Show=5 doesn't do delogo, it only shows you a mask.

how to do I must put the loca twice ?
the text disappears at frame 1300

VoodooFX
21st November 2021, 21:00
how to do I must put the loca twice ?
the text disappears at frame 1300
You don't. Include both logos in same Loc. And both logos should be in the mask.
If logo is not in the whole video then delogo only that range, example is there https://forum.doom9.org/showthread.php?p=1957647#post1957647

dot75
21st November 2021, 21:46
V2 = InpaintDelogo( mask="H:\Mask9.bmp",
\ Automask=0, aMix=-0,Loc="1018,920,-248,-106",
\ Mode="Inpaint",
\ Analyze=3, FrW=54, FrS=0,dPP=0,Show=1,Inflate=2)


https://imgur.com/a/bO2XYi6

VoodooFX
21st November 2021, 22:13
You didn't set a black frame: FrB.
dPP has nothing to do with Inpaint mode.

EDIT:
How did you get that mask?
It's incorrect:
https://i.imgur.com/CPQ1AG2.png

Mask should be: white where logo is, and the rest is black.

Danette
22nd November 2021, 04:04
V1 = InpaintDelogo( mask="D:\logo1.bmp")
ReplaceFramesSimple(Last,V1,Mappings="[0 500] [3400 3800] [4000 4444]")
V2 = InpaintDelogo( mask="D:\logo2.bmp")
ReplaceFramesSimple(Last,V2,Mappings="[2020 2500]")
V3 = InpaintDelogo( mask="D:\logo3.bmp")
ReplaceFramesSimple(Last,V3,Mappings="[1100 1900]")


Had a chance to test this code approach. It works perfectly AND can handle, at least, three separate logos simultaneously. Thanks.

Question: if I am creating a manual mask (all blue 255 background with the logo white), why bother with the location of the logo? When I tried setting Loc=”0,0,-0,-0” , and applied the manual mask mentioned, the logo was covered exactly as it is when a selection tightly bound by location coordinates is used.

Does anyone have wishes/suggestions about delogo and stuff?

What about idea to incorporate all masks into one file? That would make it more universal, in case you would want to use masks on other videos with same logo, you would need to change only coords to move all logo masks, but at the current state you can move only by 2 pxs, it's possible to add compatibility to 1px, but lots of stuff then need to be rechecked/rewritten and probably there would be some performance penalty. I'm not sure if it's worth to bother, there are no problems for the savy avs users...

I think that you have some of my interests to use. Of particular value, to me, would be the previously mentioned idea of being able to track a logo that doesn’t change, other than its’ location. If this can be done, a further enhancement would be to have the delogo function adapt to minor variations in the logo itself, e.g.; if the logo mask changed by 2%, the delogo function would adapt as it happened.

I like that idea of all masks into one file!

VoodooFX
22nd November 2021, 05:52
Question: if I am creating a manual mask (all blue 255 background with the logo white), why bother with the location of the logo? When I tried setting Loc=”0,0,-0,-0” , and applied the manual mask mentioned, the logo was covered exactly as it is when a selection tightly bound by location coordinates is used.


You are mixing up with Vdub's Delogo, there is no "blue" for InpaintDelogo, the base mask should be only white and black.
Loc is area which will be processed, if you process whole frame then it will be pretty slow.

Of particular value, to me, would be the previously mentioned idea of being able to track a logo that doesn’t change.
That would be nice. You can try to make a thread at Avisynth Development (https://forum.doom9.org/forumdisplay.php?f=69), maybe someone would be interested in making such tracking or someone secretly has such plugin.

dot75
22nd November 2021, 07:15
You didn't set a black frame: FrB.
dPP has nothing to do with Inpaint mode.

EDIT:
How did you get that mask?
It's incorrect:
https://i.imgur.com/CPQ1AG2.png

Mask should be: white where logo is, and the rest is black.
Just via Analyze=3
the result and not good you are right iam lost lol

VoodooFX
22nd November 2021, 08:21
Just via Analyze=3
the result and not good you are right iam lost lol
But you didn't set the black frame parameter there [and Automask=1 creates the base mask].
Here is the mask I made with Photoshop from your screenshot:
https://i.imgur.com/guOQbvt.png

dot75
22nd November 2021, 08:38
But you didn't set the black frame parameter there [and Automask=1 creates the base mask].
Here is the mask I made with Photoshop from your screenshot:
https://i.imgur.com/guOQbvt.png

I'm going to start over .
you did it with Photoshop I don't know anything about photo editing I guess that's complicated to do ?

VoodooFX
22nd November 2021, 08:55
I don't know anything about photo editing I guess that's complicated to do ?
It took me all ~30 seconds to do it.

dot75
22nd November 2021, 09:13
It took me all ~30 seconds to do it.

yes when we know how to do it
I will try to learn with gimp or photofiltre

Danette
22nd November 2021, 15:34
You are mixing up with Vdub's Delogo, there is no "blue" for InpaintDelogo, the base mask should be only white and black.

No, this wasn’t a mix-up with VDub’s Delogo. When I initially made a black image for Automask, then ran it, the mask color appeared as a blue (0,0,255 RGB) in my particular image editor (it was black in another image viewer, though). So, I assumed that was ok and began using blue as the mask, but always making the logo white. Guess what: it seems to work the same with the blue mask (I can’t tell a difference in the result). However, I will return to a black mask, since it is just as easy and, perhaps, the value may be so subtle that I am overlooking it.

Using a blue mask even worked identically to a black mask when using Automask. However, I’ve decided not to use Automask because it doesn’t identify a logo image well enough and does falsely find other non-logos, despite amix settings and best efforts to get a solid black image in the location area, requiring manual adjustments in the image editor, anyway.

The other reason that I say it wasn’t a mix-up with VDub’s DeLogo is because, from a user standpoint, VDub’s DeLogo doesn’t require a user-created mask. All you need do is to capture the image, open the image in a image editor, and paint the logo red (255,0,0 RGB). VDub’s DeLogo then takes it from there and, internally, processes it all. That may be an idea for simplifying InpaintDelogo for users, since you are de-constructing VDub’s DeLogo and looking for improvement ideas.

That would be nice. You can try to make a thread at Avisynth Development (https://forum.doom9.org/forumdisplay.php?f=69), maybe someone would be interested in making such tracking or someone secretly has such plugin.

Done

VoodooFX
22nd November 2021, 16:58
When I initially made a black image for Automask, then ran it, the mask color appeared as a blue (0,0,255 RGB) in my particular image editor (it was black in another image viewer, though).
You don't create images for Automask. Automask creates images for you. I've no ideas how Black can be Blue...

The other reason that I say it wasn’t a mix-up with VDub’s DeLogo is because, from a user standpoint, VDub’s DeLogo doesn’t require a user-created mask. All you need do is to capture the image, open the image in a image editor, and paint the logo red (255,0,0 RGB).
In your second sentence you describe how you make "a user-created mask" for VDub's Delogo...

That may be an idea for simplifying InpaintDelogo for users, since you are de-constructing VDub’s DeLogo and looking for improvement ideas.
VDub mask has four colors for user to use: Blue, Red, Green and Black. That's way more complex than simply Black and White. I can't reduce colors count further. :D

dot75
22nd November 2021, 18:29
automask work via

InpaintDelogo( mask="E:\Mask15.bmp",
\ Automask=0, aMix=0, Loc="1018,920,-248,-106",
\ Mode="Inpaint",
\ Analyze=4, FrB=499, FrW=800, FrS=0,show=1)

https://imgur.com/a/iRGknHF

VoodooFX
22nd November 2021, 19:13
automask work via
You can still see logo outlines, that's because the mask doesn't cover all upscaled artifacts in your video. Try Inflate=2.
Btw, with Analyze=4 a white frame [FrW] is not used.

dot75
22nd November 2021, 19:24
still artifacts


InpaintDelogo( mask="E:\Mask15.bmp",
\ Automask=0, aMix=0, Loc="1018,920,-248,-106",
\ Mode="Inpaint",
\ Analyze=4, FrB=499, FrW=800, FrS=0,show=1,Inflate=2)

https://imgur.com/a/1SC2mkD

VoodooFX
22nd November 2021, 20:21
still artifacts
I don't see any, looks ok.

Danette
22nd November 2021, 21:07
I think we’re getting twisted-up in semantics:

You don't create images for Automask. Automask creates images for you. I've no ideas how Black can be Blue...

Yes, I know about Automask creating the image/mask. It did create the black mask background with the white logo. It was my image editor that, somehow, reads that black creation of Automask as blue. Then, when I make the manual mask using blue (assuming that was ok), I found that it works with InpaintDelogo, even though it isn’t a black mask background. I guess that InpaintDelogo will work with any pure RGB mask color as long as there isn't such purity in any other part of the image.

This blue mask background was confirmed to be blue by other image editors. If you’re interested in trying this blue version, I can send the file, but you could probably do it as easily by creating the blue mask with your own editor. It’s not an issue, just a point of curiosity.

In your second sentence you describe how you make "a user-created mask" for VDub's Delogo...

Not exactly. There is no mask aspect necessary, from a user standpoint, in VDub’s DeLogo. It is the actual frame image, as it appears in, e.g.; AvsPmod, that is used by VDub’s DeLogo, not a black, blue, etc. colored mask image. The only thing the user needs to do is to paint the logo red. VDub’s DeLogo then takes that and, presumably, creates a mask out of it internally, out of sight from the user.

VDub mask has four colors for user to use: Blue, Red, Green and Black. That's way more complex than simply Black and White. I can't reduce colors count further. :D

Black and white are fine, as mentioned above. However, I think that InpaintDelogo can also handle, at least, blue, as well. I have not tested other two RGB colors. Again, just a point of curiosity/interest.

That would be nice. You can try to make a thread at Avisynth Development (https://forum.doom9.org/forumdisplay.php?f=69), maybe someone would be interested in making such tracking or someone secretly has such plugin.

Surprise: see the comment by wonkey_monkey here: https://forum.doom9.org/showthread.php?p=1957958#post1957958

VoodooFX
22nd November 2021, 22:41
It was my image editor that, somehow, reads that black creation of Automask as blue.
What is that image editor?


If you’re interested in trying this blue version, I can send the file

No need, any image is binarized according to levels [whatever numbers I did put there].


Not exactly. There is no mask aspect necessary, from a user standpoint, in VDub’s DeLogo. It is the actual frame image, as it appears
If you don't understand what mask means, that doesn't make a mask not a mask. :)


not a black, blue, etc. colored mask image. The only thing the user needs to do is to paint the logo red.

That's for opaque logos, for transparent one there are four colors for a mask.

Danette
23rd November 2021, 00:43
The image editor is an old version of Ulead PhotoImpact.

Perhaps I don’t understand what a mask is, as you said. When we paint the logo, that is the mask …correct?

What I have found is that, for both color and B&W videos, if I use a saved image of a video frame and simply paint the logo gray or white, with the PhotoImpact mask tool, it works without having a black base layer. This is similar to VDubs DeLogo, except that white or gray is used to paint the logo instead of red. Do you see anything wrong with this approach to using InpaintDelogo?

BTW: wonkey_monkey is looking for examples of moving logos within a video, in case you can provide any. The link is in a previous post.

VoodooFX
23rd November 2021, 02:06
Do you see anything wrong with this approach to using InpaintDelogo?
If programs tell you to use black and white and you paint there god knows what, do you think it's right? Is Black color against your religion or something, what is the problem? :D

This is similar to VDubs DeLogo
It's opposite of "similar", in VDub you do as instructed - paint mask red, when in here against all instructions you paint some random colors. Why you don't paint some random stuff in VDub's masks?
I don't understand, at all...

Danette
23rd November 2021, 03:17
It's opposite of "similar", in VDub you do as you instructed - paint mask red, when in here against all instructions you paint some random colors. Why you don't paint some random stuff in VDub's masks?
I don't understand, at all...

This was taken out of context. Vdubd DeLogo instructions are quite clear and easy to understand.

Sorry to cause frustration, but the InpaintDelogo instructions leave much to be desired in terms of guidance. So, we are left to our own devices in terms of choosing a color for manual mask creation. I’d be very interested if you could point me to any part of the manual where it states what color to paint the logo and whether or not the background/base should be a certain color. I started with RGB, black and white. After much trial and error, I came up with gray and white as those colors that work for painting the logo.

From what I can tell of the instructions, virtually all guidance is for Automask, but Automask performs rather poorly on every video that I’ve thrown at it. Using the Automask base of black caused my image editor to exhibit a blue base. Not all image editors appear to be created equally so, when you expect black, but get blue, you work with that, since it does the job. With no instruction for manual mask creation apparent, I look for trial and error solutions. From this process, I found that the black base seems to work no better than an original video image. I was simply asking for confirmation that the process I stumbled upon, when not using Automask, was ok given what you know of the code.

Much of the problems that many are struggling with on this thread could be avoided by providing a step-by-step guide on manual mask creation.

I'll back away and follow the progress as others squeeze info out in this thread.

Incidentally: you were quite helpful on other issues and I thank you for that.

VoodooFX
23rd November 2021, 15:21
Vdubd DeLogo instructions are quite clear and easy to understand.
Yes they are, still you didn't understood that you are making a mask and that there are more colors than Red for it.

I’d be very interested if you could point me to any part of the manual where it states what color to paint the logo.
That is in the first sentence about it:

# val "mask" : File based mask:
# Full path to the base mask of the logo, a B/W picture (Logo -> white).

Automask performs rather poorly on every video that I’ve thrown at it... black, but get blue...
Maybe you are doing something wrong, maybe there is a bug, maybe it can be improved, or not. Without examples I don't know.

Danette
23rd November 2021, 23:48
Thanks for the response. I wasn’t expecting it.

I did see the “B/W picture (Logo -> white)” in the manual, but didn’t realize that it was code for: “create a black base with the logo painted white.” I suggest changing that code to the plain-English version I just posted, or something similarly clear. When I read the manual, where it says “B/W picture” I assumed that a B/W picture (black and white as opposed to color) was to be used. Here is an example of a “B/W picture”: https://postimg.cc/jwQyP4gB. This is how I discovered that InpaintDelogo works using that as the “C:\mymask.bmp”. Where I had only a color image, I assumed that Greyscale() could be employed to create the “B/W picture.” I had no idea what “(Logo -> white)” meant. I do now.

I’m not worried about the Automask-generated black base showing as blue in my image editor. I now know that the base should be black if I use Automask and can deal with that. I’m also not worried about the Automask feature, since I won’t be using it. If you are asking, for your own benefit, for examples, to see how it fails on my videos, I’ll be happy to provide examples. However, it seems that Automask is an unreliable method for sufficiently covering a logo, from what I’ve read by other posters confirming my own experience with it. So, I’m happy just making my own manual masks.

What I had an interest in knowing, as per my previous post, is whether or not, in your opinion, using the base without any solid color, such as in the link posted above, presents any problem in your mind. I suspect that you may have been unaware that InpaintLogo does work on a video without needing a black base, much like VDubs DeLogo. As an example; when I take the image in that link, above, and paint the logo white, and then use that in the “C:\mymask.bmp”, it seems to perform exactly as compared to when I make a black base. My reason for doing this is to simply save time in mask creation.

VoodooFX
24th November 2021, 13:13
That's a greyscale image in your example, if you have no idea what something means then you need to ask on forum. I'll change it in the manual to be more specific.

I'm fully aware how InpaintDelogo works, of course images with random colors supplied as masks can have problems. If something seems to work doing against instructions that's called a foolproof design. Looks like I need to change that too. ;)

Can you generate and show a mask with Automask from video in that example you've posted, and one you made with editor?

VoodooFX
25th November 2021, 19:26
However, it seems that Automask is an unreliable method for sufficiently covering a logo, from what I’ve read by other posters confirming my own experience with it.
I've searched this whole thread and except yours I found only one feedback about Automask:


First of all I must say that the Automask feature works well.

Then I tried Automask on one frame example you have shared. Works well for me:

https://i.imgur.com/wyRJR25.png
Mask from Automask:
https://i.imgur.com/2s57pO4.png
Delogo:
https://i.imgur.com/DJBK2eT.png

Danette
26th November 2021, 15:02
I've searched this whole thread and except yours I found only one feedback about Automask

A quick search shows the same issue in post #125, where Automask apparently had the same problem. In post #126, you suggested that the poster edit the Automask image to improve it. I ran into the same issues and, rather than go through the Automask processing and subsequent editing, it made more sense, to me, to just create the mask manually.

No need to pursue this aspect further, as I think we are going in circles, needlessly, in doing so.


Can you generate and show a mask with Automask from video in that example you've posted, and one you made with editor?

I didn’t run Automask on one image/frame. I ran it on the entire video. There are three images in this link: https://postimg.cc/gallery/9TH71fG/627b6e3e

The script I used is this:

#InpaintLoc(Loc="514,370,-28,-30")
InpaintDelogo(Loc="514,370,-28,-30",Automask=1,mask="C:\Users\Main\Desktop\Capture\MTS Logo Templates\TV Land.bmp")
#InpaintDelogo(mask="C:\Users\Main\Desktop\Capture\MTS Logo Templates\TV Land.bmp", Loc="514,370,-28,-30", Mode="InPaint")

Running Automask on the video generated the mask labeled “BW Automask Mask” and you can see that the upper left part of the main logo is not masked. However, there are large areas to the right of the logo and below the logo that are erroneously masked. The result of using this mask on the video can be seen in the image labeled “BW Automask Results” where the logo is showing through as a result of that missing section where the upper left part of the main logo is not masked. The false masking, to the right and below the logo, will then cover non-logo parts of other frames in the video.

The image labeled “BW Editor Manual Mask” is the mask I created with my image editor and it works perfectly when used in InpaintDelogo processing. Note that this image is not a black base. It is what I would do with VDubs DeLogo, but using a white mask instead of red.

Again, don’t make adjustments for my sake. I am content making manual masks (it’s faster and better). However, if you want additional tests from me, I’ll be happy to help.

VoodooFX
26th November 2021, 16:30
A quick search shows the same issue in post #125, where Automask apparently had the same problem.
Automask is to create a mask for a logo not to some upscaled artifacts like there.

I ran it on the entire video.
So you have selected the wrong method for your task.
Are words from the manual not clear about this: "doesn't produce good results"?

Btw, in v2.0[WIP] there are new smart auto Analyze modes, actually I deleted all old Analyze code, the manual analysis modes too.
Dunno, maybe I need to return manual modes, hard to decide without checking stuff in practice.

EDIT:
OK, I decided to return them. :)
But as old manual and new auto Analysis stuff is not intercompatible then dunno when it will be released...

Danette
26th November 2021, 17:34
So you have selected the wrong method for your task.
Are words from the manual not clear about this: "doesn't produce good results"?

Btw, in v2.0[WIP] there are new smart auto Analyze modes, actually I deleted all old Analyze code, the manual analysis modes too.
Dunno, maybe I need to return manual modes, hard to decide without checking stuff in practice.

EDIT:
OK, I decided to return them. :)
But as old manual and new auto Analysis stuff is not intercompatible then dunno when it will be released...

Don’t do this simply because of my comments. As I said, I won’t be using Automask and others may prefer it as it is.

Yes, "doesn't produce good results" does mean something. It means it may or may not work. From my viewpoint, why spend the time with Automask when I can just make a manual mask, in a fraction of the time, that is guaranteed to work. Who knows, maybe the new smart auto Analyze modes would not be prone to this variability, but I just don’t see the value in it.

You have a great code, overall. By being able to get a good, simple, delogo function in Avisynth script, you've given us a great time savings over having to run it through Vdub. My suggestion is to not get hung-up on the Automask issue. I much prefer your earlier comments regarding the idea to incorporate all masks into one file or, maybe, incorporating what wonkey_monkey may be on the verge of delivering.

VoodooFX
4th December 2021, 22:16
Harder, Better, Faster, Stronger v2.0:


# Version 2.0 : 2021/12/04. AviSynth+ v3.7.1 or later & FrameSel plugin is required.
# New: Old Deblend delogo is superceded by the new superior one.
# New: Smart frames selection for analyze using "AnalyzeTh" & "NoBorderAt" parameters.
# New: "Automask" adapted to the new stuff and it doesn't reanalyze when "aMix" is adjusted.
# New: "Show" 7/8/9.
# Note: Old Deblend is saved as negative "Analyze",
# -3/-4 should be same as old, -1/-2 were augmented by the smart frames selection.


Advantages of new delogo will be mostly noticeable on damaged logos (E.g. overcompressed, re-re-re-encoded videos).
So here are some comparisons on such one. x3 upsized, no PP (except last one):

Top row: Original logo & rm_logo/InpaintFunc
Bottom row: InpaintDelogo old, InpaintDelogo v2.0 & InpaintDelogo v2.0 with default dPP=3, Interp=2

https://i.imgur.com/4txTAn3.png https://i.imgur.com/dAaf4hr.png
https://i.imgur.com/qHWMOXa.png https://i.imgur.com/jkp34HL.png https://i.imgur.com/VDheMF5.png

As there are less artifacts then maybe I'll lower PP defaults (btw, for anime Interp shouldn't be used, maybe maximum 1).

Some other before/after frames (no PP):

https://i.imgur.com/38O1t1c.png https://i.imgur.com/Kt4TZn1.png
https://i.imgur.com/ZJorBEY.png https://i.imgur.com/IGT3n3X.png

Old Automask & new Automask:
https://i.imgur.com/JAqC1d7.png https://i.imgur.com/SsFWCdx.png

And benchmarks (video: 720p , H264, 00:18:25):
Automask (old) - 00:01:50
Automask (v2.0) - 00:01:37

Analyze old - 00:03:36
Analyze (v2.0) - 00:02:52

Deblend old - 196 FPS
Deblend (v2.0) - 352 FPS

Happy delogo! ;)

VoodooFX
6th December 2021, 01:43
I was asked to make comparison to "lgd", so here it's: Left InpaintDelogo & right Makki's lgd:

https://i.imgur.com/jkp34HL.png https://i.imgur.com/ldOgPCb.png
https://i.imgur.com/ZJorBEY.png https://i.imgur.com/dg42T3r.png
https://i.imgur.com/IGT3n3X.png https://i.imgur.com/YYHYNSx.png


Good frames found (Threshold 30) & analysis time:
ID v2.0: 10643 frames - 00:02:52
LGD: 7647 frames - 00:05:02

Benchmark:
Deblend ID v2.0 - 352 FPS
Deblend LGD - 380 FPS


Looks almost same, InpaintDelogo has more precise the good frames search so it found more frames.

But, it's simple logo and Makki's delogo can do only simple logos, enough to move logo to the frame's border or letterbox and it fails to do proper analysis:

https://i.imgur.com/jkp34HL.png https://i.imgur.com/UfhjkFg.png

Forget about color and variable transparency logos with lgd. Here is InpaintDelogo v2.01 on my delogotest sample:

https://i.imgur.com/MYOiAWw.gif

Download DelogoTest video (https://drive.google.com/uc?export=download&id=1z-8NpTILUkKnjeAtV-sR66w9l0Z4FmRa) for delogo tests, and ID v2.01 command:
InpaintDelogo( mask="D:\mask.bmp", Automask=0, aMix=-1, Loc="10,16,-6,-20", Mode="Both", Analyze=3, Interp=0, oTune=-10)

VoodooFX
10th December 2021, 22:16
# Version 2.02 : 2021/12/10. Fixed: "Analyze=1" bug.
# +11% deblend speed-up.
# Tweaked "aMix". "Analyze=2" is default. Adaptive "AnalyzeTh" default [16 or 30].
# Don't search frames for analyse if 'txt' file is present and ReAnalyze=0.
# Version 2.01 : 2021/12/05. "Analyze" 3 option.

quochuyonnet
12th December 2021, 18:20
Could i have ver 1.48 link please? i'm using avisynth 2.60

VoodooFX
12th December 2021, 18:31
Could i have ver 1.48 link please? i'm using avisynth 2.60

All versions from v1.24 are on GitHub:

https://github.com/Purfview/InpaintDelogo/commits/main/InpaintDelogo.avsi

Two buttons at the right side there will bring you to "that" version.

quochuyonnet
12th December 2021, 19:49
Thank you for answer i've downloaded v1.48 avsi file.

Edit: I've install Gimport, but still can not call InpaintDelogo Function inside AvsPmod
LoadCPlugin("C:\Program Files (x86)\AviSynth\plugins\AVSInpaint.dll")
GImport("C:\Program Files (x86)\AviSynth\plugins\InpaintDelogo.avs")

Update: I'm able to use function by typed it manually in AvsPmod, I saw it did good with static logo, could InpaintDelogo help delogo which is moving/ has faded away slowly effect?

quochuyonnet
12th December 2021, 20:38
Do you've any idea to deal with this moving logo?
https://youtu.be/5ZKuJJaqCDE

VoodooFX
12th December 2021, 22:56
For parts where logo is static but "fades away" use "Inpaint" mode. For moving parts you can try one of dynamic methods.
Share sample of original video.

Inolga
13th December 2021, 15:55
Hi !

Thanks VoodooFX for you great work !

Version 1.48 was working good but every time I try to load the v2.02 with MeGUI, I have an error :

https://i.imgur.com/xdYxlg2.jpg

I have all the requirements, up to date :

https://i.imgur.com/GTS26se.jpg



I'm using ffms2 to load my source video

Thanks for your help

VoodooFX
13th December 2021, 17:10
Version 1.48 was working good but every time I try to load the v2.02 with MeGUI, I have an error :

I think that error is from v2.01.

Try AvS+ v3.7.1 test build 34 https://forum.doom9.org/showthread.php?p=1958925#post1958925

What is masktools2 version? Post your full script and the mask file.

quochuyonnet
13th December 2021, 17:21
this is original video which i've used for test delogo has moving and fades away effect.
https://youtu.be/sQvmLppMU_s

VoodooFX
13th December 2021, 17:33
this is original video which i've used for test delogo has moving and fades away effect.
https://youtu.be/sQvmLppMU_s
Anything uploaded to youtube is not original anymore and it looks cropped.

quochuyonnet
13th December 2021, 17:44
yes, it's only a small clip i've used for testing delogo has moving effect. Here is another host
https://ufile.io/ra46waxn
p/s: i've tried "dynamic mask" as a crop clip with resolution same as "Loc" area, but got "Crop: Destination width is 0 or less (C:\...Inpaintdelogo.avs, line 1296)" error.

StainlessS
13th December 2021, 18:22
"Crop: Destination width is 0 or less (C:\...Inpaintdelogo.avs, line 1296)" error.
I dont know what your crop numbers are, but see here:- https://forum.doom9.org/showthread.php?p=1893966#post1893966
for MakeLoc(), allows more flexible coords


Function MakeLoc(clip c,Int x, Int y, Int w, Int h) { # https://forum.doom9.org/showthread.php?p=1893966#post1893966
/*
Make Loc string for VoodooFX InPaintDelogo.
Input X and Y, where -ve, is relative to c.Width or c.Height, and are converted to +ve X and Y in result string.
Input W and H, where 0 or -ve, is relative c.Width or c.Height [as in Crop()],
Where +ve, are converted to -ve W and H in result string [as required by InPaintDelogo].
Allows to make Loc string programmatically using flexible coord system and not locked into hand editing Loc string.

ColorBars # 640,480
S=MakeLoc( 0, 0, 0, 0) # "0,0,-0,-0"
S=MakeLoc( 540, 380,-40,-40) # "540,380,-40,-40"
S=MakeLoc(-100,-100, 60, 60) # "540,380,-40,-40"
S=MakeLoc( 540, 380, 60, 60) # "540,380,-40,-40"
S=MakeLoc(-100,-100,-40,-40) # "540,380,-40,-40"
*/
c
# First, Ensure/Convert X,Y,W,H ALL +ve
x = (x >= 0) ? x : Width + x
y = (y >= 0) ? y : Height + y
w = (w > 0) ? w : Width - x + w
h = (h > 0) ? h : Height - y + h
# Check validity
Assert(0 <= x < Width ,String(x,"MakeLoc: 0 <= X(%.0f)") + String(Width ," < Width(%.0f)" ))
Assert(0 <= y < Height ,String(y,"MakeLoc: 0 <= Y(%.0f)") + String(Height ," < Height(%.0f)"))
Assert(1 <= w <= Width -x ,String(w,"MakeLoc: 1 <= W(%.0f)") + String(Width ," <= Width-X(%.0f") + String(x ," - %.0f)"))
Assert(1 <= h <= Height-y ,String(h,"MakeLoc: 1 <= H(%.0f)") + String(Height ," <= Height-Y(%.0f") + String(y ," - %.0f)"))
# Output string: +ve X,Y :: -ve W,H, Ensure all (even W=0 and H=0) flagged as -ve eg -0
return String(x,"%.0f") + String(y,",%.0f") + String(Abs(x+w-Width),",-%.0f") +String(Abs(y+h-Height),",-%.0f")
}

EDIT: To Reply 2 posts later,
our Left/Top/Width/Height coords patch is included from v1.13
OK, thanks.

VoodooFX
13th December 2021, 19:03
yes, it's only a small clip i've used for testing delogo has moving effect. Here is another host
https://ufile.io/ra46waxn

Here is script for v2.03 (for v1.48 you would need to change "128" to "1" at line 989):

o=LSMASHVideoSource("D:\logoorg.mp4")

c1 = o.Trim(0,2)
c2 = o.Trim(3,3).InpaintDelogo(Loc="0,0,-0,-0", Dynmask=2, Dyntune=42, DynInflate=3)
c3 = o.Trim(4,5).InpaintDelogo(Loc="0,0,-0,-0", Dynmask=2, Dyntune=45, DynInflate=3)
c4 = o.Trim(6,136).InpaintDelogo(Loc="0,0,-0,-0", Dynmask=2, Dyntune=50, DynInflate=2)
c5 = o.Trim(137,139).InpaintDelogo(Loc="0,0,-0,-0", Dynmask=2, Dyntune=20, DynInflate=2)

c1+c2+c3+c4+c5


Result:
https://i.imgur.com/wsUhYOc.gif
For 1 & 2 frames use image based mask[s].


p/s: i've tried "dynamic mask" as a crop clip with resolution same as "Loc" area, but got "Crop: Destination width is 0 or less (C:\...Inpaintdelogo.avs, line 1296)" error.

Post full script, try latest InpaintDelogo version.

VoodooFX
13th December 2021, 19:34
I dont know what your crop numbers are, but see here:- https://forum.doom9.org/showthread.php?p=1893966#post1893966
for MakeLoc(), allows more flexible coords

Your Left/Top/Width/Height coords patch is included from v1.13. ;)

Inolga
14th December 2021, 12:19
I think that error is from v2.01.

Try AvS+ v3.7.1 test build 34 https://forum.doom9.org/showthread.php?p=1958925#post1958925

What is masktools2 version? Post your full script and the mask file.

Thanks !

It seems that the problem is that MeGUI doesn't load automatically all the plugins in the MeGUI/tools/avisynth_plugin and MeGUI/tools/avs/plugins (the difference between these 2 folders is not clear to me...)

So I had to install the UN-portable version of Avisynth+ and then InPaint Delogo 2.02 is working :)

Any idea why MeGUI doesn't load automatically the plugins which are in MeGUI/plugins folders ?
Cause IMO, it's much more convenient to use the portable version of Avisynth+

VoodooFX
14th December 2021, 13:27
Any idea why MeGUI doesn't load automatically the plugins which are in MeGUI/plugins folders ?
Cause IMO, it's much more convenient to use the portable version of Avisynth+

Portable Avisynth+ can autoload plugins, but from installed Avisyth folders.
Now, after you've installed AvS+ and plugins to its folders, you can use MeGUI's portable version and it will autoload plugins (installed AvS version can be different).

That error looks like wrong plugin version loaded, not that it's not loaded [strange error, maybe some CUDA version of masktools?]:

https://i.imgur.com/xdYxlg2.jpg

StainlessS
14th December 2021, 13:36
the difference between these 2 folders is not clear to me...
So far as I know, MeGUI/tools/avisynth_plugin is used by standard MeGUI tools (those available by megui menus) and loaded by MeGUI when it knows they are required
for eg Deinterlace or whatever - dont think is intended as autoload plugs directory for whatever you put in there, only for builtin MeGUI functionality.

MeGUI/tools/avs/plugins, looks to be for external plugins that may once have been builtin avisynth filters, but were made external as seldom used.
[The plugs contained there are usually auto copied to Plugins directory when using standard Avisynth installer, eg DirectShowSource.dll].

General auto load of plugins is an Avisynth job, not MeGUI job, and apart from anything else, MeGUI does not set an autoload folder,
a portable eg USB stick installed MeGUI cannot really alter system registry to set the autoload folder. [usually done during Avisynth setup].

You might want to use Avs+ AddAutoloadDir(), but would need to use in every script, [set to MeGUI/tools/avs/plugins and copy your plugins there],
but I would find that more awkward than using system wide setup of Avisynth.
See:- http://avisynth.nl/index.php/AviSynth+#Plugin_Autoloader

Lastly, current Avs+ needs new Avs+ wrapper when used with MeGUI,
https://forum.doom9.org/showthread.php?p=1913117#post1913117

quochuyonnet
14th December 2021, 13:48
Thank you, it's worked perfectly when logo is brighter than background of clip. I've tried with background has higher brightness and result is the logo is still seeable
https://youtu.be/NNKqYhPCG04
This is original file without delogo
https://ufile.io/ajoiae88

Inolga
14th December 2021, 14:31
That error looks like wrong plugin version loaded, not that it's not loaded [strange error, maybe some CUDA version of masktools?]:

The weird thing is that I use the same version of masktools2.ddl (x86, 2.2.29) when using the "portable" version of avisynth (I get this error message), that the one I use with the normal "installed" version of avisynth (no error message). In the first case, when I manually load the plugin in my script, this error disappears but others appear (probably cause I need to manually load the other required plugins).

Portable Avisynth+ can autoload plugins, but from installed Avisyth folders.
Now, after you've installed AvS+ and plugins to its folders, you can use MeGUI's portable version and it will autoload plugins (installed AvS version can be different).

Thanks for your explanation. It is more convenient for me to use "portable" version of avisynth+ 2.7.1 into the MeGUI folder cause I already have avisynth 2.5 installed on my PC (with a 2.5 avisynth.dll file in the SysWOW64 folder). I need this 2.5 version to be on my PC ("system wide" setup) cause I use it within an installed MPC-HC and madVR configuration which calls for this 2.5 avisynth version in order to apply upscaling filters when I play films on my 4K TV.


So far as I know, MeGUI/tools/avisynth_plugin is used by standard MeGUI tools (those available by megui menus) and loaded by MeGUI when it knows they are required
for eg Deinterlace or whatever - dont think is intended as autoload plugs directory for whatever you put in there, only for builtin MeGUI functionality.

MeGUI/tools/avs/plugins, looks to be for external plugins that may once have been builtin avisynth filters, but were made external as seldom used.
[The plugs contained there are usually auto copied to Plugins directory when using standard Avisynth installer, eg DirectShowSource.dll].

General auto load of plugins is an Avisynth job, not MeGUI job, and apart from anything else, MeGUI does not set an autoload folder,
a portable eg USB stick installed MeGUI cannot really alter system registry to set the autoload folder. [usually done during Avisynth setup].

You might want to use Avs+ AddAutoloadDir(), but would need to use in every script, [set to MeGUI/tools/avs/plugins and copy your plugins there],
but I would find that more awkward than using system wide setup of Avisynth.
See:- http://avisynth.nl/index.php/AviSynth+#Plugin_Autoloader

Lastly, current Avs+ needs new Avs+ wrapper when used with MeGUI,
https://forum.doom9.org/showthread.php?p=1913117#post1913117


Thanks a lot for all these explanations ! I already tried this AddAutoloadDir() command in my script after I saw a post about it in other forum (videohelp I think) but it didn't work, plugins weren't loaded. I'll try again using the explanations in the link you provided :).

For AVS+ wrapper, I have already replaced the one in the MeGUI folder with the good one (1.0.217.2).

VoodooFX
14th December 2021, 16:08
Thank you, it's worked perfectly when logo is brighter than background of clip. I've tried with background has higher brightness and result is the logo is still seeable
https://youtu.be/NNKqYhPCG04
This is original file without delogo
https://ufile.io/ajoiae88

DynMask=2 is just simple method to be used where dynamic logo is brighter than background, and DynMask=3/4 methods for the subtitle like dynamic logos.
You can poke wonkey_monkey with your original samples there -> https://forum.doom9.org/showthread.php?p=1957958
And there is Animate filter-> http://avisynth.nl/index.php/Animate

As you are in luck with your video and have sample with most of the logo animation in dark background then you can construct dynamic mask and apply it on different parts of your video.
Example on the same[previous] sample:

o = LSMASHVideoSource("D:\logoorg.mp4")

m1 = o.Trim(3,3) .InpaintDelogo(Loc="0,0,-0,-0", DynMask=2, DynTune=42, DynInflate=3, Show=4)
m2 = o.Trim(4,5) .InpaintDelogo(Loc="0,0,-0,-0", DynMask=2, DynTune=45, DynInflate=3, Show=4)
m3 = o.Trim(6,136) .InpaintDelogo(Loc="0,0,-0,-0", DynMask=2, DynTune=50, DynInflate=2, Show=4)
m4 = o.Trim(137,139).InpaintDelogo(Loc="0,0,-0,-0", DynMask=2, DynTune=20, DynInflate=2, Show=4)
constructedDynmask = m1+m2+m3+m4

c1 = o.Trim(0,2)
c2 = o.Trim(3,139).InpaintDelogo(Loc="0,0,-0,-0", mask=constructedDynmask, DynMask=1)
c1+c2


It has same result as the script I posted before, but now you can apply "constructedDynmask" on different parts of your video.

You can even join-in the image based masks for frame 1 & 2 if you want, with something like that:

img1 = ImageReader("D:\mask1.bmp",0,0).ConvertToY8(matrix="PC.601").AssumeFPS(30)
img2 = ImageReader("D:\mask2.bmp",0,0).ConvertToY8(matrix="PC.601").AssumeFPS(30)
constructedDynmask2 = img1+img2+constructedDynmask.AssumeFPS(30)

VoodooFX
14th December 2021, 16:26
The weird thing is that I use the same version of masktools2.ddl (x86, 2.2.29) when using the "portable" version of avisynth (I get this error message), that the one I use with the normal "installed" version of avisynth (no error message). In the first case, when I manually load the plugin in my script, this error disappears but others appear (probably cause I need to manually load the other required plugins).



Thanks for your explanation. It is more convenient for me to use "portable" version of avisynth+ 2.7.1 into the MeGUI folder cause I already have avisynth 2.5 installed on my PC (with a 2.5 avisynth.dll file in the SysWOW64 folder). I need this 2.5 version to be on my PC ("system wide" setup) cause I use it within an installed MPC-HC and madVR configuration which calls for this 2.5 avisynth version in order to apply upscaling filets when I play films.

AvS v2.5 is veeery dated, can't you get madVR working with AvS+?
I've no idea what plugins madVR is using, maybe it's safe for you to copy AvS+ plugins to your AvS v2.5 folders.
And with this old AvS instalation you would need to load ImageSeq in your script [when using MeGUI's portable]:
Loadplugin("D:\MeGUI\tools\avs\plugins\ImageSeq.dll")

Inolga
14th December 2021, 17:55
AvS v2.5 is veeery dated, can't you get madVR working with AvS+?
I've no idea what plugins madVR is using, maybe it's safe for you to copy AvS+ plugins to your AvS v2.5 folders.
And with this old AvS instalation you would need to load ImageSeq in your script [when using MeGUI's portable]:
Loadplugin("D:\MeGUI\tools\avs\plugins\ImageSeq.dll")

Here are the avisynth plugins installed on my setup using MPC-HC + madVR (this one : https://www.kazcorporation.com/la-config-kaz=) :

https://images4.imagebam.com/47/4e/19/ME5LF4Y_o.JPG

https://images4.imagebam.com/db/7b/bb/ME5LETU_o.JPG

I tried to put avs+ plugins into this avs 2.5 plugins folder but now I have this error when I try to use Inpaint Delogo :

https://images4.imagebam.com/3e/5d/0a/ME5LEX3_o.JPG

From what I understand I guess it's because MeGUI now uses the 2.5 avisynth.dll file which is in SysWOW64. So I tried to replace this file with the 2.7.1 version, but now I have this error when playing my video :

https://images4.imagebam.com/ff/a3/58/ME5LF55_o.JPG

So I'm not sure that my video playing setup can coexist with Inpaint Delogo. So I guess I'm forced to find a way to use Inpaint Delogo with a portable avisynth+, isn't it?

VoodooFX
14th December 2021, 18:29
It's v3.7.1, not v2.7.1.
To get info about your AvS installation and plugins use AVSMeter (https://forum.doom9.org/showthread.php?t=174797): "Avsmeter.exe -avsinfo".
You should run MeGUI with portable option enabled in settings, and don't replace Avisynth files in non portable folders.
About MadVR you can ask there: https://forum.doom9.org/showthread.php?t=146228

Inolga
14th December 2021, 20:48
It's v3.7.1, not v2.7.1.
To get info about your AvS installation and plugins use AVSMeter (https://forum.doom9.org/showthread.php?t=174797): "Avsmeter.exe -avsinfo".
You should run MeGUI with portable option enabled in settings, and don't replace Avisyth files in non portable folders.
About MadVR you can ask there: https://forum.doom9.org/showthread.php?t=146228

Yes I mean 3.7.1 sorry
Ok, I'll continue to find a way, thanks again for your help !

VoodooFX
14th December 2021, 21:35
Post Avsmeter info, post your full script, then we can tell what you are doing there.

quochuyonnet
15th December 2021, 05:19
Yes, i've given this case to wonkey_monkey for his testing.
Thank you for a useful way although constructedDynmask is not perfect in some circumstances. In this case i've tested KillBlobs=7 with Dynmask=2, Dyntune=150 giving a better result.

VoodooFX
15th December 2021, 09:11
Thank you for a useful way although constructedDynmask is not perfect in some circumstances.
I guess that's because duplicates in your video. 30 FPS is weird fps for video. Try to dedupe first before delogo.

coolgit
15th December 2021, 10:25
Inolga, I use MadVR and the latest avisynth+ and no issues at all. Works as intended. Try installing MadVR again and follow the quirky instructions without any deviation.

Inolga
22nd December 2021, 17:33
I finally managed to get the last portable version of avisynth working in MeGUI with last version of Inpaint Delogo, while the 2.5 avisynth version is still installed on my PC for MadVR.

To get it working, I added these two line at the top of my script :

ClearAutoloadDirs()
AddAutoloadDir("C:\Users\***\Desktop\MeGUI\tools\avs\plugins")

Thanks again for your precious help !

katzenjoghurt
29th December 2021, 22:16
Hey. :) This new version seems to work much better for me than last time, when I tried it with inpaint and UHD material. *thumbsup*

But I’m still struggling with getting Deblend to… well deblend in all areas.
The logo disappears well on a dark scene or on white background… but on colored backgrounds it’s still well visible/readable.
Well… actually it seems to matter which part of the video you analyze. If you do the analyze step on a certain section it may blend well there… but worse with other backgrounds.
I don’t know how it works internally but from a naïve view it feels like some more sophisticated color mapping could do wonders. Feels like there’s just not enough information to adapt to too many different backgrounds. But probably that’s nonsense.

Anyway… is there some promising way to tweak this?
dPP seemed to help a lot to make the deblended logo adapt to the color tones of different backgrounds - at the cost of losing most details due to blurring.

Before that I just did the basic steps… (out of my head):
Analyze with:
InpaintDelogo(mask="C:\Mask.bmp", Loc="…", mode= "Deblend", Automask=1, Analyze=2)
Deblend with:
InpaintDelogo(mask="C:\Mask.bmp", Loc="…", mode= "Deblend")


Btw… I guess there’s a major thing I didn’t understand yet:
As the doc says Automask would only work with Analyze=2, when would I ever use Analyze=1 then?
Why would I do an analyze pass without creating an automask? :confused:

VoodooFX
30th December 2021, 10:37
Hey. :) This new version seems to work much better for me than last time, when I tried it with inpaint and UHD material. *thumbsup*
But since your last post there is nothing changed in Inpaint mode that would visually impact it. Can you post comparison examples what is "better" now?

But I’m still struggling with getting Deblend to… well deblend in all areas.
The logo disappears well on a dark scene or on white background… but on colored backgrounds it’s still well visible/readable.
Well… actually it seems to matter which part of the video you analyze.
Without samples of video and script I can't help you. Maybe video is overcompressed + logo is hardly transparent, maybe you are doing something wrong.
You should analyze whole video where logo is, not some parts.

Btw… I guess there’s a major thing I didn’t understand yet:
As the doc says Automask would only work with Analyze=2, when would I ever use Analyze=1 then?
Why would I do an analyze pass without creating an automask? :confused:

Analyze when you create the base mask [with Automask=1] and Analyze for actual delogo with Deblend does the two different things, for Deblend it creates Alpha/Color masks.
Analyze=2 is default, no need to add it to a script then.
Btw, Analyze options are the different frame selection methods, and if you ran same option before with Automask=1 then the frame selection result is reused when Analyze runs again for Alpha/Color masks.
Analyze=1 should be more precise, but usually you won't see a difference, in some rare cases it can be helpful.

katzenjoghurt
30th December 2021, 15:33
But since your last post there is nothing changed in Inpaint mode that would visually impact it. Can you post comparison examples what is "better" now?


Then maybe I'm just lucky. I just don't see that "emboss" like effect anymore when inpainting logos in UHD clips that was plagueing me here (https://forum.doom9.org/showthread.php?p=1941684#post1941684).
I'd need to recheck with those clips I posted.


Without samples of video and script I can't help you. Maybe video is overcompressed + logo is hardly transparent, maybe you are doing something wrong.
You should analyze whole video where logo is, not some parts.


Ok... here's a test video.
https://1drv.ms/v/s!ArUJrXgYajLogqYAv7D7TBrryU1Ivw?e=mF1wgP

Area I chose for the mask:
https://i.ibb.co/gRy9kbj/Bild-2021-12-30-151421.png (https://imgbb.com/)

Logo mask (only cropped the relevant upper right part here for this post)
https://i.ibb.co/Lx6HXkC/Bild-2021-12-30-151559.png (https://imgbb.com/)

Result:
https://i.ibb.co/DRP7SHj/Bild-2021-12-30-153035.png (https://imgbb.com/)
https://i.ibb.co/pQHtt4F/Bild-2021-12-30-152957.png (https://imgbb.com/)
https://i.ibb.co/Bgc1JSD/Bild-2021-12-30-152522.png (https://imgbb.com/)
https://i.ibb.co/ng2q3ZX/Bild-2021-12-30-152600.png (https://imgbb.com/)
https://i.ibb.co/k6VPynT/Bild-2021-12-30-152634.png (https://imgbb.com/)
https://i.ibb.co/FXTfjWD/Bild-2021-12-30-152703.png (https://imgbb.com/)

Invoked with no additional params.
1) Create Mask:
InpaintDelogo(mask="V:\Logos\UHD-Test.bmp", Loc="3366,50,-110,-1934", Mode="Deblend", Automask=1)
2) Deblend:
InpaintDelogo(mask="V:\Logos\UHD-Test.bmp", Loc="3366,50,-110,-1934", Mode="Deblend", Automask=0)



Analyze when you create the base mask [with Automask=1] and Analyze for actual delogo with Deblend does the two different things, for Deblend it creates Alpha/Color masks.
Analyze=2 is default, no need to add it to a script then.
Btw, Analyze options are the different frame selection methods, and if you ran same option before with Automask=1 then the frame selection result is reused when Analyze runs again for Alpha/Color masks.
Analyze=1 should be more precise, but usually you won't see a difference, in some rare cases it can be helpful.

Ahhh.
Okay... so Analyze = 1 may be used for the (first) deblend run then. Thx!

VoodooFX
30th December 2021, 17:53
Your video has color matrix BT.709 instead of BT.2020, maybe it has to do something with the problem, I dunno, maybe original blending is just damaged here.

EDIT:
Your sample looks like re-encode, share only original video.

Danette
6th January 2022, 17:03
Is there any chance of getting the 2.x versions to work with Avisynth+ 3.7.0? Not only am I concerned about the previously reported MeGUI problem with 2.x, but the 2.x versions do not seem to work in AvsPmod (probably due to the use of 3.7.0). AvsPmod also no longer functions when using Prefetch with most Avisynth+ 3.7.1 versions, which is another reason for me to not use Avisynth+ above 3.7.0.

VoodooFX
6th January 2022, 18:53
What MeGUI problem?
Try older AvsPmod till it is fixed, or 32bit one.

Danette
6th January 2022, 19:18
Looks like that MeGUI problem was assigned to the portable Avisynth+ version, which I don't use. However, I installed Avisynth+ 3.7.1, after reading that post, and that's when I ran into the InpaintDelogo/Prefetch AvsPmod problem. I think I will have to wait for the AvsPmod problem to be fixed (if it is), as I am already using an older 32-bit version of it (2.7.0.0). In the meantime, InpaintDelogo 1.48 is certainly fully acceptable, from my perspective.

puregreen
8th February 2022, 04:27
Trying to deblend a logo with my manually created mask using the following command:

InpaintDelogo( mask="C:\path\to\LogoMask3840x2160pBW.bmp", Automask=0, Loc="0,0,-0,-0", Analyze=3, Mode="Deblend")

but the result is rather weird:

https://i.ibb.co/NxFWNc3/Screenshot-1.png (https://imgbb.com/)

What parameters should I adjust?

Source video: https://filetransfer.io/data-package/jcs1FMaL#link
Mask: https://filetransfer.io/data-package/EUIMIWSJ#link

VoodooFX
8th February 2022, 11:00
That video is just 12 seconds of static scene where logo is not in solid background. There is nothing to build a deblending mask from.

You need at least one frame with logo in dark solid background and one frame with logo in bright solid background.
Or you need much longer video than this to try anything.

EDIT:
Actually, "Analyze=-4" can create the deblend masks from one frame with logo in dark solid background.

VoodooFX
8th February 2022, 11:25
Inpaint doesn't look bad, if you can find good inpainting settings for that big "A" at the left.

Downscaled example:
https://i.imgur.com/Rp8DkkQ.jpeg
https://i.imgur.com/K8MWNXz.jpeg

puregreen
9th February 2022, 01:18
That video is just 12 seconds of static scene where logo is not in solid background. There is nothing to build a deblending mask from.

You need at least one frame with logo in dark solid background and one frame with logo in bright solid background.
Or you need much longer video than this to try anything.

I thought all I need is a black and white (logo in white) mask and then it can be used for all other videos of the same frame size. That's why I made that mask (https://filetransfer.io/data-package/EUIMIWSJ#link) from another video where the logo was on solid black background. So... I was completely wrong? I guess I just don't quite understand how deblending works then :(

VoodooFX
9th February 2022, 06:52
I thought all I need is a black and white (logo in white) mask and then it can be used for all other videos of the same frame size. That's why I made that mask (https://filetransfer.io/data-package/EUIMIWSJ#link) from another video where the logo was on solid black background. So... I was completely wrong? I guess I just don't quite understand how deblending works then :(

Black and white mask is just a basemask, when you have it then "Analyze" runs to create Alpha/Color deblend masks, and that A/C masks filename would look like this:
"LogoMask3840x2160pBW.bmp_InpaintDelogo2_1010-900-990-900_A3.ebmp".
Basemask and deblend masks can be reused on other videos with same logo.

Basemask is enough only for "Inpaint" mode.

VoodooFX
9th February 2022, 07:48
from another video where the logo was on solid black background.

You can try old Deblend 'manual' method[s] on that "another video", those methods produce lower quality deblend but don't need many frames to analyze, actually "Analyze=-4" can create the deblend masks from one frame.

Try this [replace '000' with proper frame number]:
InpaintDelogo( mask="C:\LogoMask3840x2160pBW.bmp", Loc="1010,900,-990,-900", Analyze=-4, FrB=000, Mode="Deblend")

And for the example above you can finetune these parameters [here with defaults]:
Interp=2, dPP=3, Inflate=1 [These are like postprocess effects]
FrS=0, Deep=3 [These influence the deblend masks creation]

If you want to compare the deblend masks/methods or see a pure deblend effect, then turn off "Interp" and "dPP".

PS:
Another possibility is to join hundreds of those videos in Avisynth and create the deblend masks from that. :)

puregreen
10th February 2022, 02:44
Basemask and deblend masks can be reused on other videos of the same frame size and same logo.

How to re-use them? If I set Analyze to 0, I get the "File 'Script.avs' does not have a video stream" error... Or if the files are present, it won't re-analyze anything even if analyze parameters are set?

puregreen
10th February 2022, 03:30
You can try old Deblend 'manual' method[s] on that "another video", those methods produce lower quality deblend but don't need many frames to analyze, actually "Analyze=-4" can create the deblend masks from one frame.

Try this [replace '000' with proper frame number]:
InpaintDelogo( mask="C:\LogoMask3840x2160pBW.bmp", Loc="1010,900,-990,-900", Analyze=-4, FrB=000, Mode="Deblend")

And for the example above you can finetune these parameters [here with defaults]:
Interp=2, dPP=3, Inflate=1 [These are like postprocess effects]
FrS=0, Deep=3 [These influence the deblend masks creation]

If you want to compare the deblend masks/methods or see a pure deblend effect, then turn off "Interp" and "dPP".

PS:
Another possibility is to join hundreds of those videos in Avisynth and create the deblend masks from that. :)

Ohh... Looks like the logo has shadows :scared: At least it's visible on a solid white background but more likely it's there on a dark one too, it's just hard to notice it.

Here's a video with both black (frame 001) and white (frame 055) background: https://filetransfer.io/data-package/wHl0HYcU#link

VoodooFX
10th February 2022, 04:26
How to re-use them? If I set Analyze to 0, I get the "File 'Script.avs' does not have a video stream" error... Or if the files are present, it won't re-analyze anything even if analyze parameters are set?

Just change video to another in script and thats it.
There is no Analyze=0 option for user to select, looks like that after v2.00 I forgot to add error on it [EDIT: I didn't forgot, the error assert is there], but from the manual it should be clear.
Why you need to re-analyze if you want re-use same masks?

PS
And you are selecting non existent "0" option to "not-analyze" when you want to analyze? I'm a bit confused. :)

VoodooFX
10th February 2022, 18:48
Ohh... Looks like the logo has shadows :scared: At least it's visible on a solid white background but more likely it's there on a dark one too, it's just hard to notice it.

Here's a video with both black (frame 001) and white (frame 055) background: https://filetransfer.io/data-package/wHl0HYcU#link

Didn't had time to look at it in the morning.
I see there are good white frames, so use Analyze=-3 method.
I've removed logos with such faint shadows before, and there are bunch of settings to deal with them. Most likely that Automask won't pick up very transparent parts like this shadow, so you need to create a base mask in photoshop including that shadow too.

PS:
Maybe later this evening I'll give this video a try.

puregreen
11th February 2022, 01:50
And you are selecting non existent "0" option to "not-analyze" when you want to analyze? I'm a bit confused. :)

No, I thought setting it to "0" would protect the existing ebmp files from re-analyzing but turned out it's not needed because it doesn't re-analyze if the files already exist :-)

I'm getting pretty good results after generating a deblending mask from the black frames. The only thing left is dealing with the shadow somehow...

VoodooFX
11th February 2022, 02:24
I'm getting pretty good results after generating a deblending mask from the black frames. The only thing left is dealing with the shadow somehow...
I've no idea what you are doing there, post your script and basemask.
I wrote one post above yours what to do...

puregreen
11th February 2022, 03:23
I've no idea what you are doing there, post your script and basemask.
I wrote one post above yours what to do...

I did this:

InpaintDelogo( mask="C:\LogoMask3840x2160pBW.bmp", Loc="1010,900,-990,-900", Analyze=-4, FrB=001, Mode="Deblend")

It works fine on the parts where the shadow is not visible.

I tried making a base mask with the shadow: https://filetransfer.io/data-package/3kaMyxIQ#link

...and tried using it with the script:

InpaintDelogo( mask="C:\LogoMask3840x2160pShadow.bmp", Loc="1010,900,-990,-900", Analyze=-3, FrB=001, FrW=055, Mode="Deblend")

...but it doesn't help with the shadow.

VoodooFX
11th February 2022, 03:34
I tried making a base mask with the shadow: https://filetransfer.io/data-package/3kaMyxIQ#link
It's not a black/white mask. Whole logo must be white.

EDIT:
FrB=001, FrW=055.
You don't need to add zeros in front of numbers.

VoodooFX
11th February 2022, 14:39
Did you re-encoded those videos in your posts?
Btw, there is the error assert for "Analyze=0", probably because of soft you use you don't see Avisynth errors.

Here I tried to delogo, shadow is perfectly deblended, good result, no need for any PP:

InpaintDelogo( mask="D:\Mask.bmp", Loc="920,810,-910,-820", Analyze=-3, FrB=0, FrW=51, FrS=1, Deep=1, Interp=0, dPP=0, Mode="Deblend")

Mask:
https://thumbs2.imgbox.com/c7/34/Tb5LH429_t.png (https://imgbox.com/Tb5LH429)

Before:
https://thumbs2.imgbox.com/04/f8/wQqocM2G_t.png (https://imgbox.com/wQqocM2G)
After:
https://thumbs2.imgbox.com/2b/c8/ekZgd6MQ_t.png (https://imgbox.com/ekZgd6MQ)

Before:
https://thumbs2.imgbox.com/62/30/nIJPsB9K_t.jpg (https://imgbox.com/nIJPsB9K)
After:
https://thumbs2.imgbox.com/01/4b/7EH2W8R9_t.jpg (https://imgbox.com/7EH2W8R9)

EDIT:
I was about to test Makki's delogo, but I remembered that there you can't create lgd from few frames...

puregreen
12th February 2022, 02:14
Wow, that's perfect :eek: Thank you!

Did you re-encoded those videos in your posts?

No, they are untouched.

puregreen
12th February 2022, 04:05
What if I created a deblending mask and want to use it on a video where the logo is the same but shifted a little bit?

For example, here's my base mask: https://filetransfer.io/data-package/QxGcwH8N#link

Here's a video I used to generate deblending mask from: https://filetransfer.io/data-package/mjjRj0qE#link

InpaintDelogo( mask="C:\LogoMask596x336p.png", Loc="136,194,-136,-88", Analyze=3, FrB=120, FrW=0, FrS=1, Deep=1, Interp=0, dPP=0, Mode="Deblend")

And let's say I want to use it on this video: https://filetransfer.io/data-package/dzWZCyxL#link

But the logo here is shifted by about 6 px down so the same deblending mask doesn't quite work... Is there a way to make it work? Or the only way is to make a deblending mask from a video where the logo is located at the exact same position?

VoodooFX
12th February 2022, 18:10
What if I created a deblending mask and want to use it on a video where the logo is the same but shifted...

1) What is this mask, and it doesn't even fit in your selected Loc, read in the manual about Loc parameter:
https://i.imgur.com/XY4dqnR.png

2) "Analyze=3, FrB=120, FrW=0, FrS=1" <- manual frame selection doesn't work with positive Analyze.


So, select proper Loc for this Shutterstock, create proper basemask and deblend masks with 1053334574 clip:
InpaintDelogo( mask="C:\1053334574.bmp", Loc="114,174,-112,-68", Analyze=-3, FrB=76, FrW=227, FrS=3, Deep=1, Mode="Deblend", Automask=1, aMix=0)
https://i.imgur.com/tt2czTJ.png


In 1053531500 clip the logo is shifted exactly 4 pixels up, so edit the basemask file with Photoshop and move logo up.
A/C deblend masks in ebmp are not stored in full frame dimension, only Loc area, so if you keep dimensions of the Loc area the same then deblend masks fit (they are 'moving' when you change Loc).
[If logo shifted by non-mod2 distance, then you would need to shift that one pixel inside ebmp]

About Loc. You can use "StainlessS"s coords, they are easier to grasp when you are 'moving' area inside frame.
"114,174,-112,-68" would be "114,174,370,94".
So changing "114,174,370,94" -> "114,170,370,94" would move area 4 pixels up.
Remember that "StainlessS"s coords in ebmp filename are converted back to "VoodooFX" coords format [actually they are "VDub" coords]

A/C deblend masks ebmp file is seen and reused if filename corresponds to the parameters in use.
If you don't get idea behind how ebmp file is named just by looking at it then maybe this will help:
https://forum.doom9.org/showthread.php?p=1948676#post1948676

RESULTS:

InpaintDelogo( mask="C:\1053334574.bmp", Loc="114,174,-112,-68", Analyze=-3, FrB=76, FrW=227, FrS=3, Deep=1, Interp=0, dPP=0, Mode="Deblend")
Before:
https://i.imgur.com/H3b7U8L.png
After:
https://i.imgur.com/TEBYmc3.png

InpaintDelogo( mask="C:\1053531500.bmp", Loc="114,170,370,94", Analyze=-3, FrB=76, FrW=227, FrS=3, Deep=1, Interp=0, dPP=0, Mode="Deblend")
Before:
https://i.imgur.com/NIKhoAq.png
After:
https://i.imgur.com/Px3zMHO.png

In 1053531500 clip the logo is damaged by compression on some frames and some remnants of logo are there, you can try "dPP" and "Interp" parameters, they are for hiding artifacts, but they have their own side effects.

VoodooFX
4th April 2022, 23:21
Thanks to the new feature in Masktools2 v2.2.30 by @pinterf there is no more glitches with "DynMask=4" on SD videos.

# Version 2.05 : 2022/04/04. Masktools2 v2.2.30 or later is required.
# Tweaked: "DynMask=4" and positive "DynMaskUp", should be a bit faster and no more glitches.
# New: "DynLocUp" [Experimental WIP parameter for tests].

Guilbert
30th April 2022, 17:11
Hi,

I can't find the correct settings to get proper subtitles with this video: https://mega.nz/file/sgMDyThQ#B0l4VOlDIR4HKW-5a5hFv03wHTUYK3ZcLWmgWBQElpQ (sample)

For now, my script looks like that:
LWLibavVideoSource("")
InpaintDelogo(Loc="200,570,-200,-60", Show=4, DynMask=3, DynTune=218, DynMask4H=200, DynMaskUp=2, Extract=1, ImgDir="")

BTW, I use the latest version of InpaintDelogo (2.09).

Thank you for your help!

VoodooFX
30th April 2022, 17:29
Hi,

I can't find the correct settings to get proper subtitles with this video: https://mega.nz/file/sgMDyThQ#B0l4VOlDIR4HKW-5a5hFv03wHTUYK3ZcLWmgWBQElpQ (sample)

Is your sample a record/re-encode of original video? If yes then cut a sample from original video, and longer, maybe ~15 mins.

manono
1st May 2022, 08:26
Hi,

What is the last version for AviSynth 2.60? Is it Version 1.48? And where can I get it?

VoodooFX
1st May 2022, 09:00
Hi,

What is the last version for AviSynth 2.60? Is it Version 1.48? And where can I get it?

Last compatible with AvS 2.6 is v1.48 (would need to be imported with GImport), GImport not needed for v1.33, but "Show=1" is broken there.
Actually, if you just want to inpaint some logo then all versions are good enough.

You can download from GitHub, press "InpaintDelogo.avsi" there, then "History", you'll see different versions, a second button from the right side opens 'that' version.

VoodooFX
2nd May 2022, 15:26
# Version 2.10 : 2022/05/02. Added auto generation of the dynamic mask by color (aka "DynMask=5"/"DynColor").
# New: "DynColor", "DynColorTol", "DynColorInf", "Show=10".
# This dynamic mask by color can pre-patch video for other "DynMask" methods.

Thread that prompted this update, and video samples: Remove timestamp (https://forum.videohelp.com/threads/405550-Remove-timestamp#post2655547).

Few screens for comparisons:
1) Original
2) DynMask2
3) DynMask3 [Actually, DynMask3 could generate an accurate mask, except for the last digit, read in the link above]
4) DynMask5
5) DynMask2 pre-patched with DynMask5
6) DynMask3 pre-patched with DynMask5
7) Result of the mask from 6th row.

https://i.imgur.com/q8dFIYi.png https://i.imgur.com/89L5aCI.png


v=LWLibAvVideoSource("D:\Pachacamac E.MP4")
x=v.crop(4,990,-1380,-4)

o1=v.InpaintDelogo(Loc="4,990,-1380,-4", Show=4, DynMask=2, DynTune=150)
o2=v.InpaintDelogo(Loc="4,990,-1380,-4", Show=4, DynMask=3, DynTune=150, Dyn3Seq=54)
o3=v.InpaintDelogo(Loc="4,990,-1380,-4", Show=4, DynMask=5, DynColor=$FFB900)
o4=v.InpaintDelogo(Loc="4,990,-1380,-4", Show=4, DynMask=2, DynTune=150, DynColor=$FFB900)
o5=v.InpaintDelogo(Loc="4,990,-1380,-4", Show=4, DynMask=3, DynTune=150, DynColor=$FFB900, Dyn3Seq=54)
o6=v.InpaintDelogo(Loc="4,990,-1380,-4", Show=0, DynMask=3, DynTune=150, DynColor=$FFB900, Dyn3Seq=54, DynInflate=2).crop(4,990,-1380,-4)

Stackvertical(
\ x,
\ o1.ConvertToYV12().AddBorders(0,2,0,0,$F0F080),
\ o2.ConvertToYV12().AddBorders(0,2,0,0,$F0F080),
\ o3.ConvertToYV12().AddBorders(0,2,0,0,$F0F080),
\ o4.ConvertToYV12().AddBorders(0,2,0,0,$F0F080),
\ o5.ConvertToYV12().AddBorders(0,2,0,0,$F0F080),
\ o6.ConvertToYV12().AddBorders(0,2,0,0,$F0F080))


PS:
@Guilbert, I didn't forgot you. I'll check your video today.

Selur
2nd May 2022, 16:26
Nice. (this and missing a stable RemoveDirt are the only real reasons I sill have Avisynth on my system didn't switch completely to Vapoursynth)

VoodooFX
2nd May 2022, 22:53
Hi,
I can't find the correct settings to get proper subtitles with this video: https://mega.nz/file/sgMDyThQ#B0l4VOlDIR4HKW-5a5hFv03wHTUYK3ZcLWmgWBQElpQ (sample)

For now, my script looks like that:
InpaintDelogo(Loc="200,570,-200,-60", Show=4, DynMask=3, DynTune=218, DynMask4H=200, DynMaskUp=2, Extract=1, ImgDir="")

I don't see much problems in your sample sequence, just lower DynTune to 190 to make extracted subs better. ;)
But I see problems at other places .

About your parameters:
[I]DynMask4H is only for DynMask=4, so it does nothing here.
DynMaskUp was meant for HD videos and DynMask=4, for SD videos or small subs use DynLocUp.

Halo around subs is too faint to make it useful, later I'll check if anything can be done about it.

By looking at sequence you shared, I came up with these parameters [dunno if it's worse or better at other places, let me know how it's]:
InpaintDelogo(Loc="300,560,-300,-50", Show=4, DynMask=3, DynTune=190, Dyn3Seq=25, KillBlobs=5, KillNoise=5, RePass=1, DynLocUp=2)

Subs extractor defaults are tuned for a good mask, where mask doesn't have so many artifacts.
If mask has many artifacts then you can:
Lower CorrTh, to ~0.65 - 0.75 [would be less wrong splits]
Lower SubTune, to 200 - 220.
Lower SubMinDur [so wrong splits would be extracted]
Use SubSuspect.


EDIT:

I tried VSF for comparison, sadly it fails, so no incentive to do better, maybe ~perfect mask is not possible from these subs...

On your sample sequence (38265 - 38861) VSF fails a lot, where InpaintDelogo has no problems. One extracted sub for example:

VSF:
https://i.imgur.com/PkNNarp.png
InpaintDelogo :
https://i.imgur.com/c61oscH.png


On where I spotted "problems at other places" (6752 - 7269) both fails a lot. One extracted sub for example:

VSF:
https://i.imgur.com/NW2qRaE.png
InpaintDelogo :
https://i.imgur.com/q2oHCHP.png

manono
4th May 2022, 04:00
You can download from GitHub, press "InpaintDelogo.avsi" there, then "History", you'll see different versions, a second button from the right side opens 'that' version.
Thanks a lot! I tried some of the more recent versions first but couldn't get them going. Then I downloaded V. 1.48 and set it up. I used "Inpaint" Mode to get rid of the logo but, of course, it left behind the blurs during moving backgrounds.

Then, based on your tips further up the page, I decided to try to get the "Both" Mode going as the logo wasn't completely opaque. And ... it worked! No sign at all of the logo any longer. I'm very pleased and have you to thank for it, VoodooFX.

VoodooFX
4th May 2022, 06:33
Thanks a lot! I tried some of the more recent versions first but couldn't get them going. Then I downloaded V. 1.48 and set it up. I used "Inpaint" Mode to get rid of the logo but, of course, it left behind the blurs during moving backgrounds.

Then, based on your tips further up the page, I decided to try to get the "Both" Mode going as the logo wasn't completely opaque. And ... it worked! No sign at all of the logo any longer. I'm very pleased and have you to thank for it, VoodooFX.
Finally you moved to proper logo deblending from simple inpaintings. [or was it some other guy?] :)

So it wasn't AvS+ issue? Why didn't you ask for help then?
For not Inpaint mode you definitely want to use latest version, other modes progressed (https://forum.doom9.org/showthread.php?p=1958556#post1958556) a lot.

You should use Deblend for non-opaque logos, Both is meant for other things and can have unpredictable side effects if you use it instead of Deblend.

Post issues you had, full avs script, frame sample from video and we'll solve it.

Guilbert
5th May 2022, 10:13
Thanks a lot, VoodooFX!

(I'll test these parameters next weekend and keep you in touch.)

VoodooFX
5th May 2022, 22:41
Thanks a lot, VoodooFX!
(I'll test these parameters next week-end and keep you in touch.)

I quick looked what can be done with tcanny edge masking, I think it can replace positive KillBlobs and RePass, and it's faster.

KillBlobs and RePass:
https://i.imgur.com/q2oHCHP.png
new tcanny stuff:
https://i.imgur.com/RcUolOT.png

And in general there are less bad splits and less some other artifacts with tcanny.

EDIT:
Need to investigate what Dogway's masks are doing...
Maybe someone knows magic already how to isolate letters inside this halo precisely [from the sample below]?

https://i.imgur.com/goxj4KB.png

VoodooFX
7th May 2022, 16:41
...
Masking with "new tcanny stuff": 204 FPS
Masking with KillBlobs/RePass: 91 FPS

Dunno when I'll have time to release a new version, so here is the mask: https://we.tl/t-MjgKuwhWWn

Used Dyn3Seq=24, [I checked and found shortest sub is 24 frames]

Took ~7 mins to encode the mask, and ~3 mins to extract images with: SubsMask2Img(ImgDir="D:\test", SubMinDur=6, SubSuspect=23)

https://i.imgur.com/OGDHlPl.png

Guilbert
8th May 2022, 13:17
Wow, that's a nice improvement!

I use these parameters for this show, now:

InpaintDelogo(Loc="300,560,-300,-50", Show=4, DynMask=3, DynTune=190, Dyn3Seq=24, KillBlobs=5, KillNoise=5, RePass=1, DynLocUp=2, CorrTh=0.75, SubTune=220)

It took me only 15-20 minutes to OCR and edit with Tesseract 5.0.1. Can't wait to test the next release with the "new tcanny stuff", then. :)

:thanks:

VoodooFX
14th May 2022, 22:53
# Version 2.12 : 2022/05/14. Added generation of the dynamic mask by gradient magnitude map (aka "DynMask=7"/"DynTEdge").
# New: "DynTEdge", "DynTEdgeThY", "DynTEdgeInf", "DynTuneInf", Show=10, Show=11.
# vsTEdgeMask plugin is required.
# Version 2.11 : 2022/05/13. Rewrite: "DynColor" ~30%-300% faster. New: "DynMask=6/"DynTune". Removed: "Show=10".

@Guilbert
I used these parameters to get the mask in my previous post:
InpaintDelogo(Loc="300,560,-300,-50", Show=4, DynMask=3, Dyn3Seq=24, DynTune=190, DynTEdge=1, DynTEdgeThY=20, DynTEdgeInf=2, DynLocUp=2)

VoodooFX
21st May 2022, 14:12
Improved subs extraction: ~90% reduction of non-sub images.

# Version 2.13 : 2022/05/21. SubsMask2Img: Added average luma check to catch non-sub images.
# New: "SubMinLuma", "SubSusLuma".
# Renamed: "SubSuspect" to "SubSusDur".

VoodooFX
23rd May 2022, 02:11
# Version 2.14 : 2022/05/22. SubsMask2Img: New option to extract raw non-binarized images.
# Enabled by "Extract=2" in InpaintDelogo() or "Raw" in SubsMask2Img().
# New: "Raw", "RawAvr".

Should be better than VSF's raw images, as I added averaging for raw images, that should increase OCR accuracy [it's enabled by default].

For example averaged raw sub image:
https://i.imgur.com/A6GfTob.png

Not averaged raw sub image:
https://i.imgur.com/mk7suu9.png



The feature request:
Chinese-like characters are not well supported by tesseract or any other softwares. It would be nice to use paid Baidu OCR api on those languages. Since it's an enterprise solution, they can handle hardsub detection a lot better than custom masks, more often than not, raw image will yield better results.

He sent me few examples of Baidu OCR:

Sub image: https://i.imgur.com/goxj4KB.png

https://i.imgur.com/bvloEeS.png

Sub image: https://i.imgur.com/u3nzosV.png [not raw, just to check how it's better than Tesseract]

https://i.imgur.com/DUgthMw.png

Note: Google Cloud Vision OCR should be something similar to Baidu OCR.

VoodooFX
30th May 2022, 06:01
# Version 2.15 : 2022/05/29. Spaces are allowed in "Loc".

The feature request:
It would be nice if you could specify loc as "60, 500, -60, -40" for example.

VoodooFX
12th June 2022, 16:35
# Version 2.16 : 2022/06/12. Higher quality and faster "DynColor" mask when used with "DynLocUp".
# Faster "DynColor" alternative if parameter is string, and it supports multiple colors.
# TColorMask plugin is required.

VoodooFX
13th June 2022, 17:29
# Version 2.17 : 2022/06/13. Option for ranged luma mask with DynMask6.

Helps when "logo" is not so bright:

https://i.imgur.com/EbavHqF.png

Activated by string: DynTune="140 - 200"

Eserissen
20th July 2022, 20:24
I don't understand those who remove the logo from images and videos.

Espinosa
21st July 2022, 08:15
I need help to remove the semi-transparent logo in the upper right corner of this video (neglect those black bars, they will be removed anyway). I used InpaintDelogo before to remove letters from logos in "Inpaint" mode and it usually gave good results, but this time I couldn't do anything in "Deblend" mode.

https://www.mediafire.com/file/kzzerp0fk93zhe5/sample.mkv/file

VoodooFX
21st July 2022, 15:53
I need help to remove the semi-transparent logo in the upper right corner of this video (neglect those black bars, they will be removed anyway). I used InpaintDelogo before to remove letters from logos in "Inpaint" mode and it usually gave good results, but this time I couldn't do anything in "Deblend" mode.

https://www.mediafire.com/file/kzzerp0fk93zhe5/sample.mkv/file
First, deinterlace and crop video, encode it to lossless:


QTGMC(Preset="Medium", Sharpness=0.2)
Crop(264,6,-258,-2)


Then run InpaintDelogo on that lossless file:


InpaintDelogo( mask="D:\mask.bmp", Loc="1170,44,-0,-950", Mode="Both", Analyze=3, dPP=4, oTune=-5)
Spline36Resize(752,576)

Probably on this video "Analyze=3" is most suitable. Basemask can be easily done with Photoshop.
Actual footage is upscaled so we downscale it back to "sd" res.
"Both" because those black letters are not transparent.

With logo:
https://i.imgur.com/UpolKsf.jpeg

Logo gone:
https://i.imgur.com/tBT10pN.jpeg

PS:
Something is wrong with FPS, got 100fps and twice shorter clip, maybe it's issue with sample...

Espinosa
21st July 2022, 21:35
Of course I tried this but got this error:

https://i.ibb.co/wM0W8Hw/image.png

My mask has a black background with a white rectangle at Loc position. I'm going to update the core files and plugins and then run the script again.

VoodooFX
21st July 2022, 21:56
Update InpaintDelogo.

Espinosa
21st July 2022, 22:25
Now this:

https://i.ibb.co/VtswCwK/image.png

VoodooFX
21st July 2022, 22:52
"AviSynth+ v3.7.1 or later", check Avisynth version with Version().

Espinosa
21st July 2022, 23:27
https://i.ibb.co/Hx2qDGh/image.png

VoodooFX
22nd July 2022, 00:05
That's strange, upload your InpaintDelogo.avsi to mega and share output of AVSMeter -avsinfo.

Espinosa
22nd July 2022, 08:54
https://mega.nz/file/CqhlTIoA#3vwgLFNl5oQgDrHzzrtz-nSnVZlcTanHOOfwXUP-mUo

https://mega.nz/file/ymR10JjR#pmJWpn9cGGCbVUHfrP64_EjdIJKAeRpObs1myMULcxA

Espinosa
22nd July 2022, 11:13
That's strange, upload your InpaintDelogo.avsi to mega and share output of AVSMeter -avsinfo.

Can you upload your mask.bmp file? I get this now:

https://i.ibb.co/6N1pjQ6/image.png

This is the mask I used:

https://i.ibb.co/hmGR2fn/image.png

Espinosa
22nd July 2022, 11:26
It's fine, I forgot that ~10px mask rule. I have other issues with updating Avisynth plugins but that has nothing to do with InpaintDelogo.

https://i.ibb.co/FVmq8B6/image.png

Thank you!

VoodooFX
22nd July 2022, 12:34
So what was culprit of that "unexpected character" error?
"Mask is full" is because you painted whole Loc area white, only logo should be white.

Upload your bmp & ebmp masks to mega, I'll check if everything is OK.

Espinosa
22nd July 2022, 15:30
I got lost in all these difficulties with updating but I think it's Avisynth.dll. I use MeGUI and AvsPmod, and since MeGUI uses its own core libraries the same script now runs in AvsPmod but throws the same error in MeGUI. Function objects as a new variable type is something that should be defined in the core part so I suppose it's the problem with the core libraries.

I didn't use a ebmp mask at all but judging by some examples here, I guess it should contain only the logo in order to know what to remove by inpainting and what by deblending or something like that. I'm just not sure whether it should be black & white or not. Can you explain this and also how to name it?

VoodooFX
22nd July 2022, 16:40
...but throws the same error in MeGUI.

In MeGUI set to use external Avisynth: MeGUI > Options > uncheck "Always use the included Avisynth" > Save > restart MeGUI


I didn't use a ebmp mask at all... Can you explain this and also how to name it?
ebmp masks are created and used automatically by InpaintDelogo, they are at same place where is your "bmp" basemask, and it's filename starts same as "bmp" mask's name.

Espinosa
22nd July 2022, 17:23
In MeGUI set to use external Avisynth: MeGUI > Options > uncheck "Always use the included Avisynth" > Save > restart MeGUI

Thank you.

ebmp masks are created and used automatically by InpaintDelogo, they are at same place where is your "bmp" basemask, and it's filename starts same as "bmp" mask's name.

I modified Crop parameters a little bit:

crop(266, 4, -262, -2)

These are the files:

https://mega.nz/file/rngEXJbZ#h4h0wNa58UJseAQInp9H-Q3cY9H70Oe5gK4Vu0PZqKA

https://mega.nz/file/OjYkQTpI#PwmK4yvZNgIlAWAKtXNQ9hmk6-jRFOxIPsvKiBcnCCk

VoodooFX
22nd July 2022, 20:11
These are the files:

Not bad masks, but not so good.

Try these custom masks: https://we.tl/t-yMUvpwMNk1


InpaintDelogo( mask="D:\mask4.bmp", Loc="1170,44,-0,-950", Mode="Both", Analyze=3, dPP=4, oTune=-5, oTinflate=1, Alphatweak=-3)


Your masks:
https://i.imgur.com/0uudsiW.jpeg

My custom masks:
https://i.imgur.com/u1zkaTu.jpeg

Clotibrut
22nd July 2022, 22:14
I don't understand those who remove the logo from images and videos. You don't want the person who created this video or photo to receive well-deserved compliments and praise for his work. I am a photographer, and many of my photos are becoming popular on the networks, so I created a simple logo for myself using create.vista (https://create.vista.com/create/animated-logo-maker/). Finding my photo works in other sources without my logo is extremely unpleasant. It seems to me that this is plagiarism and also very incorrect concerning me.

StainlessS
22nd July 2022, 22:26
Because they're annoying, but welcome to the forum where you will no doubt learn to be similarly annoyed :)

VoodooFX
22nd July 2022, 23:42
Why you are welcoming a new roBot? :)

StainlessS
23rd July 2022, 00:22
It's more pleasant than interacting with the natives.

VoodooFX
23rd July 2022, 00:58
It's more pleasant than interacting with the natives.

https://i.imgur.com/GSjgnAW.png

More pleasures there: https://chai.ml :)

kedautinh12
23rd July 2022, 05:27
Lol :D

Espinosa
28th July 2022, 12:08
Not bad masks, but not so good.

Try these custom masks: https://we.tl/t-yMUvpwMNk1
I didn't have time for creating masks, later will play with that. I updated all plugins but now there is a strange problem.

- InpaintDelogo after QTGMC doesn't work
- InpaintDelogo after Yadif for example works
- QTGMC not followed by InpaintDelogo works

Any idea what could be wrong?

VoodooFX
28th July 2022, 14:12
@StainlessS
Look how your beloved robot replaced his "innocent" post with ad. :)
[10£ per month for some crap :eek:]

I updated all plugins but now there is a strange problem.

- InpaintDelogo after QTGMC doesn't work
- InpaintDelogo after Yadif for example works
- QTGMC not followed by InpaintDelogo works

Any idea what could be wrong?
What happens when "doesn't work"? Share whole avs script.

Btw, can you remove that quote with images?

Espinosa
28th July 2022, 14:22
Images removed.

I have a longer script but after debugging I figured out that the problem is with QTGMC and InpaintDelogo. I was trying to run the script and encode the video but MeGUI crashes at that point.

LWLibavVideoSource("sample.mkv")

QTGMC(preset = "Slower", Sharpness=0.2)
crop(266, 4, -262, -2)
#InpaintDelogo(mask="D:\mask4.bmp", Loc="1170,44,-0,-950", Mode="Both", Analyze=3, dPP=4, oTune=-5, oTinflate=1, Alphatweak=-3)
return last

VoodooFX
28th July 2022, 14:28
Why do you run QTGMC again? Run delogo on your lossless file.

Espinosa
28th July 2022, 14:51
What do you mean by "again"? My source is interlaced, I want to deinterlace it and run delogo.

VoodooFX
28th July 2022, 14:55
Then I've no idea what you are doing there, what are those masks you posted? At this point I thought that you have deinterlaced your file...
Read this post again: https://forum.doom9.org/showpost.php?p=1972031

Espinosa
28th July 2022, 14:59
Why do I need to encode the file to lossless after QTGMC and Crop and then use InpaintDelogo? Can I simply write one script where InpaintDelogo call follows QTGMC?

VoodooFX
28th July 2022, 15:18
Can I simply write one script where InpaintDelogo call follows QTGMC?
You can, but you would be deinterlacing twice as whole video is parsed to create masks.

Espinosa
28th July 2022, 15:40
You can, but you would be deinterlacing twice as whole video is parsed to create masks.

Twice? Where does that happen?:confused:

VoodooFX
28th July 2022, 16:18
Twice? Where does that happen?:confused:
In Avisynth.

Espinosa
28th July 2022, 16:36
That doesn't make sense that QTGMC followed by InpaintDelogo does deinterlacing twice. I used QTGMC in all my scripts with interlaced sources and this is the first time I read that I need to encode twice.

VoodooFX
28th July 2022, 17:10
That doesn't make sense that QTGMC followed by InpaintDelogo does deinterlacing twice. I used QTGMC in all my scripts with interlaced sources and this is the first time I read that I need to encode twice.
Deinterlacing twice doesn't mean encoding twice. You don't "need" to do that, but for some reason you are trying to do that, maybe that's why MeGUI is crashing.

"Twice" is hypothetical, with your way you can go to any number of "empty" deinterlaces, depends from what you are doing there.

Espinosa
28th July 2022, 17:36
LWLibavVideoSource("sample.mkv")

QTGMC(preset = "Slower", Sharpness=0.2)
crop(266, 4, -262, -2)
InpaintDelogo(mask="D:\mask4.bmp", Loc="1170,44,-0,-950", Mode="Both", Analyze=3, dPP=4, oTune=-5, oTinflate=1, Alphatweak=-3)
return last
I still fail to see that this simple script can be problematic. If source file is interlaced then QTGMC should give a progressive output video file. After that InpaintDelogo should remove the logo on that file. This works with Yadif instead of QTGMC.

VoodooFX
28th July 2022, 17:48
Maybe there is not enough memory, try "Medium" instead of "Slower". Why you don't want to deinterlace to lossless file?
You didn't answered how you got those masks you posted there (https://forum.doom9.org/showpost.php?p=1972079&postcount=358).

StainlessS
28th July 2022, 20:36
@StainlessS
Look how your beloved robot replaced his "innocent" post with ad.
[10£ per month for some crap ]
How terribly perceptive of you, It did not occur to me at all the the guy/gal/gadget was as robot. [from original post content]

Espinosa, just do as VX says, from eg VDub2, set codec to eg Ut_Video [lossless code] and save as result of QTGMC to AVi,
otherwise QTGMC deinterlaced twice, is twice as slow.
[InPaintDelogo scans file twice, so it would have to deintelace twice if all done in single script].

Espinosa
28th July 2022, 20:58
Maybe there is not enough memory, try "Medium" instead of "Slower". Why you don't want to deinterlace to lossless file?
You didn't answered how you got those masks you posted there (https://forum.doom9.org/showpost.php?p=1972079&postcount=358).

No, it's not memory. I checked memory consumption in real time while running the script and 40% of it was free.

When you write "lossless file" I interpret it as "Let one script crop the video and deinterlace it, after that encode it losslessly. After that use that lossless file in another script as an input and do additional processing, including InpaintDelogo". To me this seems necessary only in case that deinterlacing can't be followed by InpaintDelogo but I don't see why such a limitation would exist. If my interpretation is not correct then please explain what you mean by "deinterlace to lossless file".

I created that base mask manually and ebmp file I got after running InpaintDelogo using the parameters from your first example. I used Yadif to deinterlace the video file.

Now I tried my script with QTGMC followed by InpaintDelogo in Virtual Dub and it works. I still don't know why it doesn't work with MeGUI. In MeGUI I can see a preview but when I try to start encoding it crashes. It looks like a problem with the encoder but it's updated and this is the first time I see such a behavior so I have no idea why that happens.

Espinosa
28th July 2022, 21:07
Espinosa, just do as VX says, from eg VDub2, set codec to eg Ut_Video [lossless code] and save as result of QTGMC to AVi,
otherwise QTGMC deinterlaced twice, is twice as slow.
[InPaintDelogo scans file twice, so it would have to deintelace twice if all done in single script].

I prefer to understand things than simply do as someone says. Since it works in VirtualDub it means that crashing has nothing to do with QTGMC-InpaintDelogo relationship. As for computational efficiency, I have no idea what InpaintDelogo does internally so I'm confused why deinterlacing happens two times.

VoodooFX
28th July 2022, 21:32
No, it's not memory. I checked memory consumption in real time while running the script and 40% of it was free.
It's not about whole memory, it's about memory per process, 2GB is a limit for 32bits, I think.


When you write "lossless file" I interpret it as "Let one script crop the video and deinterlace it, after that encode it losslessly. After that use that lossless file in another script as an input and do additional processing, including InpaintDelogo". To me this seems necessary only in case that deinterlacing can't be followed by InpaintDelogo but I don't see why such a limitation would exist. If my interpretation is not correct then please explain what you mean by "deinterlace to lossless file".

There is no such limitation, just saving your time when video is/can be parsed many times and you have a heavy filter above InpainDelogo. Most of the mask creation options parse whole video, that means all filters above InpaintDelogo are processed too. So, with lossless file you deinterlace only once, btw lossless encoding is very fast.


I created that base mask manually and ebmp file I got after running InpaintDelogo using the parameters from your first example. I used Yadif to deinterlace the video file.

Like here, you wasted time deinterlacing it, now you need to deinterlace again.
Maybe that mask wasn't so good because you used inferior deinterlacer, I dunno.

You can try Analyze=1, maybe you'll get better masks.
InpaintDelogo( mask="D:\mask.bmp", Loc="1170,44,-0,-950", Mode="Both", Analyze=1, dPP=4, oTune=-5)

VoodooFX
28th July 2022, 21:48
It did not occur to me at all the the guy/gal/gadget was as robot. [from original post content].
Yeah, bots are getting smarter, now they search forums for suitable threads to post targeted ads.
They can be spotted by semi-stupid posts, sometimes they make posts without ads just to build-up human like "ego" and then after few months starts posting targeted ads.

Eshraq Rahman
4th August 2022, 20:03
Hi
I am new to programming as well as to converting hardcoded subtitles to images and then convert them to srt. I have provided the screenshot of the error when I run the script. If anyone could help with the error I would be really appreciate it.

https://1drv.ms/u/s!Aj8vvEW_e-AYlXqRnY_JlRKMzR4M
Thank you

https://1drv.ms/u/s!Aj8vvEW_e-AYlXqRnY_JlRKMzR4M

Eshraq Rahman
4th August 2022, 20:07
I have attached a screenshot of the script and the error message

VoodooFX
4th August 2022, 23:19
Upload your image to Imgur or similar site.

Eshraq Rahman
5th August 2022, 12:03
https://imgur.com/fOEcvaT

VoodooFX
5th August 2022, 13:37
https://imgur.com/fOEcvaT

This error is because GRunT is missing, install all required plugins.

Espinosa
6th August 2022, 13:54
There is no such limitation, just saving your time when video is/can be parsed many times and you have a heavy filter above InpainDelogo. Most of the mask creation options parse whole video, that means all filters above InpaintDelogo are processed too. So, with lossless file you deinterlace only once, btw lossless encoding is very fast.

Well, you could have written that the real reason is computational efficiency and it would be enough to understand. However, I still can't figure out why all filters above InpaintDelogo need to be executed. Can you explain on one example the order of execution when InpaintDelogo follows QTGMC?

Like here, you wasted time deinterlacing it, now you need to deinterlace again.

I always use a very short sequence of frames to test a script before I get the final version, so it's not problematic.

VoodooFX
6th August 2022, 16:27
Well, you could have written that the real reason is computational efficiency and it would be enough to understand.
Isn't obvious that deinterlacing once is more efficient that deinterlacing same thing multiple times?

However, I still can't figure out why all filters above InpaintDelogo need to be executed.
Because those filters stands between InpaintDelogo and video source. That's how Avisynth works, all filters above any filter are executed.

I always use a very short sequence of frames to test a script before I get the final version, so it's not problematic.
You could write that, there was no way to know that you posted useless masks, problem is that I wasted time on useless tasks. :)

Espinosa
6th August 2022, 17:46
Isn't obvious that deinterlacing once is more efficient that deinterlacing same thing multiple times?


Because those filters stands between InpaintDelogo and video source. That's how Avisynth works, all filters above any filter are executed.


You could write that, there was no way to know that you posted useless masks, problem is that I wasted time on useless tasks. :)

Ugh, seems like we always misunderstand each other.

My main question is why does it deinterlace twice? There is one QTGMC call and it does deinterlacing. What part of the code calls it for the second time?

"...need to be executed twice" - I forgot "twice".

I don't understand where your arrogance comes from but that's your problem anyway. Masks which I uploaded I got using your parameters, not mine. I came here to ask for help and turns out I'm blamed that "my masks are useless". If helping random users of your script is useless task then you have a wrong motivation for your work.

VoodooFX
6th August 2022, 20:05
My main question is why does it deinterlace twice? There is one QTGMC call and it does deinterlacing. What part of the code calls it for the second time?
You got answer to that multiple times, I think, now I don't have time to reread posts.
Second [or last n-th] time is when you do encode, encoder calls it.


I don't understand where your arrogance comes from but that's your problem anyway. Masks which I uploaded I got using your parameters, not mine. I came here to ask for help and turns out I'm blamed that "my masks are useless". If helping random users of your script is useless task then you have a wrong motivation for your work.
You asked for help - you got the answer, masks you uploaded you got doing your own things out there, not the things you got as answer.
Don't perceive conversations with strangers online as some feelings, what you perceived as "blaming" I would describe as a sarcastic answer.
I would call "arrogance" when you complain about free things on internet. I didn't knew that helping random users is my work, I'll write that to my resume. I would like to hear your perception about the motivations. :)


PS
Maybe I'm bad at it, let's try again:


Like here, you wasted time deinterlacing it, now you need to deinterlace again.
I always use a very short sequence of frames to test a script before I get the final version, so it's not problematic.

So you waste time deinterlacing it + more time waste "to test". :)

Eshraq Rahman
8th August 2022, 11:40
This error is because GRunT is missing, install all required plugins.

Thank you

Eshraq Rahman
8th August 2022, 12:06
How to extract subtitles which are of two colors on each line and also don't display at once instead shows up like you are typing the subtitles

VoodooFX
8th August 2022, 17:59
How to extract subtitles which are of two colors on each line and also don't display at once instead shows up like you are typing the subtitles
Without video sample I can't tell.

Eshraq Rahman
9th August 2022, 11:02
Without video sample I can't tell.

https://1drv.ms/v/s!Aj8vvEW_e-AYlX0IEPoxHjvytZuy?e=FR9HYl

VoodooFX
9th August 2022, 21:53
Always share sample from original video, anyway, those blue subs are hardly visible, so you can't extract them.

https://i.imgur.com/8LDCyNw.png

EDIT:
Theoretically you can extract them, but OCR engines won't recognize what is written there...

evafans
11th August 2022, 14:05
Thank you, your script works perfect for characters with halo, but for English sub without halo, the characters often miss. Which mask do you recommend? Or is there a well-adjusted setting?
This is my setting for now, It seems fine, does it need any changes? Dyntune seems to be the key parameter to keep character complete, is there other parameter that I can use?
\ DynMask=4, DynTune=200,
\ DynMask4H=110,
\Extract=1, Show=4,

VoodooFX
11th August 2022, 17:06
Thank you, your script works perfect for characters with halo, but for English sub without halo, the characters often miss. Which mask do you recommend? Or is there a well-adjusted setting?
This is my setting for now, It seems fine, does it need any changes? Dyntune seems to be the key parameter to keep character complete, is there other parameter that I can use?
\ DynMask=4, DynTune=200,
\ DynMask4H=110,
\Extract=1, Show=4,
Where is sample of your video?
For different video/subtitles you need to set different thresholds, Dynmask4 is meant only for subtitles with distinct halo, so you are using wrong settings. There is no "well-adjusted" thresholds to magically fit all subtitles.

evafans
12th August 2022, 07:52
Where is sample of your video?
For different video/subtitles you need to set different thresholds, Dynmask4 is meant only for subtitles with distinct halo, so you are using wrong settings. There is no "well-adjusted" thresholds to magically fit all subtitles.
https://drive.google.com/file/d/1uWtcp8tYFsIiIGcn99v0RXlyCXVkiZeF/view?usp=sharing

StainlessS
12th August 2022, 11:00
@ evafans,

Dynmask4 is meant only for subtitles with distinct halo
The halo is key to making the subtitle detections.

You have to have or create a google account to access your link.

evafans
12th August 2022, 11:48
https://wormhole.app/vD0Mq#_yqBj3yogM4rCHQYPHDIjw

VoodooFX
12th August 2022, 15:41
https://wormhole.app/vD0Mq#_yqBj3yogM4rCHQYPHDIjw

You can't get simpler subs like these, subs are brighter than anything else in this video/sample, so if whole video is like that then you can use simplest and fastest dynamic mask AKA DynMask6:


LWLibAvVideoSource("D:\sample.mkv")
InpaintDelogo(Loc="400,840,-400,-80", Show=4, DynMask=6, DynTune=215)


Inside the script [InpaintDelogo.avsi], at the top there is manual/help about parameters, you can open it with any text editor like Notepad++ or PSPad.
Come back with more challenging sample/subs, for example where you get artifacts. :p

VoodooFX
12th August 2022, 15:57
The halo is key to making the subtitle detections.
Halo is the key only in DynMask4, there is other options for DynMask where halo is not taken into account.

kedautinh12
12th August 2022, 16:42
Hi VX, i tried your script but can use cause it's hard to got mask logo.bmp and use your script?? Can you got logo.bmp from there video and guide me to use your script, thanks
M-On: https://drive.google.com/file/d/1Zsx7OYSGWL6W3BsJJn8fWPMkdd-EgdQE/view?usp=sharing
SSTV: https://drive.google.com/file/d/1ntJYRiwL8thnUDLlFZe_oTdM3zrxe6rR/view?usp=sharing
SSTV+: https://drive.google.com/file/d/1i3jj5thtLpYP-YG-Xm-5apAsaGXez2YI/view?usp=sharing

VoodooFX
12th August 2022, 16:56
Hi VX, i tried your script but can use cause it's hard to got mask logo.bmp and use your script?? Can you got logo.bmp from there video and guide me to use your script, thanks
Those links doesn't work for me, use normal filelocker like Wetransfer or Mega ect., you can share from Google Drive too.

And share the script where you are trying to get that mask.

kedautinh12
12th August 2022, 18:41
Those links doesn't work for me, use normal filelocker like Wetransfer or Mega ect., you can share from Google Drive too.

And share the script where you are trying to get that mask.

Ok, i edited my link and about script, i use loc and mask. Other parameter is default

VoodooFX
12th August 2022, 19:56
i tried your script... it's hard... guide me to use your script
and about script, i use loc and mask. Other parameter is default
I see that you didn't tried anything, first step in guide is to read it...

So you've used 2 parameters so far... even in "Basic short guide" on the first post are mentioned 5 parameters, after you read it - post what you didn't understand.
Meanwhile, I'll look at your first link.

VoodooFX
12th August 2022, 22:14
M-On: https://drive.google.com/file/d/1Zsx7OYSGWL6W3BsJJn8fWPMkdd-EgdQE/view?usp=sharing

Video is interlaced, so first deinterlace it to lossless file.
Logo is transparent = use Deblend mode.
Trim to exclude parts where there is no logo or logo is animated.
Run the script posted below with Automask=1 to create "bmp" basemask, then run with 0 to create deblending masks and delogo.
Animated parts you can delogo with Inpaint mode.


LWLibAvVideoSource("D:\EONIAN_deinterlaced.mkv")
Trim(61,10907)
InpaintDelogo( mask="D:\mask2.bmp", Automask=0, aMix=1, Loc="1252,878,-90,-64", Mode="Deblend")


Similarly you can remove logo at the left side too.

Logo:
https://i.imgur.com/eTxsNe4.jpeg
https://i.imgur.com/FOmKVDG.jpeg

Delogo:
https://i.imgur.com/HZNQF8f.jpeg
https://i.imgur.com/jBIxngM.jpeg

ChaosKing
12th August 2022, 22:41
Similarly you can remove logo at the left side too.


You mean the other left, also know as right.
I was staring for half a minute at the left text and couldn't find any difference:devil:

VoodooFX
12th August 2022, 23:12
You mean the other left, also know as right.
I was staring for half a minute at the left text and couldn't find any difference:devil:
Left side is left, not idea what you meant by "right". :confused:
I meant that he can delogo the text at the left side himself. :)

kedautinh12
13th August 2022, 01:22
I see that you didn't tried anything, first step in guide is to read it...

So you've used 2 parameters so far... even in "Basic short guide" on the first post are mentioned 5 parameters, after you read it - post what you didn't understand.
Meanwhile, I'll look at your first link.

Oh, i tried to understand but your script hard to understand, sr i'm noob. And my result is video with green color cover all video:D

kedautinh12
13th August 2022, 01:31
Video is interlaced, so first deinterlace it to lossless file.
Logo is transparent = use Deblend mode.
Trim to exclude parts where there is no logo or logo is animated.
Run the script posted below with Automask=1 to create "bmp" basemask, then run with 0 to create deblending masks and delogo.
Animated parts you can delogo with Inpaint mode.


LWLibAvVideoSource("D:\EONIAN_deinterlaced.mkv")
Trim(61,10907)
InpaintDelogo( mask="D:\mask2.bmp", Automask=0, aMix=1, Loc="1252,878,-90,-64", Mode="Deblend")


Similarly you can remove logo at the left side too.

Logo:
https://i.imgur.com/eTxsNe4.jpeg
https://i.imgur.com/FOmKVDG.jpeg

Delogo:
https://i.imgur.com/HZNQF8f.jpeg
https://i.imgur.com/jBIxngM.jpeg

Like you said. I use this script
LWLibAvVideoSource("D:\EONIAN_deinterlaced.mkv")
Trim(61,10907)
InpaintDelogo( mask="D:\mask2.bmp", Automask=1, aMix=1, Loc="1252,878,-90,-64", Mode="Deblend") # to make .bmp file
InpaintDelogo( mask="D:\mask2.bmp", Automask=0, aMix=1, Loc="1252,878,-90,-64", Mode="Deblend") # to Delogo

Right?

VoodooFX
13th August 2022, 01:48
Right?
No, you don't stack it like that. Run with Automask enabled to get the basemask, then run with Automask disabled to do delogo.

kedautinh12
13th August 2022, 02:04
No, you don't stack it like that. Run with Automask enabled to get the basemask, then run with Automask disabled to do delogo.

But i only use one pass encode. And my scripts i use both. Automask=1 on top and automask=0 on bottom

VoodooFX
13th August 2022, 02:23
"Run" doesn't mean encode, that means you do preview of your script.
And that script is not ready to encode, you need to join parts with no logo, and delogo and join the animated parts.

kedautinh12
13th August 2022, 02:35
"Run" doesn't mean encode, that means you do preview of your script.
And that script is not ready to encode, you need to join parts with no logo, and delogo and join the animated parts.

I know what you say, but i ask this script correct in delogo part??

VoodooFX
13th August 2022, 03:15
If you understand then I don't understand what you are asking.

kedautinh12
13th August 2022, 03:24
If you understand then I don't understand what you are asking.

You said: "join parts with no logo, and delogo and join the animated parts". And i ask my scripts above correct with "delogo part" as you said

VoodooFX
13th August 2022, 03:36
You said: "join parts with no logo, and delogo and join the animated parts". And i ask my scripts above correct with "delogo part" as you said
Sorry, I don't understand what you write.

kedautinh12
13th August 2022, 03:46
Sorry, I don't understand what you write.

Lol, just forget about it :D

pcroland
15th August 2022, 20:56
If anyone is interested I created a small script that can extract forced cues from a full subtitle based on the folder that SubsMask2Img created:
https://github.com/pcroland/substoforced
❯ ./stf.py -h
substoforced 1.0.0

USAGE: stf.py [-h] [-v] [-s SUB] [-f FOLDER]

FLAGS:
-h, --help show this help message.
-v, --version show version.
-s, --sub SUB specifies srt input
-f, --folder FOLDER specifies a folder where SubsMask2Img generated timecodes (optional)
you should remove the junk from there manually

VoodooFX
16th August 2022, 17:57
If anyone is interested I created a small script that can extract forced cues from a full subtitle based on the folder that SubsMask2Img created:
https://github.com/pcroland/substoforced

Could you describe more specifically what it does?

pcroland
16th August 2022, 18:04
It keeps the cues from the full subtitle that overlaps with any of the timecodes generated by SubsMask2Img. Lets say you have an English movie with French parts that are hardsubbed and you have a dub in another language where French parts aren't translated and you only have a full subtitle for it. You can generate the forced automatically for it.
Another use case would be to have a video with hardsubs that are also present in the full subtitle. You could create a subtitle based on your full subtitle without OCRing image (so it has less errors).

VoodooFX
16th August 2022, 18:16
Now it's clear. I was thinking what you are extracting there when you have srt already. :)

Emulgator
19th August 2022, 23:26
First off, many thanks to you, VoodooFX for building and maintaining that huge and useful script.

A suggestion: While having to handle plain white text logo with black borders (subtitle style) I came across the need to give expand=3.
expand=2 would still leave inpainting artifacts, which postprocessing could mend only a bit.
Going into script version 2.17 line 1178 it was well possible to change the assert line to acommodate expand up to 5 without breaking the underlying function balloonPX.
buginflate = (inflate < 0 || inflate > 2) ? true : false
changed to
buginflate = (inflate < 0 || inflate > 5) ? true : false

Maybe worth a suggestion to have that in the coming version.

VoodooFX
20th August 2022, 03:00
@Emulgator

Thing is that I never saw a practical case where I would need it more than 2...
You would need to share your logo case so I can see it with my own dead eyes to change my mind on that option.

Btw, you are not the first one asking this, and all of them were doing something wrong and wanted to "expand" stuff more to cover mistakes.

Emulgator
20th August 2022, 22:15
It was a subtitle style logo. White body, plus black borders, plus a bit halo.
Photosobbing -> Curves -> Isolating the white body left my mask without the black borders, let alone the faint halo, so too thin
To get that inpainted properly it would either take photosobbing again to pad up the lost borders and halo, or take the borders into account first.

Well, more work...or simply hand that padding job over to Inpaint Delogo, which did work nicely.

I guess the old fat bordered Sony Handycam style time code rendering would benefit from that too, still got to capture a case to publish.
Badly needed for stabilising such footage, because stabilising alone leaves you with shaky timecode, so timecode got to be removed first before stabilising.

VoodooFX
21st August 2022, 17:56
Photosobbing -> Curves -> Isolating the white body left my mask without the black borders
So it's problem of you not making a proper basemask with Photozhop. If logo has black borders then select a frame with a bright background for edits. Use Magic Wand [there is Contiguous option] and Paint Bucket.
Or just use Automask.

I guess the old fat bordered Sony Handycam style time code rendering would benefit from that too
Inflate is only for static logos, for a dynamic mask there is DynInflate, it's limited to "4".

Emulgator
21st August 2022, 21:19
Good, I will try that.
Automask got it wrong, no pure logo on black to be had, so I would have liked to tune thresholds and such, but at the moment I am only a Delogo beginner...

VoodooFX
21st August 2022, 22:01
Did you tried to use aMix option with Automask? Are you sure logo is not transparent?
Without video I can't tell you much, share it by PM if you want.

Guilbert
8th September 2022, 09:34
Hi, @VoodooFX.

Can you please take a look to the video I send you?
I can't get a good result with InpaintDelogo to OCR these hardcoded subtitles.

I tried with these parameters, with no luck:
InpaintDelogo(Loc="280,560,-280,-40", Show=4, DynMask=4, DynTune=210, DynMask4H=60, DynMaskUp=2)

Thank you for your help! :)

VoodooFX
8th September 2022, 13:21
I tried with these parameters, with no luck:
InpaintDelogo(Loc="280,560,-280,-40", Show=4, DynMask=4, DynTune=210, DynMask4H=60, DynMaskUp=2)

Did you read the manual how to set those parameters? In this video a text brightness is way over "210" and a halo brightness as "60" is way too low.

DynTune aka text brightness - set high as possible [till text doesn't disappear].
DynMask4H aka halo brightness - set low as possible [till letters doesn't disappear].
KillBlobs - set low as possible [till letters doesn't disappear, good indicator are capital "M" and "W" letters].


v=LWLibAvVideoSource("D:\video.1080p.mkv")
x=v.crop(360,820,-360,-80)

o1=v.InpaintDelogo(Loc="360,820,-360,-80", Show=4, DynMask=4, DynTune=210, DynMask4H=60)
o2=v.InpaintDelogo(Loc="360,820,-360,-80", Show=4, DynMask=6, DynTune=240)
o3=v.InpaintDelogo(Loc="360,820,-360,-80", Show=4, DynMask=4, DynTune=240, DynMask4H=140)
o4=v.InpaintDelogo(Loc="360,820,-360,-80", Show=4, DynMask=4, DynTune=240, DynMask4H=140, KillBlobs=-4, KillNoise=-5)

Stackvertical(
\ x,
\ o1.ConvertToYV12().AddBorders(0,2,0,0,$F0F080).Subtitle("1: your settings"),
\ o2.ConvertToYV12().AddBorders(0,2,0,0,$F0F080).Subtitle("2: only DynTune"),
\ o3.ConvertToYV12().AddBorders(0,2,0,0,$F0F080).Subtitle("3: DynMask=4"),
\ o4.ConvertToYV12().AddBorders(0,2,0,0,$F0F080).Subtitle("4: DynMask=4 + KillBlobs & KillNoise"))


Frame 12270:

https://thumbs2.imgbox.com/26/87/YlWDrkXT_t.png (https://images2.imgbox.com/26/87/YlWDrkXT_o.png)


Here is the extracted result ["00_08_09_640__00_08_12_360.png"]:

InpaintDelogo(Loc="360,820,-360,-80", Show=4, DynMask=4, DynTune=240, DynMask4H=140, KillBlobs=-4, KillNoise=-5, DynMaskUp=2, Extract=1, ImgDir="D:\Images", ImgInflate=1)


https://thumbs2.imgbox.com/59/82/g6jh9jO4_t.png (https://images2.imgbox.com/59/82/g6jh9jO4_o.png)

[I]ImgInflate=1 because DynTune=240 is a bit too high for some sub lines [there are some small "holes" in text], so ImgInflate=1 fills them in.

Guilbert
8th September 2022, 14:42
No, I didn't read the manual yet, but I will, thank you for the advice.
Thank you as well for the explanations and those parameters, it looks amazing! :)

Do you know if Google Cloud Vision is able to detect italics, by any chance, please?
(The API was added recently in Subtitle Edit. ;))

VoodooFX
8th September 2022, 14:57
Do you know if Google Cloud Vision is able to detect italics, by any chance, please?
(The API was added recently in Subtitle Edit. ;))
I dunno. You can ask at Subtitle Edit's thread. (https://forum.doom9.org/showthread.php?t=162721)

Zetti
9th September 2022, 03:01
I have tested the subtitle extraction function with your settings from post 435 like this:

LoadPlugin("C:\MeGUI-x64\tools\ffms\ffms2.dll")
FFVideoSource("D:\Test\Test.mp4", threads=1)
InpaintDelogo(Loc="164, 362, -150, -38", Show=4, DynMask=4, DynTune=240, DynMask4H=140, KillBlobs=-4, KillNoise=-5, DynMaskUp=2, Extract=1, ImgDir="D:\Test", ImgInflate=1)

So i can see what it is doing with my video test, but i got this result out of it:

https://i.postimg.cc/yY55nsGx/test.jpg

What can i have done wrong?

VoodooFX
9th September 2022, 12:03
I have tested the subtitle extraction function with your settings from post 435 like this:
...
What can i have done wrong?
Most likely - subtitles in your video are not the same type as subtitles in Guilbert's video, you need to set parameters fitting your subtitles.
Cut [no re-encode] and post a short few mins sample of video if you want advice [or a whole video by PM].

Zetti
9th September 2022, 17:33
Here is small sample: https://www.file.io/9gdT/download/Xm0V7j2kmDMc

VoodooFX
9th September 2022, 23:57
Here is small sample: https://www.file.io/9gdT/download/Xm0V7j2kmDMc

Try this:

InpaintDelogo(Loc="130, 358, -130, -34", Show=4, DynLocUp=4, DynMask=4, DynTune=210, DynMask4H=190, KillBlobs=-7, Extract=1, ImgDir="D:\Test", ImgInflate=1, CorrTh=0.7)

Zetti
10th September 2022, 04:50
I got a good result, thank you very much.

Guilbert
14th September 2022, 14:02
@VoodooFX, what do you think about those parameters, please:

InpaintDelogo(Loc="200,490,-200,-70", Show=4, DynMask=3, Dyn3Seq=32, DynTune=240, DynTEdge=1, DynTEdgeThY=60, DynTEdgeInf=8, DynLocUp=2, KillBlobs=-5, KillNoise=-5, Extract=1, ImgDir="", ImgInflate=1)

(Video sent by PM.)

I find that the font is too altered, which makes the OCR complicated. :/

VoodooFX
14th September 2022, 15:44
@VoodooFX, what do you think about those parameters, please
Nonsense parameters, please read the manual about parameters you are using, then ask what you don't understand.
Copy-pasting random parameters from other posts is not how it works.

Guilbert
14th September 2022, 17:08
Well, sorry, I try to do my best to learn how to use InpaintDelogo and not to bother you anymore, so I read the manual again carefully, and I started from scratch with those ones:

InpaintDelogo(Loc="200,500,-200,-90", Show=4, DynMask=4, DynMask4H=90, DynLocUp=3, KillBlobs=7, KillNoise=5)

Unlike the parameters above, the font looks much better, but there are still some artifacts and the credits still appear.

Is it possible to improve that, please?

VoodooFX
14th September 2022, 18:24
Well, sorry, I try to do my best...
No need to be sorry, just that you are asking for same things, better ask what do you not understand.

so I read the manual again carefully, and I started from scratch
Start from "DynTune" parameter, what do you not understand about it?

Here is your used "DynTune=240" [frame 12349]:

v=LWLibAvVideoSource("D:\Brassic.mp4")
x=v.crop(200,490,-200,-86)

o1=v.InpaintDelogo(Loc="200,490,-200,-86", Show=4, DynMask=6, DynTune=240)

Stackvertical(
\ x,
\ o1.ConvertToYV12().AddBorders(0,2,0,0,$F0F080))


https://images2.imgbox.com/e2/ca/ETBPO75c_o.png



there are still some artifacts and the credits still appear.
If you want an advice on some artifact then you need to share where I can see that artifact, the frame number or timing.
If the credits looks like subtitles then you'll see them in a mask.

evafans
15th September 2022, 15:46
Hello,Sir. Could you help me find the right settings for the sample video, This one is half transparent without halo. I found it very tricky.
https://wormhole.app/qeyOM#mFSnGFBdgXFbjsXXfTEwLg

VoodooFX
15th September 2022, 22:54
Hello,Sir. Could you help me find the right settings for the sample video, This one is half transparent without halo. I found it very tricky.
https://wormhole.app/qeyOM#mFSnGFBdgXFbjsXXfTEwLg
Where is your full script?

These subs are not very distinctive from the background and I think they are transparent, but nothing too complicated.
Mix few masks like Dynmask6 with Dynmask7, maybe this will help you to understand:


v=LWLibAvVideoSource("D:\test.mp4")
x=v.crop(130,950,-130,-50)
o1=v.InpaintDelogo(Loc="130,950,-130,-50", Show=4, DynLocUp=2, DynMask=6, DynTune=190)
o2=v.InpaintDelogo(Loc="130,950,-130,-50", Show=4, DynLocUp=2, DynMask=7, DynTEdge=1, DynTEdgeThY=30, DynTEdgeInf=4)
o3=v.InpaintDelogo(Loc="130,950,-130,-50", Show=4, DynLocUp=2, DynMask=2, DynTune=190, DynTEdge=1, DynTEdgeThY=30, DynTEdgeInf=4, KillNoise=5)

Stackvertical(
\ x.Spline16Resize(2180,160).Subtitle("0: Original", size=40),
\ o1.ConvertToYV12().AddBorders(0,2,0,0,$F0F080).Subtitle("1: DynTune", size=40),
\ o2.ConvertToYV12().AddBorders(0,2,0,0,$F0F080).Subtitle("2: DynTEdge", size=40),
\ o3.ConvertToYV12().AddBorders(0,2,0,0,$F0F080).Subtitle("3: Non-temporal mix of 1 & 2", size=40))


Frame 3445:
https://thumbs2.imgbox.com/d9/e0/U2zxom0f_t.png (https://images2.imgbox.com/d9/e0/U2zxom0f_o.png)

Here is the extracted result ["00_02_23_227__00_02_26_271.png"]:

InpaintDelogo(Loc="130,950,-130,-50", Show=4, DynLocUp=2, DynMask=2, DynTune=190, DynTEdge=1, DynTEdgeThY=30, DynTEdgeInf=4, KillNoise=5, Extract=1, ImgDir="D:\Images", CorrTh=0.7, ImgInflate=1)

https://thumbs2.imgbox.com/17/09/c6LcCR5O_t.png (https://images2.imgbox.com/17/09/c6LcCR5O_o.png)

https://images2.imgbox.com/cc/11/drBNcJSB_o.png

If full video has more than one line subs then set Loc accordingly.
What do you use to OCR these subs?

VoodooFX
16th September 2022, 00:13
I noticed one a different color subtitle (translates writing on the door), these won't be detected by the settings in the previous post [frame 15063]:

https://thumbs2.imgbox.com/d5/c1/G1BUROgF_t.png (https://images2.imgbox.com/d5/c1/G1BUROgF_o.png)

Here are quick settings to conform that one subtitle [no idea if it will catch other such subtitles]:


InpaintDelogo(Loc="130,950,-130,-50", Show=4, DynLocUp=2, DynMask=3, Dyn3Seq=40, DynTune="130 - 160", DynTEdge=1, DynTEdgeThY=30, DynTEdgeInf=4, KillNoise=5, Extract=1, ImgDir="D:\Images", CorrTh=0.7, ImgInflate=1, SubMinDur=20)


Extracted:

https://thumbs2.imgbox.com/fc/3d/sOJnNl0F_t.png (https://images2.imgbox.com/fc/3d/sOJnNl0F_o.png)

There was one more trash subtitle extracted:

https://images2.imgbox.com/91/de/bF1CovqS_o.png

evafans
16th September 2022, 02:23
Thanks. I tried Mask 3, 4, 6 on this one, I shall study other masks.

banaguitar
18th September 2022, 18:26
Hi, is there any way to remove the logo in this video here?

https://drive.google.com/file/d/1Z-nNQpFm6Oko3RCizAPHM4mLPEp3LqGo/view?usp=sharing

VoodooFX
18th September 2022, 20:02
Hi, is there any way to remove the logo in this video here?

https://drive.google.com/file/d/1Z-nNQpFm6Oko3RCizAPHM4mLPEp3LqGo/view?usp=sharing

Try to remove it and you'll know, "zdf" part looks transparent, other part maybe opaque or has low transparency.
Deinterlace it first to the lossless file before doing anything, for example: "QTGMC(Sharpness=0.0)".

banaguitar
19th September 2022, 11:23
Try to remove it and you'll know, "zdf" part looks transparent, other part maybe opaque or has low transparency.
Deinterlace it first to the lossless file before doing anything, for example: "QTGMC(Sharpness=0.0)".

The mask looks horrible. I used this settings:

InpaintDelogo(Automask=1, Analyze=3, FrB=1,FrW=30,aMix=-3, Loc="52,42,-546,-508", mask="D:\mask.bmp")

https://i.postimg.cc/ZRtXwb5V/mask3.png

evafans
19th September 2022, 11:46
ConvertToYV12: only 8 bit sources allowed

I was try to extract hardsub, but met this error. What should I do, do I need to reencode the video?

VoodooFX
19th September 2022, 14:33
ConvertToYV12: only 8 bit sources allowed
What should I do?
Share script and sample.

evafans
19th September 2022, 15:15
https://wormhole.app/2L62b#_PL1ezf3Y5HY1eeOklw_KQ
The file is 10bit, is there a way to get around it as simple as possible?

VoodooFX
19th September 2022, 15:22
The mask looks horrible. I used this settings:
InpaintDelogo(Automask=1, Analyze=3, FrB=1,FrW=30,aMix=-3, Loc="52,42,-546,-508", mask="D:\mask.bmp")

Read the manual about parameters you are using.

For Loc you didn't left any borders.
FrB/FrW parameters are not for Analyze=3, FrW=30 is not even a white frame.

Try this to create the basemask:

InpaintDelogo( mask="D:\mask.bmp", Loc="40,30,-536,-498", Automask=1, Analyze=-4, aMix=-4)


After you got the basemask use:

InpaintDelogo( mask="D:\mask.bmp", Loc="40,30,-536,-498", Analyze=1, Mode="Deblend")

or

InpaintDelogo( mask="D:\mask.bmp", Loc="40,30,-536,-498", Analyze=2, Mode="Deblend")


EDIT:
Is your video 50 FPS after deinterlace?

VoodooFX
19th September 2022, 15:40
The file is 10bit, is there a way to get around it as simple as possible?

Add "ConvertBits(8)" after the source filter.

PS:
Looks like I've autoconversion to 8bits in my personal "dev" version, maybe later I'll dump some useful stuff from there to a public version.

banaguitar
19th September 2022, 18:16
Read the manual about parameters you are using.


Is your video 50 FPS after deinterlace?

Yes, 50 fps
This is the result. What are your thoughts about it? For me it looks ok.

https://drive.google.com/file/d/1Fq-v4Cashs622jp4imemh41jUoMy_1gz/view?usp=sharing

VoodooFX
19th September 2022, 18:57
Yes, 50 fps
This is the result. What are your thoughts about it? For me it looks ok.
Looks ugly for me.
Post your full script and share the ebmp/txt files created by the script.

EDIT:
I see, I forgot Mode="Deblend" in the previous post [corrected it now], run a corrected script then ebmp/txt files will be created and you can post them.

banaguitar
20th September 2022, 11:04
Now it looks much more better. I really don't know if it gets even better.

I used this script:

LWlibavVideoSource("D:\Disco.mkv")
SetFilterMTMode("QTGMC",2)
AssumeTFF()
QTGMC(preset="Slower",sharpness=0.0, EdiThreads=3)
Prefetch(10)
InpaintDelogo( mask="D:\mask.bmp", Loc="40,30,-536,-498", Analyze=1, Mode="Deblend")
BilinearResize(720,546)

Here is the result:

https://drive.google.com/file/d/17dNEtlwAWFHnooKZ6pcicHAqc46fuDeE/view?usp=sharing

Attached the txt/ebmp files

VoodooFX
20th September 2022, 11:53
Attached the txt/ebmp files
I can't see them, upload them to gdrive too.

I really don't know if it gets even better.
Try "Analyze=2", then you'll have more masks to compare what is better.

Did you deinterlaced to the lossless file?

banaguitar
20th September 2022, 15:57
I only used the script above and the mkv-file. That's all I have.
Here are all the files you need
https://drive.google.com/drive/folders/1zK4DV1WegvumvnW3reH7SCsKHB-RqXl0?usp=sharing

VoodooFX
20th September 2022, 16:13
The txt and ebmp are in the zip file
Where is gdrive link to them?

I only used the script above
Told you that before doing anything you need to deinterlace to the lossless file.
Or do you prefer to do empty deinterlacing ten times for no reason?

banaguitar
20th September 2022, 16:20
Where is gdrive link to them?


Told you that before doing anything you need to deinterlace to the lossless file.


Ok, I will do

VoodooFX
20th September 2022, 16:32
For some reason I can't download them from gdrive, upload to Wetransfer.
I see there some "RemoveWatermark Analyze=2.mkv" file, if you ran "Analyze=2" then you must have ebmp/txt files for it, upload them too.
I don't need your encoded files.

banaguitar
20th September 2022, 17:00
Please try again. It should work now.
There is no big difference between both.

VoodooFX
20th September 2022, 17:10
Managed to download them after I generated links for every file, strange that download on mkv files worked OK.
Why did you renamed them??? Post the real filenames of those files...

banaguitar
20th September 2022, 18:09
Added now the real filenames. Thanks for help.
If you habe problems with download on gdrive you can download the files here on wetransfer
https://we.tl/t-1zZbqarzNA

VoodooFX
20th September 2022, 19:06
Those mask are not from that script.
Share the proper masks or the proper script.

I just wonder how many times did you "deinterlaced" that clip... :D

banaguitar
20th September 2022, 21:54
Thats correct.

First I deinterlaced. Just one time. :)

LWlibavVideoSource("myclip.mkv")
SetFilterMTMode("QTGMC",2)
AssumeTFF()
QTGMC(preset="Slower",sharpness=0.0, EdiThreads=3)
Prefetch(10)
BilinearResize(720,546)

Then I saved it to an uncompressed file.

Second step is to create the basic mask from the lossless mkv

InpaintDelogo(mask="mask.bmp", Loc="40,20,150,60", Automask=1, Analyze=-4, aMix=-4)

Third step:

InpaintDelogo( mask="mask.bmp", Loc="40,20,150,60", Analyze=1, Mode="Deblend")

The same for Anaylze=2

That's all I did!

VoodooFX
21st September 2022, 00:30
1) Your ebmp masks looks like made on that 1 min sample, they are useless... Why would I need them?
2) Don't resize before delogo. Why resize with crappy filter or resize at all?
3) Your encodes looks blurred. If you didn't denoise then you need to investigate your setup.

banaguitar
21st September 2022, 05:02
1) Your ebmp masks looks like made on that 1 min sample, they are useless... Why would I need them?
2) Don't resize before delogo. Why resize with crappy filter or resize at all?
3) Your encodes looks blurred. If you didn't denoise then you need to investigate your setup.

1) That's correct. Sorry. I didn't know that. I uploaded all the files again for a similar complete clip, 10 min.
How can I open a ebmp-file?
2.) That's the reason
https://youtu.be/C4PyyQoz6eo?list=PLYVUzyF0TAYMC8USP0aIFe0XgPHdKfidt&t=3093
3.) The original video does not look blurry.

Please download the files here on wetransfer. The rendered video doesn't look perfect. You can still see some "leftovers" from the logo.
The Loc are "40,26,146,60"

----> https://we.tl/t-venRlwNWzk

doctorkhv
21st September 2022, 05:04
Hi,

I apply the logo as text in the bottom right corner using the multiply overlay https://youtu.be/gzhSOqUgA4E
What advise to apply for difficulty of a script DeLogo?

banaguitar
21st September 2022, 18:35
I can play a bit with the settings. Maybe I get better results. For now it is ok, but not perfect.

VoodooFX
21st September 2022, 18:48
@banaguitar
1.) Images you can open with ImageSource().
2.) Then better to do upscale.
3.) Nevermind, I used different QTGMC settings.

Again your masks don't fit any of your shared scripts... [EDIT: My bad, actually they are OK]


I apply the logo as text in the bottom right corner using the multiply overlay https://youtu.be/gzhSOqUgA4E
What advise to apply for difficulty of a script DeLogo?

My advice: Don't waste your time, anything you add there can be removed.

Dogway
21st September 2022, 19:47
VoodoFX, do you know a good way of removing the letters
http://i.imgur.com/qMBEiYCm.png (https://i.imgur.com/qMBEiYC.png)

I made the mask with (over a bright background):
InpaintDelogo( mask="Q:\Mask.bmp",
\ Automask=1, aMix=0, Loc="1376,64,-66,-874",
\ Mode="Inpaint",interp=0,
\ Analyze=3, FrB=18024, FrW=18024, FrS=2, GrainPP=3, turbo=3)

Output (Using Analyze=2 I got a black frame only):
http://i.imgur.com/mF92bMpt.png (https://i.imgur.com/mF92bMp.png)

http://i.imgur.com/T16vOK3m.png (https://i.imgur.com/T16vOK3.png)

Then I also got another mask called Mask_AutomaskTemp_A3:

http://i.imgur.com/1ffYPyBt.png (https://i.imgur.com/1ffYPyB.png)


I spent some time editing the mask by hand in Photoshop and got the next :/

http://i.imgur.com/c9IDBEWm.png (https://i.imgur.com/c9IDBEW.png)

VoodooFX
21st September 2022, 20:38
VoodoFX, do you know a good way of removing the letters
Your example script doesn't make sense, but if you got your mask then use:

InpaintDelogo( mask="Q:\Mask.bmp", Loc="1366,54,-56,-864")
or this can be a bit better:
InpaintDelogo( mask="Q:\Mask.bmp", Loc="1366,54,-56,-864", preBlur=4, postBlur=8, Radius=16)

Are those letters in whole video?

Dogway
21st September 2022, 20:52
"Are those letters in whole video?"
No, in a few places it's off.
The call is to create the mask, that's why automask=1 and analyze=3. But it doesn't fill the letters with white.
The letters are white with a 1px black border and a faint shadow towards right-bottom.

VoodooFX
21st September 2022, 21:18
But it doesn't fill the letters with white.

Because script is nonsense. ;)
Maybe you copied from some early examples in the thread, old Analyze is deprecated and now can be activated by adding "-", but anyway, your FrB/FrW are pointing to the same frame.
New Analyze=3 is analyzing whole clip, strange that you got that shadow in the mask.

The letters are white with a 1px black border and a faint shadow towards right-bottom.
I would try a mask with that shadow excluded .

EDIT:
And your [I]Loc has borders less than 10 pxs.

VoodooFX
22nd September 2022, 08:51
@banaguitar
Actually, the masks from your last post are OK, I didn't noticed that I ran them on WIP script...

Delogo result is not perfect but you can't do better on this video, maybe I would add more Gaussian blur to it with dPP=5.

Logo:
https://i.imgur.com/tLHELEn.png

Delogo [ InpaintDelogo( mask="D:\mask.bmp", Loc="40,26,146,60", Analyze=1, Mode="Deblend", dPP=5) ]:
https://i.imgur.com/Nxide1P.png

doctorkhv
23rd September 2022, 05:52
@doctorkhv
My advice: Don't waste your time, anything you add there can be removed.

Not a single logo can be erased with high quality even by specialized programs for removing objects (DaVinci Resolve and NUKE Studio)

The brain is arranged in such a way that it is easier for it not to notice a static object (logo) than a spot that changes in color and shape in place of a remote logo.

VoodooFX
23rd September 2022, 19:11
Not a single logo can be erased with high quality even by specialized programs for removing objects (DaVinci Resolve and NUKE Studio).
Fake news, you need to join VideoNonsense forums.
Top - your logo (https://forum.doom9.org/showpost.php?p=1975054) [Trim(5921,-260).Crop(3420,2000,-20,-60)], bottom - after InpaintDelogo:

https://i.imgur.com/9gyg5Gs.gif

Btw, good to know that those "even" programs are not good.



The brain is arranged in such a way that it is easier for it not to notice a static object (logo) than a spot that changes in color and shape in place of a remote logo.
Is this some kind of propaganda or it's self-hypnosis?
My brain definitely is choosing the bottom video.

johnmeyer
23rd September 2022, 19:20
VoodooFX: Great work. Not even worth replying to someone who doesn't know which end is up.

VoodooFX
23rd September 2022, 19:42
VoodooFX: Great work. Not even worth replying to someone who doesn't know which end is up.
Nonsense should be addressed, especially on Doom9 forums.

For reference: I'm still waiting for lordTroll's MS Paint skills there (https://forum.videohelp.com/threads/399360-so-where-s-all-the-Topaz-Video-Enhance-AI-discussion/page19#post2667474), the last news that the guy started to see ghosts on his TV, most likely it's a case for Ghostbusters. :D

doctorkhv
24th September 2022, 00:40
VoodooFX: Great work!

I remembered the film "Un homme et une femme" 1966 in which I could not remove the stains that can be considered logos)

Can anyone try to remove the stains? Humanity and I will be grateful)

Link to my google drive (2 minutes 21 seconds) https://drive.google.com/file/d/1mmNZu6PgSFEK4SIvfH8-OY-rVRjj5Y4b/view?usp=sharing

Thanks a lot!

VoodooFX
24th September 2022, 03:05
I remembered the film "Un homme et une femme" 1966 in which I could not remove the stains that can be considered logos)

Can anyone try to remove the stains? Humanity and I will be grateful)

Link to my google drive (2 minutes 21 seconds) https://drive.google.com/file/d/1mmNZu6PgSFEK4SIvfH8-OY-rVRjj5Y4b/view?usp=sharing


1) Save frame with the spots to image.
2) Open that image with some editor and mask/mark the spots then save it to lossless image.
3) Apply that mask to the selected frames with InpaintDelogo( mask="D:\spots.png", Loc="0,0,0,0", Inflate=0 )

Notes:
With current version you would need to paint the background in black.
If you don't want to bother with the background then get v3 InpaintDelogo.
Use full white to mask/mark the spots.
"Inflate" expands mask, its default is 1 px, so I disabled it here.
You can use fastest preset with "Turbo=3".

Original frame 800:
https://thumbs2.imgbox.com/ae/f6/6aojiYaq_t.png (https://images2.imgbox.com/ae/f6/6aojiYaq_o.png)

Mask with the spots to remove:
https://thumbs2.imgbox.com/d0/f1/DEO5MLEn_t.png (https://images2.imgbox.com/d0/f1/DEO5MLEn_o.png)

Result:
https://thumbs2.imgbox.com/3f/f7/WaCapB0d_t.png (https://images2.imgbox.com/3f/f7/WaCapB0d_o.png)

StainlessS
24th September 2022, 13:26
Voodoo indeed.

doctorkhv, see here [Postimages instructions]:- https://forum.doom9.org/showthread.php?p=1959414&highlight=postimage#post1959414

doctorkhv
26th September 2022, 00:15
doctorkhv, see here [Postimages instructions]:- https://forum.doom9.org/showthread.php?p=1959414&highlight=postimage#post1959414

Thank you so much StainlessS

Thank you so much VoodooFX

I never saw a video without spots.

I am unable to apply the InpaintDelogo-temp.avs script. , used XviD4PSP 5
Import("C:\Program Files (x86)\XviD4PSP 5\dlls\AviSynth\functions\AudioFunctions.avs")
Import("C:\Program Files (x86)\XviD4PSP 5\dlls\AviSynth\functions\VideoFunctions.avs")
LoadPlugin("C:\Program Files (x86)\XviD4PSP 5\dlls\AviSynth\plugins\FFMS2.dll")
Import("C:\Program Files (x86)\XviD4PSP 5\dlls\AviSynth\plugins\FFMS2.avsi")
LoadPlugin("C:\Program Files (x86)\XviD4PSP 5\dlls\AviSynth\plugins\SplineResize.dll")

FFmpegSource2("D:\Un.homme.et.une.femme.1966.mkv", rffmode=0, threads=1, cachefile="D:\Temp\Un.homme.et.une.femme.1966.mkv.ffindex")

ConvertToYV12()

###[FILTERING]###
XviD4PSPPluginsPath = "C:\Program Files (x86)\XviD4PSP 5\dlls\AviSynth\plugins\"

Import(XviD4PSPPluginsPath + "InpaintDelogo-temp.avs")

InpaintFunc(last,mask="D:\spots.png", Loc="0,0,0,0", Inflate=0)

VoodooFX
26th September 2022, 01:09
I am unable to apply
Are you sure?

doctorkhv
26th September 2022, 23:45
Yes, this is probably because XviD4PSP 5 only supports AviSynth + v3.5.1
I want to see how well the spots are removed in the 2 minute episode "Un homme et une femme" 1966 https://drive.google.com/file/d/1mmNZu6PgSFEK4SIvfH8-OY-rVRjj5Y4b/view?usp=sharing

VoodooFX
27th September 2022, 00:37
Yes
How do you know that you are sure?

doctorkhv
27th September 2022, 01:41
How do you know that you are sure?
1.
https://i.postimg.cc/9f2d0kxW/2022-09-27-03-33-04-D-Temp-Avs-P-7668-avs-Avs-Pmod.png (https://postimg.cc/xXsJF6D7)
2.
You didn't show me the video fragment with the stains already removed

VoodooFX
27th September 2022, 01:59
1. Finally you've posted something tangible... How you expect to see "video without spots" or "apply" if you couln't even import InpaintDelogo?
Probably InpaintDelogo is not there, check if your path, filename and extension is correct.

2. I posted a fragment as image "Result (https://forum.doom9.org/showpost.php?p=1975214)".

doctorkhv
27th September 2022, 02:23
1. It's very easy to remove spots from one image and show the result, but I asked you about the episode VIDEO

If you want to upload a sample there's lots of places.
https://workupload.com/
https://www.udrop.com/
https://ufile.io/
https://fileupload.win/

2. What AviSynth GUI are you using and what does the script look like for this case?

VoodooFX
27th September 2022, 02:53
1) Do it by yourself.

2) GUI is not important, it was posted already.

Zetti
28th September 2022, 00:29
I have a sample that i hope you will look at and help me with the settings and give me some tips how you have got them and what i can do on future projects.

Because I'm scratching on my head after trying to adjust for hours

Samlpe
https://file.io/HHeLlMlHF5EJ

Script
InpaintDelogo(Loc="58, 564, -98, -24", Show=4, DynLocUp=4, DynMask=4, DynTune=215, DynMask4H=200, KillBlobs=-7, Extract=1, ImgDir="D:\Test\Pics", ImgInflate=1, CorrTh=0.9)

VoodooFX
28th September 2022, 01:21
Samlpe
https://file.io/HHeLlMlHF5EJ

File is deleted. Maybe upload to Wetransfer.

Zetti
28th September 2022, 10:10
https://we.tl/t-NhbuVVmQGw

kedautinh12
28th September 2022, 14:37
Video is interlaced, so first deinterlace it to lossless file.
Logo is transparent = use Deblend mode.
Trim to exclude parts where there is no logo or logo is animated.
Run the script posted below with Automask=1 to create "bmp" basemask, then run with 0 to create deblending masks and delogo.
Animated parts you can delogo with Inpaint mode.


LWLibAvVideoSource("D:\EONIAN_deinterlaced.mkv")
Trim(61,10907)
InpaintDelogo( mask="D:\mask2.bmp", Automask=0, aMix=1, Loc="1252,878,-90,-64", Mode="Deblend")


Similarly you can remove logo at the left side too.

Logo:
https://i.imgur.com/eTxsNe4.jpeg
https://i.imgur.com/FOmKVDG.jpeg

Delogo:
https://i.imgur.com/HZNQF8f.jpeg
https://i.imgur.com/jBIxngM.jpeg

I tried with leftside but can't creat mask perfect like rightside
Trim(159,10954)
InpaintDelogo( mask="C:\mask3.bmp", Automask=1, aMix=1, Loc="98,874,-980,-64", Mode="Deblend")

sample:
https://drive.google.com/file/d/1-kkoFbzWZp3BIZ4pPfmKlfPGN3xa1SQU/view?usp=sharing

kedautinh12
29th September 2022, 13:32
I tried with leftside but can't creat mask perfect like rightside


sample:
https://drive.google.com/file/d/1-kkoFbzWZp3BIZ4pPfmKlfPGN3xa1SQU/view?usp=sharing

I use this script too good but when delete show=4, i meet error
InpaintDelogo(Loc="98,874,-980,-64", Show=4, DynLocUp=2, DynMask=7, DynTEdge=1, DynTEdgeThY=30, DynTEdgeInf=4)

VoodooFX
29th September 2022, 19:53
I tried with leftside but can't creat mask perfect like rightside
Trim(159,10954)
InpaintDelogo( mask="C:\mask3.bmp", Automask=1, aMix=1, Loc="98,874,-980,-64", Mode="Deblend")
sample:https://drive.google.com/file/d/1-kkoFbzWZp3BIZ4pPfmKlfPGN3xa1SQU/view?usp=sharing
Almost two months have passed and you still on it? With your script I get this blobalogo:

https://i.imgur.com/ZKjmoIx.png


You need to leave borders around logo and don't analyze frames without a logo or with animations of a logo:

QTGMC(Preset="Slower", Sharpness=0).SelectEven() # intermediate file
Trim(220,10830)
InpaintDelogo( mask="C:\mask3.bmp", Automask=1, aMix=1, Loc="88,864,-980,-64", Mode="Deblend")


https://i.imgur.com/8adgUSe.png


I use this script too good but when delete show=4, i meet error
InpaintDelogo(Loc="98,874,-980,-64", Show=4, DynLocUp=2, DynMask=7, DynTEdge=1, DynTEdgeThY=30, DynTEdgeInf=4)
LOL, no comments.... I'll add 30 more new parameters for you to do random things. :)

VoodooFX
29th September 2022, 20:07
I have a sample that i hope you will look at and help me with the settings and give me some tips how you have got them and what i can do on future projects.

Because I'm scratching on my head after trying to adjust for hours

Samlpe
https://file.io/HHeLlMlHF5EJ

Script
InpaintDelogo(Loc="58, 564, -98, -24", Show=4, DynLocUp=4, DynMask=4, DynTune=215, DynMask4H=200, KillBlobs=-7, Extract=1, ImgDir="D:\Test\Pics", ImgInflate=1, CorrTh=0.9)


Problem is that these subs are aligned to the left, when the scanning window looks at the middle, for now download a temp script (https://github.com/Purfview/InpaintDelogo/tree/temp) for these subs, in next version I'll add option to adjust position of the scanning window.

Resolution of the mask is very high, max KillBlobs is too low for such big letters, imo DynLocUp=2 is enough for these subs.
CorrTh you want to lower when there are lots of artifacts in a mask like this, for some reason you set it higher than default.
Imo, DynTune is too high, letters look ugly and some dots disappear.
In this sample I don't see reason for such high DynMask4H.

Maybe I would use something like this:
InpaintDelogo(Loc="60,566,-120,-30", Show=4, DynLocUp=2, DynMask=4, DynTune=170, DynMask4H=150, KillBlobs=-7, KillNoise=5, Extract=1, ImgDir="", ImgInflate=1, CorrTh=0.7)

Zetti
29th September 2022, 20:32
Thank you very much.

I will test the temp script and im happy to see that i came with something you can use to get the script better for everyone.

kedautinh12
30th September 2022, 02:20
Almost two months have passed and you still on it? With your script I get this blobalogo:

https://i.imgur.com/ZKjmoIx.png


You need to leave borders around logo and don't analyze frames without a logo or with animations of a logo:

QTGMC(Preset="Slower", Sharpness=0).SelectEven() # intermediate file
Trim(220,10830)
InpaintDelogo( mask="C:\mask3.bmp", Automask=1, aMix=1, Loc="88,864,-980,-64", Mode="Deblend")


https://i.imgur.com/8adgUSe.png



LOL, no comments.... I'll add 30 more new parameters for you to do random things. :)

My trim and your trim different cause i use other deinterlaced AnimeIVTC. I busy at all and now have freetime to test your script. I noob at English too and your script had many parameters, sr :D

katzenjoghurt
30th September 2022, 12:30
For the learning purpose I also tried to delogo kedautinh12's clip.

But that logo seems to be pretty lively... in some areas deblending works fine, in others it doesn't.

QTGMC(Preset = "Medium")
Trim(1396, 43251)
InpaintDelogo(mask="V:\Logos\Test\(test2).bmp",Loc="88, 866, -982, -68", Mode="Deblend", Automask=0, aMix=3) // aMix doesn't really seem to matter here

https://i.imgur.com/FjXJyCR.png
https://i.imgur.com/Uq7HYoR.png

https://i.imgur.com/bpucGAg.png
https://i.imgur.com/sKe6GYL.png

Mask: https://www.file-upload.net/download-15022690/test2.zip.html

kedautinh12
30th September 2022, 13:55
I used with logo in rightside and got that result too (in some areas deblending works fine, in others it doesn't.)

Selur
30th September 2022, 14:50
@VoodooFX: Small question: does InpaintDelogo only look at one frame at a time, or does it have a temporal component?

VoodooFX
30th September 2022, 15:34
@VoodooFX: Small question: does InpaintDelogo only look at one frame at a time, or does it have a temporal component?
DynMask3 and stuff in subs extraction is temporal, if you meant inpainting then it's spatial.

Selur
30th September 2022, 16:53
Thanks for clarifying. :)

VoodooFX
30th September 2022, 17:37
For the learning purpose I also tried to delogo kedautinh12's clip.

But that logo seems to be pretty lively... in some areas deblending works fine, in others it doesn't.

QTGMC(Preset = "Medium")
Trim(1396, 43251)
InpaintDelogo(mask="V:\Logos\Test\(test2).bmp",Loc="88, 866, -982, -68", Mode="Deblend", Automask=0, aMix=3) // aMix doesn't really seem to matter here


Deblending is "constant", it works same on all frames, btw, it removes logo but not the "damage" from video.
aMix is for Automask, so it doesn't do anything when Automask is disabled.

I don't experience "pretty lively" on my side. Your screenshot vs mine [frame 7449]:

https://i.imgur.com/BBrcB6v.png

https://i.imgur.com/CWFg53u.png

My script:
QTGMC(Preset = "Medium").SelectEven()
Trim(220,10830)
InpaintDelogo(mask="D:\(test2).bmp", Loc="88, 866, -982, -68", Mode="Deblend")

I don't know what you are doing there, just my wild guess:
You deinterlaced to lossy file then again "deinterlaced" that lossy file to another lossy file, then you ran delogo on it. :D


EDIT:
@kedautinh12 can you stop quoting with all images and stuff? It's annoying. :)

katzenjoghurt
30th September 2022, 22:21
Huh! That's super-interesting.


I don't know what you are doing there, just my wild guess:
You deinterlaced to lossy file then again "deinterlaced" that lossy file to another lossy file, then you ran delogo on it. :D


Not really... It's a single script - without intermediate saving.
But I'll show you what I do...

So I did it again and tried to use the very same settings you used.
I'm using StaxRip (and an older version of that - 1.7.0.6) here... though that shouldn't matter? AviSynth is 3.7.1.

https://i.imgur.com/0ML1pav.png

This results in the following script to create the mask:

https://i.imgur.com/cINCfnw.png

Afterwards I set automask=0 and looked at the result.

Oddity: I wanted to use your very Trim() values - though they only made sense with two SelectEven() calls to reduce the framerate to ~30fps. Then your Trim() range seems to fit the time where the logo is fully shown for the first time until near the end where it fades away.
Without that your range would have started even before the logo would fully appear and end at half of the clip.

Anyway... the result is the very same as I posted above.

https://i.imgur.com/6yq1zvP.png

Maybe some colorspace issue?

I'll retry tomorrow with VirtualDub2... I'm too dead tired right now to continue investigating.

kedautinh12
1st October 2022, 00:10
Do you see post #507, VX?? Don't had any images

VoodooFX
1st October 2022, 10:23
I'll show you what I do...

I suspect that your ffms2 is the culprit. For you it outputs 60 fps instead of 30, it outputs 30 for me, so try to update your ffms2.

But probably that 60 fps wouldn't create those artifacts... I don't use ffms2 because I believe that it's not frame accurate, try LSMASH (https://github.com/HomeOfAviSynthPlusEvolution/L-SMASH-Works/releases/) as a source filter [ LWLibavVideoSource() ].

Try :
1) Updated FFMS2
2) LSMASH
3) If above failed then try other GUI instead of StaxRip.

Btw, don't waste your time generating a new bmp mask every time, just reuse it, use a new filename for bmp to trigger new analysis [results of it are stored in ebmp file].
I recommend AvsPmod (https://github.com/gispos/AvsPmod) instead of VDub2.

katzenjoghurt
1st October 2022, 10:50
Hi again, VoodooFX.

You were faster than me...
Yes, indeed... ffms2 was the reason why I had to do two SelectEven() calls.

Apart from that... I think the unsatisfying explanation is just that... well... we were comparing two neighboring frames that are actually the same BUT the logo.

In frame 7773 I have your deblending result.
In frame 7774 it's the result I posted above.

(You said yours is 7774 too... but maybe that's due to me using FFMS2)

https://i.imgur.com/4wyctDb.png

VoodooFX
1st October 2022, 11:01
You said yours is 7774 too...
I said it's "7449". And delogo on the both neighboring frames [7448/7450] looks same as on 7449 for me.

PS:
Did you ran non-updated ffms2 in those screenshots?

katzenjoghurt
2nd October 2022, 10:19
Right. 7449, sorry.
The numbers confuse me as
- in VirtualDub the displayed frame number has the first 220 frames of the Trim() deducted while in StaxRip it hasn't.
- depending on the decoder I use (and which version of it I use) I get different frame numbers.

My mind creates a mess out of it.

Okay... I think I definitely got your result now by updating ffms2.
Also remuxed the clip to mp4 so I could open it with LSMASH but (at least with the version I used) I got a slight frame offset of 6fps and the video showed as a 25fps video (shouldn't matter when looking at single frames but... meh, didn't trust it anymore - and due to the slight frame offset it was obviously different to what you had).
And I again needed the two SelectEven()s.

Anyway... we got the same frame numbers now and it looks like this for me.

https://i.imgur.com/6569qaS.gif

tcFile = "C:\Temp\EONIAN - ELISA PV (2)_temp\EONIAN - ELISA PV (2)_timestamps.txt" # timestamps file path
Exist(tcFile) ? FFVideoSource("C:\Temp\EONIAN - ELISA PV (2).mp4", \
cachefile="C:\Temp\EONIAN - ELISA PV (2)_temp\temp.ffindex", timecodes=tcFile) : FFVideoSource("C:\Temp\EONIAN - ELISA PV (2).mp4", \
cachefile="C:\Temp\EONIAN - ELISA PV (2)_temp\temp.ffindex")
QTGMC(preset="Medium")
SelectEven()
Trim(220, 10831)
InpaintDelogo(mask="V:\Logos\Test\(test4) VoodooFX.bmp",Loc="88, 866, -982, -68", Mode="Deblend", Automask=0, aMix=3)


What did we learn?
I don't know...
Keep your plugins updated maybe.

VoodooFX
2nd October 2022, 13:16
Okay... I think I definitely got your result now by updating ffms2.

Your result looks same bad as before. ;)


https://i.imgur.com/Vt9XUiG.png

https://i.imgur.com/q7jgH2i.png

https://i.imgur.com/U3DwRV4.png

Get LSMASH from the link I posted.
Btw, I can load original .ts video without remuxing, with both source filters.

kedautinh12
2nd October 2022, 14:01
katzenjoghurt you can change to L-SMASH, i use L-Smash and get better results

katzenjoghurt
2nd October 2022, 14:57
Your result looks same bad as before. ;)


https://i.imgur.com/Vt9XUiG.png


This file is bewitched.
We keep looking at different frames because we use different tools.
(Yea, the different plugin versions probably don't help either).

Same avs script. Same frame.
Left: VirtualDub2
Right: AvsPmod

https://i.imgur.com/5If2795.png

But with VDub I won't ever see the frame at the right and with AvsPmod I won't ever see the frame on the left side.


Get LSMASH from the link I posted.

Will also try with LSMASH again. (see below)


Btw, I can load original .ts video without remuxing, with both source filters.

Ah, ok. I overlooked that you said to use LWLibavVideoSource. I used LSMASHVideoSource.



----



Ok, in AvsPmod with LWLibavVideoSource the "really ugly" frames don't show up any more. LWLibavVideoSource makes the difference here for me.

With that I also recreated the mask and with that the result improved again. Comparison between old mask and new mask below.


Old A:

https://i.imgur.com/eduRBGk.png

New A:

https://i.imgur.com/MxyueY0.png

Old B:

https://i.imgur.com/iXsJMcV.png

New B:

https://i.imgur.com/KOsG80y.png


Didn't update LSMASH though.

Well... fascinating.

VoodooFX
2nd October 2022, 16:50
But with VDub I won't ever see the frame at the right and with AvsPmod I won't ever see the frame on the left right.

I don't understand what you meant here.
Anyway, in your "FFMS2 VDub" vs "FFMS2 AvsPmod" comparison you are comparing same "bad" ebmp masks, that's why you can still see faint artifacts in "FFMS2 AvsPmod", because when you created ebmp with VDub [or StaxRip] those artifacts were burned into the masks.
So, for same reason "LSMASH A" vs "LSMASH B" comparison is pointless.

Only useful thing I can deduct from your tests is that FFMS2 in VDub/StaxRip doesn't work properly, and that probably it's OK in AvsPmod.

EDIT:
To remind what I posted before.
I don't use ffms2 because I believe that it's not frame accurate, try LSMASH (https://github.com/HomeOfAviSynthPlusEvolution/L-SMASH-Works/releases/) as a source filter [ LWLibavVideoSource() ].

You can search Doom9 what means "not frame accurate", there was some program posted to test a source filter's frame accuracy.

EDIT2:
Another reminder.
Btw, don't waste your time generating a new bmp mask every time, just reuse it, use a new filename for bmp to trigger new analysis [results of it are stored in ebmp file].

katzenjoghurt
2nd October 2022, 23:32
I don't understand what you meant here.


I wanted to say that these two pictures...

Your result looks same bad as before. ;)
https://i.imgur.com/Vt9XUiG.png


...are not showing the same frame. (The left one shows some lines)
And they never could be the same.
While skipping through frame by frame I never got that frame with the lines in AvsPmod. On the other hand I never got the frame without the lines in VDub.

So, for same reason "LSMASH A" vs "LSMASH B" comparison is pointless.


The two bottom comparisons were just supposed to show that now with AvsPmod & LSMASH I (too) could create a better mask.


Still not sure though if AvsPmod/StaxRip/VirtualDub2 are also relevant factors here. That the same script (with the same imports) showed me two different frames @7445 here (https://i.imgur.com/5If2795.png) and that the shown frame was either exclusive to VDub or AvsPmod feels dubious.

Anyway... I got enough clues now why your deblending quality was much higher than mine originally and why the logo was "lively" for me but not for you.

VoodooFX
3rd October 2022, 00:40
Look at my post there, those lines are ghosts of the next frame, it's some quirks of frame inaccuracy. Let's say QTGMC requests frame 1200 but actually gets from a source filter 1190 then it would produce some garbage when deinterlacing.
Dunno why it happens, ask at FFmpegSource (https://forum.doom9.org/showthread.php?t=127037) thread. In AvsPmod it looks OK but frames are offset by 2 frames vs LSMASH in your screenshots.
Did you tried LSMASH in VDub?

katzenjoghurt
3rd October 2022, 11:01
You talk of ghosts... I say the file is bewitched.

Seriously...
It's just insane.

My PC crashed with a bluescreen yesterday. (wtf?!)
After a restart frame 7445 doesn't show the lines in VirtualDub2 any more.
With the old mask. With ffms2. Using the old avs script I posted here (https://forum.doom9.org/showpost.php?p=1975763&postcount=517).

https://i.imgur.com/liYGsev.png

Nevermind.
I'm sitting here... puzzled, frustrated... as I don't feel much wiser now after all those hours. :rolleyes:
But let's call it a day.
Thank you so much for all your patience and support, VoodooFX!

Sorry for wasting your time.

VoodooFX
3rd October 2022, 11:26
I say the file is bewitched.
My PC crashed with a bluescreen yesterday. (wtf?!)
After a restart frame 7445 doesn't show the lines in VirtualDub2 any more.
Maybe the frame inaccuracy has random factor in it.

Sorry for wasting your time.
Nah, it's you who wasted time not deinterlacing to a lossless intermediate file. ;)
Automask + Deblend analyze = up to 4 empty "deinterlaces", not counting encoding. Now multiply that with your tests you did.

kedautinh finally was able to properly delogo it, so time wasn't wasted. :D

PS:
Btw, if you wanna see pure deblend effect [to compare masks ect.] then set "Interp=0" & "dPP=0".

kedautinh12
3rd October 2022, 12:59
PS:
Btw, if you wanna see pure deblend effect [to compare masks ect.] then set "Interp=0" & "dPP=0".

Add that parameters in step automask=1 or automask=0??

VoodooFX
3rd October 2022, 13:09
Add that parameters in step automask=1 or automask=0??

Automask doesn't do deblend.
"Automask=0" is not some "step", its 1 = On, 0 = Off.

StainlessS
3rd October 2022, 13:36
See I told you, too many arguements for poor little kedautinh12 to remember :)

Now for a little bit of funky dancing:- https://www.youtube.com/watch?v=CkNrmhXUu0k

VoodooFX
3rd October 2022, 14:06
See I told you, too many arguments ...
Not my fault that they bother me with various logos you can imagine, and they want everything to be auto-one-click. :D

Talking about too many, started dumping stuff from my "dev" to "public" version, a small sneak peek from upcoming v3:

https://i.imgur.com/LkfkGZW.png

PS:
Can't remember for what that last param is...

kedautinh12
3rd October 2022, 14:30
See I told you, too many arguements for poor little kedautinh12 to remember :)

Now for a little bit of funky dancing:- https://www.youtube.com/watch?v=CkNrmhXUu0k

If it's use my local language, i will remember it :D

kedautinh12
4th October 2022, 14:00
Hi, i meet new error. I use your script very good but some sceen delogo error
https://i.imgur.com/CQtwuGQ.png

Example: https://drive.google.com/file/d/1zD-vkLPAkTG9D0I4UW8c4WYcQDU5sJjK/view?usp=sharing

Scripts:
QTGMC(Preset="Medium", Sharpness=0).SelectEven()
trim(165,7898)
InpaintDelogo(mask="C:\mask3.bmp", Automask=1, aMix=-10, Loc="88,864,-980,-64", Mode="Deblend")

VoodooFX
4th October 2022, 14:13
Hi, i meet new error. I use your script very good but some sceen delogo error
How many suitable frames were found for analysis? [look at the created txt file]

kedautinh12
4th October 2022, 14:24
How many suitable frames were found for analysis? [look at the created txt file]

Text file
# Total frames to analyze: 4
3248,-1
7731,-3

VoodooFX
4th October 2022, 14:45
# Total frames to analyze: 4
That's very low, usually you need hundreds or thousands suitable frames to get good deblending masks [ebmp].
I doubt that you got a proper basemask [bmp] from this too. [upload it to gdrive]
You can try to analyze all frames with Analyze=3

kedautinh12
4th October 2022, 14:51
That's very low, usually you need hundreds or thousands suitable frames to get good deblending masks [ebmp].
I doubt that you got a proper basemask [bmp] from this too. [upload it to gdrive]
You can try to analyze all frames with Analyze=3

here .bmp file
https://imgur.com/gallery/hqFw2kA

kedautinh12
4th October 2022, 14:59
With Analyze=3
https://imgur.com/gallery/MLpfMtv

Scripts:
InpaintDelogo(mask="C:\mask3.bmp", Automask=1, aMix=-10, Loc="88,864,-980,-64", Mode="Deblend", Analyze=3)

VoodooFX
4th October 2022, 15:13
Often in the short clips there are no good frames to analyze.
Maybe this evening I'll look at your video.

kedautinh12
4th October 2022, 15:22
Often in the short clips there are no good frames to analyze.
Maybe this evening I'll look at your video.

Ok, thanks

katzenjoghurt
4th October 2022, 18:04
Not my fault that they bother me with various logos you can imagine, and they want everything to be auto-one-click. :D


Well... who wouldn't want that? :devil:
I'm a game dev. You wouldn't want to know what artists / designers ask for. For every 5min task they do once every other month they ask for a one-click-tool.


Talking about too many, started dumping stuff from my "dev" to "public" version, a small sneak peek from upcoming v3:

https://i.imgur.com/LkfkGZW.png

PS:
Can't remember for what that last param is...

Still looking forward to it. :)
(Not so much on trying to figure out what they do exactly... but some means to tweak deblending... mhh... looks super-delicous.)

kedautinh12
5th October 2022, 13:01
With aMix=-30, it's look better when make logo. But result still 2 color black-white
https://imgur.com/gallery/I0rYknx

Scripts:
trim(165,7898)
InpaintDelogo(mask="C:\mask3.bmp", Automask=0, aMix=-30, Loc="88,864,-980,-64", Mode="Deblend", Analyze=3)

kedautinh12
5th October 2022, 17:00
I was tried removed all logo from this video. I think this very good but can you suggest if this can better, VX? (If had other way). Thanks

example: https://drive.google.com/file/d/19xumWTzFVng6Avp9cOyWg8wDFjRo-hLF/view?usp=sharing

Applied Scripts: https://drive.google.com/file/d/1E4Z-SmrHWUylhsCd-HE5YlLvOoTTTC5P/view?usp=sharing

Scripts:
LWLibavVideoSource("C:\Users\ADMIN\Downloads\Gen Hoshino - Kigeki [1440x1080i MPEG2 M-ON! HD].ts", fpsnum=24000, fpsden=1001)

a0=trim(0,49)
b0=trim(50,5488).InpaintDelogo(mask="C:\mask5.bmp", Automask=0, aMix=0, Loc="50,40,-1186,-910", Mode="Inpaint")
c0=trim(5489,5563)
a0++b0++c0

a1=trim(0,53)
b1=trim(54,119).InpaintDelogo(mask="C:\mask1.bmp", Automask=0, aMix=0, Loc="60,880,-1094,-50", Mode="Inpaint", Analyze=3)
c1=trim(120,5477).InpaintDelogo(mask="C:\mask1.bmp", Automask=0, aMix=0, Loc="60,880,-1094,-50", Mode="Deblend")
d1=trim(5478,5491).InpaintDelogo(mask="C:\mask1.bmp", Automask=0, aMix=0, Loc="60,880,-1094,-50", Mode="Inpaint", Analyze=3)
e1=trim(5492,5563)
a1++b1++c1++d1++e1

a2=trim(0,25)
b2=trim(26,37).InpaintDelogo( mask="C:\mask2.bmp", Automask=0, aMix=0, Loc="1292,908,-60,-50", Mode="Inpaint", Analyze=3)
c2=trim(38,5526).InpaintDelogo( mask="C:\mask2.bmp", Automask=0, aMix=0, Loc="1292,908,-60,-50", Mode="Deblend")
d2=trim(5527,5538).InpaintDelogo( mask="C:\mask2.bmp", Automask=0, aMix=0, Loc="1292,908,-60,-50", Mode="Inpaint", Analyze=3)
e2=trim(5539,5563)
a2++b2++c2++d2++e2

propSet("_FieldBased",0)
deep_resize(1920,1080)

Reel.Deel
5th October 2022, 20:02
Video without logo: https://www.youtube.com/watch?v=D_Oyplmhhv0

v1 = DGSource("Gen Hoshino - Kigeki [1440x1080i MPEG2 M-ON! HD].dgi").TFM().Tdecimate().Trim(3,0).Spline36Resize(1920,1080)
v2 = DGSource("Gen Hoshino – Comedy.dgi")
msk = v1.ExtractY().Trim(5460,5460).mt_binarize(24).mt_expand().mt_expand().mt_expand().mt_expand().mt_expand()

mt_merge(v1, v2, msk, luma=true)

Result: https://imgsli.com/MTI4ODcw

The mask can be improved, should be really easy to draw it yourself.

Dogway
5th October 2022, 21:36
@kedautinh12: For live video opaque delogo is not very good, I think in this case InpaintDelogo just does a passthrough to AVSInpaint which is spatial only. I tried to improve it with temporal compensation, it does improve a little but needs more work.

kedautinh12
6th October 2022, 04:17
@kedautinh12: For live video opaque delogo is not very good, I think in this case InpaintDelogo just does a passthrough to AVSInpaint which is spatial only. I tried to improve it with temporal compensation, it does improve a little but needs more work.

Hi, any suggestions scripts for temporal compensation?? Thanks

johnmeyer
6th October 2022, 05:22
Hi, any suggestions scripts for temporal compensation?? Thanks

Mcompensate, from MVTools2:

http://avisynth.org.ru/mvtools/mvtools2.html#functions

kedautinh12
6th October 2022, 13:52
Video without logo: https://www.youtube.com/watch?v=D_Oyplmhhv0

v1 = DGSource("Gen Hoshino - Kigeki [1440x1080i MPEG2 M-ON! HD].dgi").TFM().Tdecimate().Trim(3,0).Spline36Resize(1920,1080)
v2 = DGSource("Gen Hoshino – Comedy.dgi")
msk = v1.ExtractY().Trim(5460,5460).mt_binarize(24).mt_expand().mt_expand().mt_expand().mt_expand().mt_expand()

mt_merge(v1, v2, msk, luma=true)

Result: https://imgsli.com/MTI4ODcw

The mask can be improved, should be really easy to draw it yourself.

sr for noob answer, why msk use trim(5460,5460) and why use many mt_expand()??

Reel.Deel
7th October 2022, 06:10
Trim(5460,5460) because that frame is all black with just the logo and text, perfect for creating a mask. mt_expand() is used to grow the mask outward. The text on the bottom left has a black outline and since frame #5460 is all black there no way to get the outline. Like I said, the mask can be improved but it took me just a few minutes to do that and the result was very good.

kedautinh12
7th October 2022, 06:20
Trim(5460,5460) because that frame is all black with just the logo and text, perfect for creating a mask. mt_expand() is used to grow the mask outward. The text on the bottom left has a black outline and since frame #5460 is all black there no way to get the outline. Like I said, the mask can be improved but it took me just a few minutes to do that and the result was very good.

Ok, thanks. Got it :D

VoodooFX
8th October 2022, 02:58
# Version 3.00 : Fixed: A frame selection scan result wasn't saved properly when "Automask=1" and "Inpaint" mode,
# now the deblending masks generation is up to twice faster in this scenario.
# New feature: Easy use of the ebmp masks on other videos, you can input them directly with "Mask" parameter.
# Ebmp format is changed, the masks from older versions are not compatible.
# New feature: Twice faster subtitles extraction with auto intermediate file.
# It's activated by negative "Extract" values.
# Requirements: LSMASH, TWriteAVI, x264vfw.
# New params: "ReExtract", "FourCC".
# New feature: Adjustable subs detection window, useful if video has non-middle subs alignment.
# New params: "DetWinPercW", "DetWinPercH", "DetWinHoPos".
# With "Show=12" you can see the subs detection window and correlation coefficient [CorrTh/Corr].
# New: "Turbo=-1", it activates an inpainting preset more suitable for UHD - HD resolutions.
# New: "IntSpd=4", similar as above.
# Basemask change: Background should be less than full white, logo - full white.
# Swapped "Turbo" 1 & 3.
# Removed "rSize" parameter.
# Reworked "Show=2", alternative to "Show=1" for positive Analyze.
# New feature: Various parameters to manipulate the deblending masks from positive analyze [for the experts only]:
# "YAlphaTweak", "UAlphaTweak", "VAlphaTweak",
# "YAlphaSolidIns", "UAlphaSolidIns", "VAlphaSolidIns",
# "YAlphaSolidOuts", "UAlphaSolidOuts", "VAlphaSolidOuts",
# "YColorSolid", "UColorSolid", "VColorSolid",
# "YColorSolidOuts", "UColorSolidOuts", "VColorSolidOuts",
# "YColorSolidIns", "UColorSolidIns", "VColorSolidIns",
# "YOffsetIns", "YOffsetOuts", "UVOffsetIns", "UVOffsetOuts", "ShiftMasksVe", "ShiftMasksHo",
# "YAlphaExternal", "WholeDeblend", "TriggerDynamic", "DumpMasks".
# Various other tweaks.
# Avisynth+ v3.7.2 or later is required.


Have fun. :)


I tried to improve it with temporal compensation, it does improve a little but needs more work.
I would be interested in your compensation script if it improves anything.

kedautinh12
8th October 2022, 04:27
Lol, many new parameters to remember :D

VoodooFX
8th October 2022, 12:44
Thank you very much.

I will test the temp script and im happy to see that i came with something you can use to get the script better for everyone.

Now you can adjust detection position with DetWinHoPos and use Show=12 for preview.
InpaintDelogo(Loc="60,566,-120,-30", Show=12, DynLocUp=2, DynMask=4, DynTune=170, DynMask4H=150, KillBlobs=-7, KillNoise=5, DetWinHoPos=0.8)

https://thumbs2.imgbox.com/55/de/iAFXeeBj_t.png (https://images2.imgbox.com/55/de/iAFXeeBj_o.png)


Comparison of Extract=1 vs Extract=-1 vs ReExtract=1 [read help about how to setup negative Extract]:

InpaintDelogo(Loc="60,566,-120,-30", Show=4, DynLocUp=2, DynMask=4, DynTune=170, DynMask4H=150, KillBlobs=-7, KillNoise=5,
\ Extract=1, ImgDir="D:\Subs", ImgInflate=1, CorrTh=0.7, DetWinHoPos=0.8)
InpaintDelogo(Loc="60,566,-120,-30", Show=4, DynLocUp=2, DynMask=4, DynTune=170, DynMask4H=150, KillBlobs=-7, KillNoise=5,
\ Extract=-1, ImgDir="D:\Subs", ImgInflate=1, CorrTh=0.7, DetWinHoPos=0.8)
InpaintDelogo(Loc="60,566,-120,-30", Show=4, DynLocUp=2, DynMask=4, DynTune=170, DynMask4H=150, KillBlobs=-7, KillNoise=5,
\ Extract=-1, ReExtract=1, ImgDir="D:\Subs", ImgInflate=1, CorrTh=0.7, DetWinHoPos=0.8)


https://thumbs2.imgbox.com/96/5c/ajkoYSr9_t.png (https://images2.imgbox.com/96/5c/ajkoYSr9_o.png) https://thumbs2.imgbox.com/d1/57/ZtakxOuj_t.png (https://images2.imgbox.com/d1/57/ZtakxOuj_o.png) https://thumbs2.imgbox.com/5e/6f/0Pfa86eS_t.png (https://images2.imgbox.com/5e/6f/0Pfa86eS_o.png)

Test.mkv file: https://drive.google.com/file/d/1Wi-JdltpVPIxd71gq4RlixEwiPnbky02/view?usp=sharing

Zetti
8th October 2022, 12:59
Thank you i will look into it.

VoodooFX
8th October 2022, 14:08
Lol, many new parameters to remember :D
There at the manual's bottom is filter() with all parameters and defaults, I copy/paste from there sometimes.
Anyway, "for the experts only", so you don't need to know them. :D

Btw, I think that v3 crossed some threshold, because avs v3.7.1 just ignores InpaintDelogo filter like it's commented out.



Still looking forward to it. :)
(Not so much on trying to figure out what they do exactly... but some means to tweak deblending... mhh... looks super-delicous.)

Here is a good sample to practice on hard to delogo video -> https://www.youtube.com/watch?v=hSXo5EMY-vA
There is a good quality 2K VP9 stream [not 1080p!], not all download tools can see that 2K stream [use 4KVideoDownloader].


Logo:
https://thumbs2.imgbox.com/92/c1/PL2OGi9Q_t.jpg (https://images2.imgbox.com/92/c1/PL2OGi9Q_o.jpg)

Delogo:
https://thumbs2.imgbox.com/e7/36/LzLp7FKl_t.jpg (https://images2.imgbox.com/e7/36/LzLp7FKl_o.jpg)

kedautinh12
8th October 2022, 14:16
Btw, can new parameters fix my problem??
https://forum.doom9.org/showthread.php?p=1975972#post1975972

kedautinh12
8th October 2022, 15:54
I meet new problem with circle logo
can anyone had suggest when use with InpaintDelogo??
https://imgur.com/gallery/9G8g3Bv
Source: https://drive.google.com/file/d/1tes_A7YPuKTWTJMIbHXMSde2CigJCGgJ/view?usp=sharing
Scripts:
ex_bob(nnedi3=true).SelectEven()
trim(38,6996)
InpaintDelogo(mask="C:\mask2.bmp", Automask=1, aMix=-10, Loc="84,44,-1260,-910", Mode="Inpaint")

kedautinh12
8th October 2022, 16:20
same error with left-bottom
https://imgur.com/gallery/HrQ3Vvg
Script:

ex_bob(nnedi3=true).SelectEven()
trim(224,6871)
InpaintDelogo(mask="C:\mask1.bmp", Automask=1, aMix=-50, Loc="78,916,-1180,-48", Mode="Inpaint")

VoodooFX
8th October 2022, 18:20
same error with left-bottom
https://imgur.com/gallery/HrQ3Vvg
What error? I see expected result of what you are doing.
Logo has shadow, so you are inpainting that shadow over letters.

VoodooFX
8th October 2022, 19:06
Btw, can new parameters fix my problem??
https://forum.doom9.org/showthread.php?p=1975972#post1975972
Split logo at the left and delogo separately.
To delogo at the right you can use ebmp from another video: https://drive.google.com/drive/folders/1QWixC2n9xy6ntt9JYr8FCsl5T3VDZuVl?usp=sharing

kedautinh12
9th October 2022, 01:26
What error? I see expected result of what you are doing.
Logo has shadow, so you are inpainting that shadow over letters.

But how i can erase that remain of black color??

kedautinh12
9th October 2022, 01:28
And can you have other ways to delogo with circle logo??

evafans
9th October 2022, 02:15
Do I need x265vfw if the video is x265?
Will negative "Extract" cause any problems like missing subs?

evafans
9th October 2022, 03:17
when I use reextract, it identifies the subs as trash, extract=1 works fine as usual. I'm sure x264vfw is installed.

plz ignore what I post, I miss the setup guide in the script.

VoodooFX
9th October 2022, 08:20
Do I need x265vfw if the video is x265?
Will negative "Extract" cause any problems like missing subs?
It has nothing to do with your source files, x264vfw is used for the intermediate files.
You can use any codec [which supports Y8] with "FourCC" parameter, but I tested them all [in various colorspaces] and x264 is fastest, actually I didn't tested x265 because I think that it can't be faster than x264.

If you didn't setup your x264vfw codec by my guide then by default it encodes with lossy & slow preset, in lossy mode the masks are damaged = subs are not detected or extracted subs/masks are damaged anyway.

If negative Extract encodes to lossless intermediate file then it will have exactly pixel to pixel same result as positive Extract.

VoodooFX
9th October 2022, 09:06
@kedautinh12
You are trying to delogo dozens of videos at once when you lack basics on things you are doing.
Stop for a second and try to successfully delogo one video after another, when you do that then you'll have more knowledge on next delogo tasks. :)

PS
I get my coffee and I'll look at your ~first video.

kedautinh12
9th October 2022, 09:55
@kedautinh12
You are trying to delogo dozens of videos at once when you lack basics on things you are doing.
Stop for a second and try to successfully delogo one video after another, when you do that then you'll have more knowledge on next delogo tasks. :)

PS
I get my coffee and I'll look at your ~first video.

I tried successful one video but you don't rep it
https://forum.doom9.org/showthread.php?p=1975980#post1975980

And i was successful some video but i don't post here. I just post when it had problems

VoodooFX
9th October 2022, 10:09
I tried successful one video but you don't rep it
I don't see any masks in that post, if you want me look at your script then I can't preview it if you didn't share all relevant files for it.

And there was a video you posted before it, and then Reel.Deel offered a better method for that video [if things fit correctly there]...

kedautinh12
9th October 2022, 10:54
ok, next video i was successful
https://forum.doom9.org/showthread.php?p=1975775#post1975775

Images: https://imgur.com/gallery/SbHQnft

Scripts:

ex_bob(nnedi3=true).SelectEven()
a1=trim(0,76)
b1=trim(77,198).InpaintDelogo(mask="C:\mask1.bmp", Automask=0, aMix=1, Loc="88,864,-980,-64", Mode="Inpaint", Analyze=3)
c1=trim(199,10848).InpaintDelogo(mask="C:\mask1.bmp", Automask=0, aMix=1, Loc="88,864,-980,-64", Mode="Deblend")
d1=trim(10849,10866).InpaintDelogo(mask="C:\mask1.bmp", Automask=0, aMix=1, Loc="88,864,-980,-64", Mode="Inpaint", Analyze=3)
e1=trim(10867,0)
a1++b1++c1++d1++e1

a2=trim(0,45)
b2=trim(46,59).InpaintDelogo(mask="C:\Logo_M-ON_Old.bmp", Automask=0, aMix=1, Loc="1252,878,-90,-64", Mode="Inpaint",Analyze=3)
c2=trim(60,10909).InpaintDelogo(mask="C:\Logo_M-ON_Old.bmp", Automask=0, aMix=1, Loc="1252,878,-90,-64", Mode="Deblend")
d2=trim(10910,10923).InpaintDelogo(mask="C:\Logo_M-ON_Old.bmp", Automask=0, aMix=1, Loc="1252,878,-90,-64", Mode="Inpaint",Analyze=3)
e2=trim(10924,0)
a2++b2++c2++d2++e2

VoodooFX
9th October 2022, 11:37
That video was resolved long time ago, if you are lost in your spam then here is your next relevant post -> https://forum.doom9.org/showpost.php?p=1975905

kedautinh12
9th October 2022, 12:00
That video was resolved long time ago, if you are lost in your spam then here is your next relevant post -> https://forum.doom9.org/showpost.php?p=1975905

But with dynamic part of logo, i successful myself

kedautinh12
9th October 2022, 12:11
I will try that video, just wait :D

kedautinh12
9th October 2022, 14:23
Split logo at the left and delogo separately.
To delogo at the right you can use ebmp from another video: https://drive.google.com/drive/folders/1QWixC2n9xy6ntt9JYr8FCsl5T3VDZuVl?usp=sharing

When i split logo at the left and delogo separately but still small black bar between 2 logo
Frame 1944
https://i.imgur.com/FPm6Srd.png

Images: https://imgur.com/a/0o9F9ZV

Scripts:
ex_bob(nnedi3=true).SelectEven()
trim(165,7898)
InpaintDelogo(mask="C:\mask3.bmp", Automask=0, aMix=-20, Loc="88,862,-980,-142", Mode="Deblend", Analyze=3)
InpaintDelogo(mask="C:\mask4.bmp", Automask=0, aMix=-20, Loc="88,938,-980,-64", Mode="Deblend", Analyze=3)

VoodooFX
9th October 2022, 14:56
That black line is at non mod2 place, so you need use conversion to RGB if you want to split exactly at that black line.

kedautinh12
9th October 2022, 15:42
That black line is at non mod2 place, so you need use conversion to RGB if you want to split exactly at that black line.

Still black bar and i seen blur box covert logo when convert to RGB
frame 1401
https://i.imgur.com/PqOPgU0.png
Images: https://imgur.com/a/cFKRlZR
Scripts:

ex_bob(nnedi3=true).SelectEven()
converttoRGB()
trim(165,7898)
InpaintDelogo(mask="C:\mask3.bmp", Automask=0, aMix=-20, Loc="88,864,-980,-142", Mode="Deblend", Analyze=3)
InpaintDelogo(mask="C:\mask4.bmp", Automask=0, aMix=-20, Loc="88,936,-980,-64", Mode="Deblend", Analyze=3)

kedautinh12
9th October 2022, 16:07
About Right Logo, your .ebmp don't different result with my .ebmp. Still black color beside black bar bottom but i think it's very good when sceen don't have both-top black bar
https://i.imgur.com/JTe4HDD.png
Images: https://imgur.com/gallery/2V8hDLB
Scripts:
ex_bob(nnedi3=true).SelectEven()
trim(45,7957)
InpaintDelogo(mask="C:\mask5.bmp", Automask=0, aMix=1, Loc="1252,878,-90,-64", Mode="Deblend")

VoodooFX
9th October 2022, 16:34
You just converted to RGB and you cut at exactly same [not where letterbox border is] location, how do you expect different result?

Look at my script:

https://thumbs2.imgbox.com/c4/b1/rweTmQFq_t.jpg (https://images2.imgbox.com/c4/b1/rweTmQFq_o.jpg)


#LWLibAvVideoSource("D:\Otome Shinto.ts").TFM() # to lossless
v=LWLibAvVideoSource("D:\Otome Shinto_lossless.mkv").Trim(178,7791)

logoRGB = v.Crop(78,852,-980,-54).ConvertToRGB24(matrix="Rec709")
topLogo = logoRGB.Crop(0,1,-0,-87).ConvertToYV12(matrix="Rec709")
botLogo = logoRGB.Crop(0,87,-0,-7).ConvertToYV12(matrix="Rec709")

topDelogo = topLogo.InpaintDelogo( mask="D:\top.bmp", Loc="0,0,0,0", Mode="Deblend", Analyze=2, NoBorderAt="bottom")
botDelogo = botLogo.InpaintDelogo( mask="D:\bot.bmp", Loc="0,0,0,0", Mode="Deblend", Analyze=3)

logoRGB = logoRGB.Overlay(topDelogo.ConvertToRGB24(matrix="Rec709"), x=0, y=1)
logoRGB = logoRGB.Overlay(botDelogo.ConvertToRGB24(matrix="Rec709"), x=0, y=87)
logoYV12= logoRGB.ConvertToYV12(matrix="Rec709")

v.Overlay(logoYV12, x=78, y=852)
InpaintDelogo( mask="D:\M-On!.1080_1252-878.ebmp", Loc="1252,878,0,0", IntSpd=4)


Masks: https://we.tl/t-0yPMVitm2k

kedautinh12
9th October 2022, 17:12
Wow, very good. Ok, i will check tomorrow :D

VoodooFX
9th October 2022, 19:17
...can you suggest if this can better, VX?
Add Turbo=-1 to all inpaint parts.
Add IntSpd=4 to your left deblend.
Disable Interp [Interp=0] on your right deblend and use M-On!.1080.Small (https://drive.google.com/drive/folders/1QWixC2n9xy6ntt9JYr8FCsl5T3VDZuVl) mask on it.

kedautinh12
10th October 2022, 15:25
You just converted to RGB and you cut at exactly same [not where letterbox border is] location, how do you expect different result?

Look at my script:


#LWLibAvVideoSource("D:\Otome Shinto.ts").TFM() # to lossless
v=LWLibAvVideoSource("D:\Otome Shinto_lossless.mkv").Trim(178,7791)

logoRGB = v.Crop(78,852,-980,-54).ConvertToRGB24(matrix="Rec709")
topLogo = logoRGB.Crop(0,1,-0,-87).ConvertToYV12(matrix="Rec709")
botLogo = logoRGB.Crop(0,87,-0,-7).ConvertToYV12(matrix="Rec709")

topDelogo = topLogo.InpaintDelogo( mask="D:\top.bmp", Loc="0,0,0,0", Mode="Deblend", Analyze=2, NoBorderAt="bottom")
botDelogo = botLogo.InpaintDelogo( mask="D:\bot.bmp", Loc="0,0,0,0", Mode="Deblend", Analyze=3)

logoRGB = logoRGB.Overlay(topDelogo.ConvertToRGB24(matrix="Rec709"), x=0, y=1)
logoRGB = logoRGB.Overlay(botDelogo.ConvertToRGB24(matrix="Rec709"), x=0, y=87)
logoYV12= logoRGB.ConvertToYV12(matrix="Rec709")

v.Overlay(logoYV12, x=78, y=852)
InpaintDelogo( mask="D:\M-On!.1080_1252-878.ebmp", Loc="1252,878,0,0", IntSpd=4)


Masks: https://we.tl/t-0yPMVitm2k

Your script very good but in sceen without black borders still bar but not black bar. I think result better
frame 2029
https://i.imgur.com/uINtbia.png

Edit: And your file Logo .ebmp in right had fix my error. Thanks

VoodooFX
10th October 2022, 16:02
@kedautinh12
Learn to post the frame numbers of your images.

kedautinh12
10th October 2022, 16:29
@kedautinh12
Learn to post the frame numbers of your images.

sr forgot it. edited post

kedautinh12
10th October 2022, 16:39
With your help, i can Delogo left logo is good. Thanks

Scripts for whole video:

ex_bob(nnedi3=true).SelectEven()

a1=trim(0,62)

b=LWLibAvVideoSource("C:\Users\ADMIN\Downloads\Otome Shinto - Ame to Namida to Otome to Taiyaki [1440x1080 h264 M-ON! HD].video-muxed_0.mkv").Trim(63,116)
logoRGB = b.Crop(78,852,-980,-54).ConvertToRGB24(matrix="Rec709")
topLogo = logoRGB.Crop(0,1,-0,-87).ConvertToYV12(matrix="Rec709")
topDelogo = topLogo.InpaintDelogo(mask="C:\mask3.bmp", Automask=0, Loc="0,0,0,0", Mode="Inpaint", Analyze=2, NoBorderAt="bottom", Turbo=-1)
logoRGB = logoRGB.Overlay(topDelogo.ConvertToRGB24(matrix="Rec709"), x=0, y=1)
logoYV12= logoRGB.ConvertToYV12(matrix="Rec709")
b1=b.Overlay(logoYV12, x=78, y=852)

c=LWLibAvVideoSource("C:\Users\ADMIN\Downloads\Otome Shinto - Ame to Namida to Otome to Taiyaki [1440x1080 h264 M-ON! HD].video-muxed_0.mkv").Trim(117,126)
logoRGB = c.Crop(78,852,-980,-54).ConvertToRGB24(matrix="Rec709")
topLogo = logoRGB.Crop(0,1,-0,-87).ConvertToYV12(matrix="Rec709")
botLogo = logoRGB.Crop(0,87,-0,-7).ConvertToYV12(matrix="Rec709")
topDelogo = topLogo.InpaintDelogo(mask="C:\mask3.bmp", Automask=0, Loc="0,0,0,0", Mode="Inpaint", Analyze=2, NoBorderAt="bottom", Turbo=-1)
botDelogo = botLogo.InpaintDelogo( mask="C:\mask4.bmp", Automask=0, Loc="0,0,0,0", Mode="Inpaint", Analyze=3, Turbo=-1)
logoRGB = logoRGB.Overlay(topDelogo.ConvertToRGB24(matrix="Rec709"), x=0, y=1)
logoRGB = logoRGB.Overlay(botDelogo.ConvertToRGB24(matrix="Rec709"), x=0, y=87)
logoYV12= logoRGB.ConvertToYV12(matrix="Rec709")
c1=c.Overlay(logoYV12, x=78, y=852)

d=LWLibAvVideoSource("C:\Users\ADMIN\Downloads\Otome Shinto - Ame to Namida to Otome to Taiyaki [1440x1080 h264 M-ON! HD].video-muxed_0.mkv").Trim(127,165)
logoRGB = d.Crop(78,852,-980,-54).ConvertToRGB24(matrix="Rec709")
topLogo = logoRGB.Crop(0,1,-0,-87).ConvertToYV12(matrix="Rec709")
botLogo = logoRGB.Crop(0,87,-0,-7).ConvertToYV12(matrix="Rec709")
topDelogo = topLogo.InpaintDelogo(mask="C:\mask3.bmp", Automask=0, Loc="0,0,0,0", Mode="Deblend", Analyze=2, NoBorderAt="bottom", IntSpd=4)
botDelogo = botLogo.InpaintDelogo( mask="C:\mask4.bmp", Automask=0, Loc="0,0,0,0", Mode="Inpaint", Analyze=3, Turbo=-1)
logoRGB = logoRGB.Overlay(topDelogo.ConvertToRGB24(matrix="Rec709"), x=0, y=1)
logoRGB = logoRGB.Overlay(botDelogo.ConvertToRGB24(matrix="Rec709"), x=0, y=87)
logoYV12= logoRGB.ConvertToYV12(matrix="Rec709")
d1=d.Overlay(logoYV12, x=78, y=852)

e=LWLibAvVideoSource("C:\Users\ADMIN\Downloads\Otome Shinto - Ame to Namida to Otome to Taiyaki [1440x1080 h264 M-ON! HD].video-muxed_0.mkv").Trim(166,7898)
logoRGB = e.Crop(78,852,-980,-54).ConvertToRGB24(matrix="Rec709")
topLogo = logoRGB.Crop(0,1,-0,-87).ConvertToYV12(matrix="Rec709")
botLogo = logoRGB.Crop(0,87,-0,-7).ConvertToYV12(matrix="Rec709")
topDelogo = topLogo.InpaintDelogo(mask="C:\mask3.bmp", Automask=0, Loc="0,0,0,0", Mode="Deblend", Analyze=2, NoBorderAt="bottom", IntSpd=4)
botDelogo = botLogo.InpaintDelogo( mask="C:\mask4.bmp", Automask=0, Loc="0,0,0,0", Mode="Deblend", Analyze=3, IntSpd=4)
logoRGB = logoRGB.Overlay(topDelogo.ConvertToRGB24(matrix="Rec709"), x=0, y=1)
logoRGB = logoRGB.Overlay(botDelogo.ConvertToRGB24(matrix="Rec709"), x=0, y=87)
logoYV12= logoRGB.ConvertToYV12(matrix="Rec709")
e1=e.Overlay(logoYV12, x=78, y=852)

f=LWLibAvVideoSource("C:\Users\ADMIN\Downloads\Otome Shinto - Ame to Namida to Otome to Taiyaki [1440x1080 h264 M-ON! HD].video-muxed_0.mkv").Trim(7899,7913)
logoRGB = f.Crop(78,852,-980,-54).ConvertToRGB24(matrix="Rec709")
topLogo = logoRGB.Crop(0,1,-0,-87).ConvertToYV12(matrix="Rec709")
botLogo = logoRGB.Crop(0,87,-0,-7).ConvertToYV12(matrix="Rec709")
topDelogo = topLogo.InpaintDelogo(mask="C:\mask3.bmp", Automask=0, Loc="0,0,0,0", Mode="Inpaint", Analyze=2, NoBorderAt="bottom", Turbo=-1)
botDelogo = botLogo.InpaintDelogo( mask="C:\mask4.bmp", Automask=0, Loc="0,0,0,0", Mode="Inpaint", Analyze=3, Turbo=-1)
logoRGB = logoRGB.Overlay(topDelogo.ConvertToRGB24(matrix="Rec709"), x=0, y=1)
logoRGB = logoRGB.Overlay(botDelogo.ConvertToRGB24(matrix="Rec709"), x=0, y=87)
logoYV12= logoRGB.ConvertToYV12(matrix="Rec709")
f1=f.Overlay(logoYV12, x=78, y=852)

g1=trim(7914,0)

a1++b1++c1++d1++e1++f1++g1

file: https://drive.google.com/file/d/1bY9QNucEo-F_xJgc6MMChTZNzG9I9pE2/view?usp=sharing

VoodooFX
10th October 2022, 16:42
frame 2029
Try again, I don't see anything like this at this frame. Maybe post timing then...

kedautinh12
10th October 2022, 16:47
Try again, I don't see anything like this at this frame.

i think this error from you and me use different deinterlaced

kedautinh12
10th October 2022, 16:53
i think this error from you and me use different deinterlaced

With tfm() error was gone. thanks.

Edit: I relized your both logo file only use for tfm(), can't use for another Deinterlaced :D

VoodooFX
10th October 2022, 17:07
Only God knows what you are doing there. :D

Reel.Deel
10th October 2022, 17:28
@kedautinh12

Your sources (at least the last 3 samples you've posted) are telecined. There is no need to deinterlace them, unless you want lower quality. Earlier I saw you were using LWLibavVideoSource("source.ts", fpsnum=24000, fpsden=1001) and now ex_bob(nnedi3=true).SelectEven(), I agree with VoodooFX - who knows what you're doing.

kedautinh12
10th October 2022, 17:28
Only God knows what you are doing there. :D

You know, sometime God can't know what i am doing here :D

VoodooFX
10th October 2022, 17:46
You know, sometime God can't know what i am doing here :D
I don't even want to know why you load same video five times in your script [at the top of this page], looks messy...
Let me know when you are on the next video/problem. :)

kedautinh12
10th October 2022, 17:51
Add Turbo=-1 to all inpaint parts.
Add IntSpd=4 to your left deblend.
Disable Interp [Interp=0] on your right deblend and use M-On!.1080.Small (https://drive.google.com/drive/folders/1QWixC2n9xy6ntt9JYr8FCsl5T3VDZuVl) mask on it.

With your help, result better very much, althought it isn't good as Reel.Deel but still very good, thanks
https://imgsli.com/MTI5NDky

Scripts:
a0=trim(0,49)
b0=trim(50,5488).InpaintDelogo(mask="C:\Left_Top_Letter.bmp", Automask=0, aMix=0, Loc="50,40,-1186,-910", Mode="Inpaint", Turbo=-1)
c0=trim(5489,0)
a0++b0++c0

a1=trim(0,53)
b1=trim(54,119).InpaintDelogo(mask="C:\mask6.bmp", Automask=0, aMix=-10, Loc="60,880,-1094,-50", Mode="Inpaint", Analyze=3, Turbo=-1)
c1=trim(120,5477).InpaintDelogo(mask="C:\mask6.bmp", Automask=0, aMix=-10, Loc="60,880,-1094,-50", Mode="Deblend", IntSpd=4)
d1=trim(5478,5491).InpaintDelogo(mask="C:\mask6.bmp", Automask=0, aMix=-10, Loc="60,880,-1094,-50", Mode="Inpaint", Analyze=3, Turbo=-1)
e1=trim(5492,0)
a1++b1++c1++d1++e1

a2=trim(0,25)
b2=trim(26,37).InpaintDelogo(mask="C:\Logo_M-ON_New.ebmp", Automask=0, aMix=0, Loc="1284,904,0,0", Mode="Inpaint", Analyze=3, Turbo=-1)
c2=trim(38,5526).InpaintDelogo(mask="C:\Logo_M-ON_New.ebmp", Automask=0, aMix=0, Loc="1284,904,0,0", Mode="Deblend", Interp=0)
d2=trim(5527,5538).InpaintDelogo(mask="C:\Logo_M-ON_New.ebmp", Automask=0, aMix=0, Loc="1284,904,0,0", Mode="Inpaint", Analyze=3, Turbo=-1)
e2=trim(5539,0)
a2++b2++c2++d2++e2

kedautinh12
10th October 2022, 17:53
I don't even want to know why you load same video five times in your script [at the top of this page], looks messy...
Let me know when you are on the next video/problem. :)

I posted here but you forgot it, #555 and #556
https://forum.doom9.org/showthread.php?p=1976151#post1976151

VoodooFX
10th October 2022, 18:03
With your help, result better very much, althought it isn't good as Reel.Deel but still very good, thanks

I don't need to know about every successful delogo. :)
Told you that myself:
Reel.Deel offered a better method for that video [if things fit correctly there]



I posted here but you forgot it, #555 and #556
I'll take a look at it.

kedautinh12
10th October 2022, 18:24
I don't need to know about every successful delogo. :)

I think you will happy if help other people successful delogo :D

VoodooFX
10th October 2022, 19:14
I meet new problem with circle logo
https://imgur.com/gallery/9G8g3Bv
Source: https://drive.google.com/file/d/1tes_A7YPuKTWTJMIbHXMSde2CigJCGgJ/view?usp=sharing
ex_bob(nnedi3=true).SelectEven()
trim(38,6996)
InpaintDelogo(mask="C:\mask2.bmp", Automask=1, aMix=-10, Loc="84,44,-1260,-910", Mode="Inpaint")


You are using Inpaint when top logo is transparent there and you are not leaving enough space from logo borders in Loc.

Deblend & positive Analyze doesn't build proper alpha on V channel, you can see with Show=2. AMSS0815 is not around anymore to ask why it's like that, probably because there's not much colors in that clip [and I use AVSInpaint in not intended ways], but why then alpha on U is build...
Anyway, use negative Analyze, delogo looks not bad with it [later I'll look if it can be done better]:

#LWLibAvVideoSource("D:\Otome Shinto.ts").QTGMC( Preset="Medium", Sharpness=0.0).SelectEven() # to lossless
LWLibAvVideoSource("D:\Otome Shinto_lossless.mkv").Trim(48,6990)
InpaintDelogo( mask="D:\mask.bmp", Loc="76,40,-1252,-904", Mode="Deblend", Analyze=-2, dPP=5, IntSpd=4)

#Crop(76,40,-1252,-904) #to take screenshots

Frame 774:

Original vs Yours vs Analyze=2 vs Analyze=-2


https://i.imgur.com/1jE7FyX.png https://i.imgur.com/3uE643k.png https://i.imgur.com/D9Ltq3D.png https://i.imgur.com/PcMvXF4.png

Basemask: https://i.imgur.com/0zWhTWP.png



BOTTOM LOGO:

You didn't created a proper basemask of whole logo.
Automask can't create precise mask for very faint shadow's edges like this, so you need to make a basemask by yourself.
Shadow is transparent and letters are not, so use Both mode [use Show=1 to adjust opaque mask]:

#LWLibAvVideoSource("D:\Otome Shinto.ts").QTGMC( Preset="Medium", Sharpness=0.0).SelectEven() # to lossless
LWLibAvVideoSource("D:\Otome Shinto_lossless.mkv").Trim(220,6767)

InpaintDelogo( mask="D:\mask2.png", Loc="60,900,-1160,-30", Analyze=3, Mode="Both", oTune=-7, oTinflate=2, dPP=5, IntSpd=4, Turbo=-1)


#Crop(60,900,-1160,-30) # to take screenshots

Frame 1297:

Original vs Yours vs My

https://i.imgur.com/8THKQHQ.png https://i.imgur.com/p9iGTzx.png https://i.imgur.com/K7FFllp.png

Masks: https://we.tl/t-mYhaD6ppsQ

kedautinh12
11th October 2022, 12:57
You are using Inpaint when top logo is transparent there and you are not leaving enough space from logo borders in Loc.

Deblend & positive Analyze doesn't build proper alpha on V channel, you can see with Show=2. AMSS0815 is not around anymore to ask why it's like that, probably because there's not much colors in that clip [and I use AVSInpaint in not intended ways], but why then alpha on U is build...
Anyway, use negative Analyze, delogo looks not bad with it [later I'll look if it can be done better]:

#LWLibAvVideoSource("D:\Otome Shinto.ts").QTGMC( Preset="Medium", Sharpness=0.0).SelectEven() # to lossless
LWLibAvVideoSource("D:\Otome Shinto_lossless.mkv").Trim(48,6990)
InpaintDelogo( mask="D:\mask.bmp", Loc="76,40,-1252,-904", Mode="Deblend", Analyze=-2, dPP=5, IntSpd=4)

#Crop(76,40,-1252,-904) #to take screenshots

Basemask: https://i.imgur.com/0zWhTWP.png



BOTTOM LOGO:

You didn't created a proper basemask of whole logo.
Automask can't create precise mask for very faint shadow's edges like this, so you need to make a basemask by yourself.
Shadow is transparent and letters are not, so use Both mode [use Show=1 to adjust opaque mask]:

#LWLibAvVideoSource("D:\Otome Shinto.ts").QTGMC( Preset="Medium", Sharpness=0.0).SelectEven() # to lossless
LWLibAvVideoSource("D:\Otome Shinto_lossless.mkv").Trim(220,6767)

InpaintDelogo( mask="D:\mask2.png", Loc="60,900,-1160,-30", Analyze=3, Mode="Both", oTune=-7, oTinflate=2, dPP=5, IntSpd=4, Turbo=-1)


#Crop(60,900,-1160,-30) # to take screenshots

Masks: https://we.tl/t-mYhaD6ppsQ

I think result is good, thanks

VoodooFX
11th October 2022, 13:11
I've fixed positive Analyze delogo, need to do more tests. Do you have other colored logo?

kedautinh12
11th October 2022, 13:52
I've fixed positive Analyze delogo, need to do more tests. Do you have other colored logo?

here:
https://drive.google.com/file/d/1Z8O3IK8vXYsDowfjdGen3c8XxuoiQwwx/view?usp=sharing

VoodooFX
11th October 2022, 14:21
Thanks, but logo there is almost always in a black background, I need video where logo is in various backgrounds, same red logo is OK too.

kedautinh12
11th October 2022, 14:42
Thanks, but logo there is almost always in a black background, I need video where logo is in various backgrounds, same red logo is OK too.

Waiting. I'm uploading more backgrounds for your test :D

kedautinh12
11th October 2022, 15:02
https://drive.google.com/file/d/13i01ajr01NjjtXqMaSeH-HjVW1n91ahH/view?usp=sharing

https://drive.google.com/file/d/1Mz4T2fSuyPeW0UkCFGZ1mVjhtX1p3YcD/view?usp=sharing

https://drive.google.com/file/d/1a-Z5j3ElMqbnKr9Q39EoIlYTBLbqz4hg/view?usp=sharing

kedautinh12
11th October 2022, 16:30
here:
https://drive.google.com/file/d/1Z8O3IK8vXYsDowfjdGen3c8XxuoiQwwx/view?usp=sharing

with this Blue Logo, i can't got logo mask correctly

Top Logo:
trim(0,7362)
InpaintDelogo(mask="C:\mask2.bmp", Automask=1, aMix=0, Loc="100,40,-1666,-904", Mode="Deblend", Analyze=-2, IntSpd=4)
Bottom Credit:
trim(162,7285)
InpaintDelogo(mask="C:\mask2.bmp", Loc="110,820,-1330,-46", Automask=0, aMix=-46, Analyze=3, Mode="Both", IntSpd=4, Turbo=-1)
With bottom credit, i can't create mask cover black shadow like Red Logo

Reel.Deel
11th October 2022, 16:31
Good job VoodooFX.

Your result vs "official" video (https://www.youtube.com/watch?v=saah9UTwaUI):

Frame 774 (688):
https://i.imgur.com/PcMvXF4.png https://i.ibb.co/N33vHQY/Clattanoia-Ox-T-688.png

Frame 1297 (1244):
https://i.imgur.com/K7FFllp.png https://i.ibb.co/PTLV7s2/Clattanoia-Ox-T-1244.png

VoodooFX
11th October 2022, 17:36
Good job VoodooFX.

Top delogo is not good there [for reason posted], it will be better in next version.
Bottom delogo could be better with this conditional feature (https://github.com/AviSynth/AviSynthPlus/issues/298), currently the detailed frames suffer a bit in favor of better looking the solid background frames.

That frame is not very "detailed" but in the middle I added how frame looks if "in favor of the detailed frames" case:

https://i.imgur.com/K7FFllp.png https://i.imgur.com/NZ4W7mB.png https://i.ibb.co/PTLV7s2/Clattanoia-Ox-T-1244.png

with this Blue Logo, i can't got logo mask correctly
Told you that video is not good for test/masking.
Learn to create basic masks yourself, it's MS Paint level skill... there are hundreds image editing programs, even Avs can be used to reproduce Mona Lisa. :D

StainlessS
11th October 2022, 22:40
Bottom delogo could be better with this conditional feature,
[Feature request] masked MinMaxDifference

Hows bout,

****************************************
******* MASKED Luma Y Functions ********
****************************************

Compile time/runtime functions, Planar, YUY2, RGB24 & RGB32. (RGB internally converted to YUV-Y).

The compiletime/runtime clip functions share some common characteristics:-

The 'n' arg is an optional frame number and defaults to 'current_frame' if not specified.
The x,y,w,h, coords specify the source rectangle under scrutiny and are specified as for Crop(), the default 0,0,0,0 is full frame.
If 'interlaced' is true, then every other line is ommited from the scan, so if eg y=1, then scanlines 1,3,5,7 etc are scanned,
if eg y=4 then scanlines 4,6,8,10 etc are scanned. The 'h' coord specifies the full height scan ie same whether interlaced is true
or false, although it will not matter if the 'h' coord is specified as eg odd or even, internally the height 'h' is reduced by 1
when interlaced=true and 'h' is even.

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

The optional mask clip, governs which pixels are processed by the functions. Where a luma pixel in selected area of the the mask clip is
in range "MaskMin" to "MaskMax" inclusive, then those pixels will be processed. The Mask must also be Planar but not
necessarily the same colorspace as clip c, also must be same dimensions and have at least the same number of frames as clip c.
Calling without mask clip OR with MaskMin=0,MaskMax=255 will effectively ignore the mask and scan full x,y,w,h area.



RT_YPlaneMinMaxDifference(clip c,int "n"=current_frame,int "delta"=0,int "x"=0,int "y"=0,int "w"=0,int "h"=0,
bool "interlaced"=false,float "threshold"=0.0, int "Matrix"=(Width>1100||Height>600?3:2),clip "mask"=NOT_USED,int "MaskMin"=128,"MaskMax"=255)
Return int -1, if no valid pixels in Mask clip.
Returns int value luma range (maximum - minimum difference) (0 -> 255) in frame(n+delta) for area x,y,w,h.
Threshold is a percentage, stating how many percent of the pixels are allowed below minimum or above maximum (ignore extreme pixels ie noise).
Threshold is % of valid mask pixels processed if Mask supplied. The threshold is optional and defaults to 0.0.


8 bit only.

VoodooFX
12th October 2022, 00:17
# Version 3.1 : 2022/10/11. Fixed: "Deblend" with positive "Analyze" was unreliable on the colored logos.

Issue was gross, but not so apparent on the long videos.

Original / pre-v3.1 bug Analyze=2 / deprecated Analyze=-2 / v3.1 Analyze=2 / + TriggerDynamic=1 hack / Reel.Deel's "official":
[the differences would be more visible without Interp & dPP blur]


https://i.imgur.com/1jE7FyX.png https://i.imgur.com/D9Ltq3D.png https://i.imgur.com/PcMvXF4.png https://i.imgur.com/KYbxaZf.png https://i.imgur.com/Gof9Sdp.png https://i.ibb.co/N33vHQY/Clattanoia-Ox-T-688.png


RT_YPlaneMinMaxDifference

You thought about everything when you made RT_Stats. :)

I wanted to do a check inside the logos too, now the suitable frames search is looking only at the outsides [managed to do it with some workarounds, but it can't be done for the insides].
Some unsuitable stuff can be only inside logo and it can "crawl" into the masks.

For example, trash burned inside logo alpha:
https://i.imgur.com/fKsudYc.png

StainlessS
12th October 2022, 02:40
You thought about everything
I think was Martin53 request.

kedautinh12
12th October 2022, 05:18
This is what you said: "masking with mspaint"??
https://m.youtube.com/watch?v=OtVR9_Ua-C8

VoodooFX
12th October 2022, 05:43
This is what you said: "masking with mspaint"??
https://m.youtube.com/watch?v=OtVR9_Ua-C8
Yeap, basic masking, just paint full white over an image and that's called a mask, InpaintDelogo will convert non full white pixels to black automatically.
MS Paint is OK to mask some squares, other shapes are easier with more sophisticated tools like Photoshop ect..

kedautinh12
12th October 2022, 06:05
Photoshop very complicated for me :D

kedautinh12
12th October 2022, 16:29
Red Logo HD:
https://drive.google.com/file/d/19iB1ttvhIPeZ1uUIo6544n9BnEmMQbTI/view?usp=sharing

VoodooFX
12th October 2022, 16:41
Photoshop very complicated for me :D
Here is mask for it: https://i.imgur.com/q121iFL.png
Top logo in "Daichi Miura" video is always in a solid background, just use Inpaint on it.
How that tv channel is called with "S" logo?

kedautinh12
12th October 2022, 16:54
Here is mask for it: https://i.imgur.com/q121iFL.png
Top logo in "Daichi Miura" video is always in a solid background, just use Inpaint on it.
How that tv channel is called with "S" logo?

Thank, i think i can use mask from other video i created successful but thanks for your Logo

Full name is SSTV (Blue Logo) and SSTV+ (Red Logo)

Edited: how about bottom letters??

VoodooFX
12th October 2022, 17:48
Red Logo HD:
SSTV+.v2.1080 (https://drive.google.com/drive/folders/1QWixC2n9xy6ntt9JYr8FCsl5T3VDZuVl?usp=sharing)
If you have many same logo clips then a better deblending mask could be build if you analyze them all. [sometimes there are not so visible differences and some clip can make it worse]

how about bottom letters??
If you can't deblend it then inpaint it too.

kedautinh12
13th October 2022, 14:25
If Daichi Miura hard to got mask, you can try with this for (1920x1080i):
https://drive.google.com/file/d/1Dc_xJLKtAr0Oz_JWPmFJ7npt9j4874No/view?usp=sharing

VoodooFX
15th October 2022, 19:58
If Daichi Miura hard to got mask, you can try with this for (1920x1080i):

Added as "SSTV.v2.1080" to the logo collection folder.
Still there is no point in deblending top "Daichi Miura" logo as inpainting would be much better on this video.

Try that video with InpaintDelogo from temp branch (https://github.com/Purfview/InpaintDelogo/tree/temp), Inpaint should be very fast on it.
Use Optimize=1 to enable faster conditional inpainting, visually it shouldn't look worse than with normal inpainting. [Not tested, atm just quick theoretical implementation]

PS:
Btw, ebmp mask can be used for Inpaint mode too.

kedautinh12
16th October 2022, 03:02
Added as "SSTV.v2.1080" to the logo collection folder.
Still there is no point in deblending top "Daichi Miura" logo as inpainting would be much better on this video.

Try that video with InpaintDelogo from temp branch (https://github.com/Purfview/InpaintDelogo/tree/temp), Inpaint should be very fast on it.
Use Optimize=1 to enable faster conditional inpainting, visually it shouldn't look worse than with normal inpainting. [Not tested, atm just quick theoretical implementation]

PS:
Btw, ebmp mask can be used for Inpaint mode too.

How about Turbo=-2?? Result will better than -1 very much?? And optimise=1 only use for Inpainting?? How if it's use for deblending and both mode??

VoodooFX
16th October 2022, 11:39
How about Turbo=-2?? Result will better than -1 very much??
You tell me. "-2" I not tested at all, with "-1" I came up only from one video, with "0" I came up as generally best after a lot of SD de-logos.

And optimise=1 only use for Inpainting?? How if it's use for deblending and both mode??
Currently should work only in Inpaint mode, in the future something similar can be implemented for other modes.
Anyway, Optimize is not tested at all, so you tell me if there is increase in speed and if there is no ~visible quality loss.

EDIT:
Btw, Inpaint mode should benefit from Prefetch().

kedautinh12
16th October 2022, 12:24
Ok, thanks for your help, i will test more to understand your scripts :D

VoodooFX
16th October 2022, 17:02
How about Turbo=-2?? Result will better than -1 very much??
Inpainting is kinda fluid, you can't have strict good settings for it, only some generally ~OK settings, and it depends from how big your logo is and from the content around logo.
I think "-2" should be more suitable for UHD. On the small logos I expect it to hurt quality.

How to compare inpainting: Don't look at the single frames, you need to watch video on original speed, least noticeable delogo = better.

https://i.imgur.com/CXE1OWd.png https://i.imgur.com/O3NiNc8.png

Tested speed on "Daichi Miura" logo:
175.4 FPS with Optimize=1
25.61 FPS with Optimize=0


Mask: https://fileupload.win/hTjOZdRLAvkcO06
Forgot to tell you, that site offered me to download a Vittalia Trojan (https://howtofix.guide/trojan-vittalia/) 3 times before it gave me your file.

kedautinh12
16th October 2022, 17:25
Ok, thanks for your guide :D

cagure
16th October 2022, 19:52
Hi VoodooFX

For my convenience, I would like to remove these subtitles,

but I can't get your script to work,

I use this :

1)
LWLibavVideoSource("BL.mkv") ## Source is 3840x2160
z_Spline36Resize(dither="error_diffusion",1920,1080)
InpaintLoc(Loc="126,886,-1118,-128")
https://thumbs2.imgbox.com/d2/4d/I9zibBT2_t.png (https://imgbox.com/I9zibBT2)


2)
LWLibavVideoSource("BL.mkv")
z_Spline36Resize(dither="error_diffusion",1920,1080)
InpaintDelogo(automask=1,analyze=2, mask="E:\Gt\logomask.bmp" ,Loc="126,886,-1118,-128",Turbo=1) ### to create the 2 masks :


but the 2 masks are all 2 black https://slow.pics/c/pT50uuqb

3)
LWLibavVideoSource("BL.mkv") ## Source is 3840x2160
z_Spline36Resize(dither="error_diffusion",1920,1080)
InpaintDelogo(mask="E:\Gt\logomask.bmp",automask=0 ,Loc="126,886,-1118,-128",, Mode="Inpaint") #Deblend and Both don't works
https://thumbs2.imgbox.com/4e/48/PlFTT4nF_t.png (https://imgbox.com/PlFTT4nF)

but it practically doesn't work, surely I'm wrong something,
I got this frame, but there are other subtitles and in different x, y on the frames,
I can probably recall them with conditional filter with others masks, but in the meantime I would like to start it
i checked there are all the .dlls, i didn't install x264vfw
S.O. 7 64bit
Cheers

VoodooFX
16th October 2022, 20:20
but it practically doesn't work, surely I'm wrong something

Of course it doesn't work because there is nothing in your mask.
I wouldn't bother inpainting subtitles, that would look ugly in most cases, unless there are few subtitles and they are in solid or static background.
Automask is for usual static logos, if you want to use it on one subtitle then you need to limit video with Trim() only to that subtitle, or read about Analyze=-4.

If you want a dynamic mask for all subtitles then there are various DynMask methods.

cagure
16th October 2022, 20:40
Ok I'll try with the trim and with others DynMask methods
Thanks

VoodooFX
16th October 2022, 20:48
I've no idea how you suddenly came up "430,830,-1000,-180" coords.
And isn't that video HDR?

Anyway, example on your screenshot:

ImageSource("D:\PlFTT4nF_o.png")
InpaintDelogo(mask="D:\AxFwWIN.png", Loc="126,886,-1118,-128", Inflate=2, Turbo=1)
Mask: https://i.imgur.com/AxFwWIN.png

https://thumbs2.imgbox.com/26/30/iSG5DD1G_t.png (https://images2.imgbox.com/26/30/iSG5DD1G_o.png)

https://thumbs2.imgbox.com/02/a7/NtZ0nHLw_t.jpg (https://images2.imgbox.com/02/a7/NtZ0nHLw_o.jpg)

kedautinh12
17th October 2022, 15:28
after extracted images, how to use all images for delogo?? thanks
https://forum.doom9.org/showthread.php?p=1974638#post1974638

VoodooFX
17th October 2022, 15:50
after extracted images, how to use all images for delogo??
You extract images for OCR, for inpainting you just use that dynamic mask, disable Show to inpaint, use DynInflate to expand mask.

katzenjoghurt
17th October 2022, 16:16
Forgot to tell you, that site offered me to download a Vittalia Trojan (https://howtofix.guide/trojan-vittalia/) 3 times before it gave me your file.

Ouch. At least it was some hentai stuff for me, when I clicked on it now.
I uploaded it somewhere else and edited the posting.
[even though I doubt anyone will have interest in downloading these masks anymore]

kedautinh12
17th October 2022, 16:48
You extract images for OCR, for inpainting you just use that dynamic mask, disable Show to inpaint, use DynInflate to expand mask.

when i disable show=0, i got error: "source and mask clip have different dimensions"
https://drive.google.com/file/d/1OXGs7k5G-4ohnRSYmotA-NRPO8wgFgZy/view?usp=sharing

scripts:
LoadPlugin("C:\Megui\MeGUI-2924-64\tools\dgindexnv\DGDecodeNV.dll")
DGSource("C:\Users\ADMIN\Downloads\back number - Kaitou [1440x1080i MPEG2 M-ON! HD].dgi")
AnimeIVTC(mode=1)
trim(336,0).InpaintDelogo(Loc="1324,110,-60,-160", Show=0, DynLocUp=2, DynMask=2, DynTune=190, DynTEdge=1, DynTEdgeThY=30, DynTEdgeInf=4, KillNoise=5, DynInflate=4)

And i can't create mask logo at top-left on video above, can you have any suggest??

Video with same logo but can't create mask logo too:
https://drive.google.com/file/d/1nQHiXqIqQrjb-qDIooATbUo1JOSFM7mc/view?usp=sharing

VoodooFX
17th October 2022, 17:21
when i disable show=0, i got error: "source and mask clip have different dimensions"


Because you are doubling mask resolution with DynLocUp=2.

Video with same logo but can't create mask logo
If it's same then why you don't use same bmp?

kedautinh12
17th October 2022, 17:47
If it's same then why you don't use same bmp?

Can't create mask logo on two video. If i can createable, i will use same mask on video can't create mask

VoodooFX
17th October 2022, 17:59
Can't create mask logo on two video.
It's few clicks in PhotoShop -> https://i.imgur.com/pK3EInq.png

kedautinh12
17th October 2022, 18:10
It's few clicks in PhotoShop -> https://i.imgur.com/pK3EInq.png

Can you have video guide?? Few clicks but can't describe how :D

VoodooFX
17th October 2022, 18:41
https://www.youtube.com/watch?v=8eL5HAyNan0

cagure
17th October 2022, 23:02
I've no idea how you suddenly came up "430,830,-1000,-180" coords.
And isn't that video HDR?
it's my mistake, corrected in the previous post.

Excellent news, certainly by removing the subtitle I will have to compensate for the loss,but that's what I was looking for

But if I use Your mask everything works fine
https://thumbs2.imgbox.com/5b/f5/bTZ4UKlC_t.png (https://imgbox.com/bTZ4UKlC)
InpaintDelogo(mask="E:Gt\AxFwWIN.png", Loc="126,886,-1118,-128",Inflate=2, Turbo=1)

is that I can't create a mask like yours, but have you used photoshop?

Thanks.

VoodooFX
17th October 2022, 23:24
But if I use Your mask everything workse a mask like yours, but have you used photoshop?
Yes.
But you can use Automask on this image:

ImageSource("D:\PlFTT4nF_o.png")
InpaintDelogo(mask="D:\mask.bmp", Loc="126,886,-1118,-128", Analyze=-4, Automask=1)

kedautinh12
18th October 2022, 14:08
Hi, InpaintDelogo for dynamic very good but sometime it's look unnatural

1mn 42s
https://i.imgur.com/XoBnTun.png
Source: https://drive.google.com/file/d/1OXGs7k5G-4ohnRSYmotA-NRPO8wgFgZy/view?usp=sharing
Scripts:
LoadPlugin("C:\Megui\MeGUI-2924-64\tools\dgindexnv\DGDecodeNV.dll")
DGSource("C:\Users\ADMIN\Downloads\back number - Kaitou [1440x1080i MPEG2 M-ON! HD].dgi")
AnimeIVTC(mode=1)
trim(336,0).InpaintDelogo(Loc="1324,110,-60,-160", Show=0, DynLocUp=1, DynMask=2, DynTune=80, DynTEdge=1, DynTEdgeThY=30, DynTEdgeInf=4, KillNoise=5, DynInflate=4)

kedautinh12
18th October 2022, 15:52
Your mask only delogo complete with inpainting mod but black color arround logo will disappear
https://i.imgur.com/l04LfDk.png

Script:

LoadPlugin("C:\Megui\MeGUI-2924-64\tools\dgindexnv\DGDecodeNV.dll")
DGSource("C:\Users\ADMIN\Downloads\back number - Kaitou [1440x1080i MPEG2 M-ON! HD].dgi")
AnimeIVTC(mode=1)
trim(49,4623).InpaintDelogo(mask="C:\Left_Top_Logo.png", Automask=0, aMix=0, Loc="40,30,-1144,-940", Mode="Inpaint", Analyze=3, Turbo=-1, Optimize=1)

VoodooFX
18th October 2022, 16:32
Hi, InpaintDelogo for dynamic very good but sometime it's look unnatural
Looks normal, don't expect the details to be magically recreated.
Are you sure that screenshot comes from that script?

Your mask only delogo complete with inpainting mod but black color arround logo will disappear
It doesn't make any sense, can you use the google translate?
Cut off the black borders from video.

kedautinh12
18th October 2022, 16:53
Looks normal, don't expect the details to be magically recreated.
Are you sure that screenshot comes from that script?
Yes, i'm sure

VoodooFX
18th October 2022, 16:56
Your screenshots doesn't correspond to video resolution.
Use https://imgbox.com to post thumbnailed screenshots.

What function AnimeIVTC is doing here?

kedautinh12
18th October 2022, 17:02
Your screenshots doesn't correspond to video resolution.
Use https://imgbox.com to post thumbnailed screenshots.

What function AnimeIVTC is doing here?

Cause i cut and paste in ms paint. AnimeITVC is deinterlaced script
https://github.com/realfinder/AVS-Stuff/blob/Community/avs%202.5%20and%20up/AnimeIVTC.avsi

VoodooFX
18th October 2022, 17:28
Cause i cut and paste in ms paint. AnimeITVC is deinterlaced script

Does this video looks like "Anime" for you?
Right click on AvSPmod preview and "Save image as...", then upload to https://imgbox.com, copy/paste BB-Code from there.

My take on this one subtitle:
LWLibAvVideoSource("D:\back number - Kaitou [1440x1080i MPEG2 M-ON! HD].ts").TFM()
InpaintDelogo(Loc="1324,110,-60,-160", DynMask=2, DynTune=190, DynTuneInf=1, DynTEdge=1, DynTEdgeThY=30, DynTEdgeInf=1, DynInflate=4)

Frame 2794:
Before:
https://thumbs2.imgbox.com/4c/d0/vdLnjcCW_t.png (https://images2.imgbox.com/4c/d0/vdLnjcCW_o.png)

After:
https://thumbs2.imgbox.com/c7/48/nb0gTPna_t.png (https://images2.imgbox.com/c7/48/nb0gTPna_o.png)

Your anime ms paint: https://i.imgur.com/XoBnTun.png

kedautinh12
18th October 2022, 17:40
AnimeITVC can use for real world too. Are you check all subtitles?? Cause sometime DynTune=190 can't detect all letters, that why i deceased Dyntune to 80

Reel.Deel
18th October 2022, 18:05
https://i.imgur.com/CXE1OWd.png https://i.imgur.com/O3NiNc8.png

Can the post-processing steps of InpaintDelogo be applied to an already delogo'd clip? I created an lgd, and while the result is not perfect I think the remaining artifacts can be mitigated.

https://i.ibb.co/JnS46bf/SSTV-1092.png https://i.ibb.co/VH1wCX3/SSTV-1115.png

The problem with TV MPEG-2 live footage is that there is always lots of artifacts in and around the logo. In some scenes the delogo'd area is better and in other the outline is clearly more visible. I also experimented with denoising the logo area before analyzing it in AviUtl but the result while better at times, it can also be inconsistent.

kedautinh12
18th October 2022, 18:09
AnimeITVC can you for real world too. Are you check all subtitles?? Cause sometime DynTune=190 can't detect all letters, that why i deceased Dyntune to 80

After check, i seen your result detect all letters with DunTune=190. Very good, thanks

VoodooFX
18th October 2022, 18:32
AnimeITVC can you for real world too. Are you check all subtitles??
You can use Invert() on any videos too.
No, I didn't check, at the bright backgrounds you would want to expand mask more to cover the shadows. Get new script from temp branch where I allowed higher DynInflate values.
And you are not leaving enough space from logo borders [shadows there are part of logo/subs].

VoodooFX
18th October 2022, 18:38
Can the post-processing steps of InpaintDelogo be applied to an already delogo'd clip? I created an lgd, and while the result is not perfect I think the remaining artifacts can be mitigated.

https://i.ibb.co/JnS46bf/SSTV-1092.png https://i.ibb.co/VH1wCX3/SSTV-1115.png


You are comparing apples to oranges there. Those examples there are inpainting.
Use Deblend for comparison, and Interp=0, dPP=0 to disable pp.
I think there is some avs function ported from aviutl to denoise delogo area.

First row - Interp=0, dPP=0, second - Interp=0, dPP=5:

https://i.imgur.com/pYT2Wb6.png https://i.imgur.com/apwVKlE.png

https://i.imgur.com/9BY0vzo.png https://i.imgur.com/tkwj6nu.png

Ebmp from there: SSTV.v3.1080 (https://drive.google.com/drive/folders/1QWixC2n9xy6ntt9JYr8FCsl5T3VDZuVl?usp=sharing)

EDIT:
Found it, logoNR [you added it to wiki], just FFT3DFilter there, added it on top of blur as negative dPP.
Interp=0, dPP=-5:

https://i.imgur.com/y4kGEtp.png https://i.imgur.com/exIWnEf.png

kedautinh12
19th October 2022, 12:58
Will SSTV.v3.1080 better than SSTV.v2.1080??

kedautinh12
19th October 2022, 13:11
You can use Invert() on any videos too.
No, I didn't check, at the bright backgrounds you would want to expand mask more to cover the shadows. Get new script from temp branch where I allowed higher DynInflate values.
And you are not leaving enough space from logo borders [shadows there are part of logo/subs].

I tried leaving more space from logo borders, result still same

VoodooFX
19th October 2022, 16:34
Will SSTV.v3.1080 better than SSTV.v2.1080??
Only you can see what better fits your videos, I'm not a fortune teller.

Reel.Deel
19th October 2022, 18:33
You are comparing apples to oranges there. Those examples there are inpainting.
Use Deblend for comparison, and Interp=0, dPP=0 to disable pp.
I think there is some avs function ported from aviutl to denoise delogo area.

First row - Interp=0, dPP=0, second - Interp=0, dPP=5:

<pictures>

Ebmp from there: SSTV.v3.1080 (https://drive.google.com/drive/folders/1QWixC2n9xy6ntt9JYr8FCsl5T3VDZuVl?usp=sharing)

EDIT:
Found it, logoNR [you added it to wiki], just FFT3DFilter there, added it on top of blur as negative dPP.
Interp=0, dPP=-5:

<pictures>

Those are some nice results. I had never used InpaintDelogo for logo deblending. Thanks for sharing.

Yes I added logoNR which is just a simple script that denoises the logo area and then overlays it on top of the delogo'd clip. I assume InpaintDelogo offers a more sophisticated technique for post-processing the logo area, hence my question if it can be used used for that purpose on an already delogo'd clip.

Regarding the ebmp you linked to. Are the numbers in the end supposed to be the x,y location? The name says SSTV.v3.1080_106-36 so I tried use loc="106,36,..." but it did not line up, but loc="56,36,..." did.

VoodooFX
19th October 2022, 18:47
question if it can be used used for that purpose on an already delogo'd clip.
You can't use it like that. It's just mainly gaussian blur.


Regarding the ebmp you linked to. Are the numbers in the end supposed to be the x,y location? The name says SSTV.v3.1080_106-36 so I tried use loc="106,36,..." but it did not line up, but loc="56,36,..." did.
Yes, x/y, I just copy pasted them from another ebmp. I've saved this logo in cropped video for tests, so I had no idea about coords, will rename x to "56" then.

kedautinh12
20th October 2022, 14:18
https://i.imgur.com/y4kGEtp.png https://i.imgur.com/exIWnEf.png

are those images you took from Daichi Miura?? :D

VoodooFX
20th October 2022, 17:02
are those images you took from Daichi Miura?? :D
No.
123

VoodooFX
22nd October 2022, 21:40
# Version 3.2 : New feature: Conditional optimizations with "Optimize", enabled by default.
# Up to ~1000% speed-up for slow "Inpaint" & "Interp" presets.
# Additional auto "Interp" disabling.
# New feature: Negative "dPP"/"oPP", adds denoise, enabled by default [20%-50% slow down].
# Very slow inpainting preset: Turbo=-2.
# Quick masks dump with clean "outs": DumpMasks=2.
# Various other tweaks.
# FFT3DFilter plugin is required.

evafans
12th November 2022, 06:09
Recently, I noticed the end time of extracted subs is always one frame late, so I change the two "subend+1" to "subend" ,will it cause any side effect? In order to get precise timestamps is there any changes needed?

VoodooFX
12th November 2022, 11:57
Recently, I noticed the end time of extracted subs is always one frame late, so I change the two "subend+1" to "subend" ,will it cause any side effect? In order to get precise timestamps is there any changes needed?

Why do you think that it's "late" and not precise?
I think "subend+1" frame is a precise timestamp. "subend+1" marks the end of subtitle in time, at "subend" subtitle is still shown till the next frame when subtitle is not shown.

Not like me, StainlessS sometimes posts sober, so let's wait for what he has to say about it [ in his extractor "subend" is without "+1" [ it's "E" there actually [ most likely it means "end" ] ] ].

StainlessS
12th November 2022, 13:31
Without looking at any scripting,
If I referred to end of sub as "E", then was probably intended as last frame where sub is shown.
And so timestamp of next nosubs frame would be that of frame E + 1.
Duration would be that of (E + 1) - S.

I think, maybe, perhaps.

VoodooFX
12th November 2022, 14:54
Duration would be that of (E + 1) - S.
Uh-huh, so my "subend+1" modification is correct.

Noticed another discrepancy between yours and mine: "AREA.Trim(S,E).ClipBlend.Trim(E-S,-1)" vs mine "inY8.Trim(SubStart,SubEnd).ClipBlend.Trim(SubEnd-SubStart+1,-1)".
Does mine cut correctly the last frame when yours next-to-last? [My brain doesn't work yet...]

StainlessS
12th November 2022, 17:51
[My brain doesn't work yet...]
Snap. :)

Mine explained,
AREA.Trim(S,E).ClipBlend.Trim(E-S,-1)

Trim(S,E), length is E - S + 1
So,
Last frame is E-S
so,
Trim(E-S,-1)
is last frame of that trim, forcing Clipblend() to return result of blending that entire trim.

your Trim(SubEnd-SubStart+1,-1)
would seem to me to try return the last frame + 1, ie frame after the last frame.
Cant offhand remember if ClipBlend would correct for that. [EDIT: Yes it would]

EDIT:

Colorbars().ShowFrameNumber.Killaudio
trim(0,-1) # 1 frame @ 0
Trim(1,-1) # NO ERROR, reaching past end of clip just returns the final frame [ie 0].

https://i.postimg.cc/LnYXCzMy/a-00.jpg (https://postimg.cc/LnYXCzMy)

So, its not right, but identical result compared to your doing it right :)

VoodooFX
12th November 2022, 19:00
Hmm, so I had a brain fart with that +1 trim [not related to evafans post], now after the third pint my brain is fresher, but still can't grasp why I did that, maybe AvS's first frame as 0 confused me...

StainlessS
12th November 2022, 19:18
Good a reason as any I suppose.
Anyways, enjoy your pint.
EDIT: Have another dozen pints and your brain will be 'as fresh as a daisy'. :)
[strange saying, why would a daisy be so extra fresh ???]

EDIT:
Why do they say as fresh as a daisy?
In Old English, daisies were referred to as “day's eye” because at night the petals close over the yellow
center and during the day they re-open. The phrase “as fresh as a daisy” originated from this, signifying
that someone had a good night's rest. The word daisy also made its way into other slang words and phrases.

https://www.ftd.com/blog/share/daisy-meaning-and-symbolism

Daisies can be eaten and are even medicinal. Daisy leaves are a common addition to salads.
Wild daisy tea is used to treat coughs, bronchitis, inflammation, and more.
Wild daisies are also sometimes applied to the skin for wounds and diseases.
And buttercup stalks taste a bit peppery. [maybe part due to cyanide or something]

EDIT:
Buttercups, like horseradish, engage in chemical warfare. In horseradish the heat one tastes comes
from crushing cells that hold two different chemicals apart which are only peppery when they combine.
This is to discourage consumption by me, thee and the denizens of nature.
The buttercup is similar in that the offending chemical, a glycoside called Ranunculin,
is not a problem until the plant’s cells are crushed.
Then an almost instant enzyme reaction turning Ranuculin into Protoanemonin, a bitter, irritating, yellow oil.
The animals most bothered by buttercups are grazing cows then horses, sheep and pigs, the latter two
sometimes suffering paralysis. Humans are rarely poisoned by buttercups because they taste so bad.
It is not fatal in small amounts but a significant irritant that can make you ill with gastric distress.
https://www.eattheweeds.com/buttercups/

VoodooFX
13th November 2022, 19:02
Have another dozen pints and your brain will be 'as fresh as a daisy'. :)

Nah, I drink responsibly, but yeah after few pints I wake up fresh as a daisy, without, I wake up after 3-4 h, not so fresh. :)

Looks like "Trim(SubEnd-SubStart+1,-1)" place was always OK and only introduced in v2.10, only this change there and nothing in the log. Probably I was testing something and forgot to change it back.

Injustice is eliminated:

# Version 3.3 : 2022/11/13. Corrected a code 'typo' in SubsMask2Img(), introduced in v2.10.



will it cause any side effect? In order to get precise timestamps is there any changes needed?
Only side effect - the imprecise timestamps. Don't change anything to get the precise timestamps.

VoodooFX
24th November 2022, 17:16
# Version 3.4 : 2022/11/24. New feature: "Greyscale" parameter, affects positive "Analyze", "Deblend", "Inpaint"...
# Up to ~60% speed-up when enabled.
# Prevents chroma changes on the greyscale videos by deblend [side effect of "3.1" fix].
# FFT3DFilter replaced by Neo_FFT3D, up to ~20% speed-up.

Selur
25th November 2022, 21:07
FFT3DFilter replaced by Neo_FFT3D, up to ~20% speed-up.
Out of curiosity: Have you tried using FFT3DGPU?

VoodooFX
25th November 2022, 21:15
Out of curiosity: Have you tried using FFT3DGPU?
Yes, I wasn't impressed.

kedautinh12
25th November 2022, 21:59
Out of curiosity: Have you tried using FFT3DGPU?

FFT3DGPU ported from older ver of fft3dfilter, result will look worser than fft3dfilter

evafans
5th December 2022, 09:17
when using extract=-1, it only allows one task runing. Is there any way to tweak it so it can allow multi-task.

VoodooFX
5th December 2022, 21:59
when using extract=-1, it only allows one task runing. Is there any way to tweak it so it can allow multi-task.
Possible but then ReExtract option wouldn't work when doing multi instance.
What is your CPU usage when using Extract=-1? Mostly it runs 100% for me on all 4 cores.

EDIT:
Actually, ReExtract would work.

evafans
6th December 2022, 01:29
9400f 6 core, 60%-70% most of the time, somtimes 100%.
If it will affect ReExtract option, then I should better upgrade my CPU to speed up the extration process for each instance.
I don't really understand ReExtract though, I used ReExtract once, it does not affect the image even if I apply different paramaters from the previous extract=-1, only cuts half of the time.
intermediate file is already appeared in black and white, so there is little use applying different masks designed for corlored images. Am I understand it correctly?

VoodooFX
6th December 2022, 03:29
9400f 6 core, 60%-70% most of the time, somtimes 100%.
Then you wouldn't get much benefit running two jobs simultaneously, it would be only ~15% faster than running one job after another.


I don't really understand ReExtract though, I used ReExtract once, it does not affect the image even if I apply different parameters from the previous extract=-1, only cuts half of the time.
intermediate file is already appeared in black and white, so there is little use applying different masks designed for corlored images. Am I understand it correctly?
Masking is done by InpaintDelogo() when subs extraction is done by another function SubsMask2Img(), if you didn't change any extraction parameter then you would get same result when doing ReExtract.

"InpaintDelogo(Extract)" is same as "InpaintDelogo().SubsMask2Img()"
"InpaintDelogo(ReExtract)" is same as "SubsMask2Img()"

kedautinh12
27th December 2022, 04:26
Hi, i can't delogo with this subtitles, can you help?? thanks
frame 28
https://i.imgur.com/3EfYQYY.png

scripts:
LoadPlugin("C:\Megui\MeGUI-2924-64\tools\lsmash\LSMASHSource.dll")
LWLibavVideoSource("C:\Users\ADMIN\Downloads\[ALEXANDROS] - Pray [1440x1080i MPEG2 SSTV HD].ts")
#deinterlace
crop(0, 154, 0, -170)
Addborders(0, 154, 0, 170)
animeIVTC(mode=1)
trim(400,4599).InpaintDelogo(Loc="1260,194,-20,-194", show=0, DynMask=5, Dyncolor=$868185, DynTune=190, DynColorTol=50, DynColorInf=2, DynTuneInf=1, DynTEdge=1, DynTEdgeThY=30, DynTEdgeInf=4, DynInflate=1)

Ex video: https://drive.google.com/file/d/12iAsTX1KBbpjm0Zr4sslvfgYUcP6f2fj/view?usp=share_link

VoodooFX
27th December 2022, 14:03
There is some bug with inpainting a dynamic mask, introduced in v3.4, anyway your settings doesn't make sense, check your mask with "Show=4".

EDIT:

Fixed in v3.5

# Version 3.5 : 2022/12/27. Fixed: Dynamic mask inpainting was broken since v3.4.

kedautinh12
27th December 2022, 14:39
ok, i tweak and it's detect better but still can't desubtitles
Frame 28
https://i.imgur.com/lCXoT4h.png
scripts:
LoadPlugin("C:\Megui\MeGUI-2924-64\tools\lsmash\LSMASHSource.dll")
LWLibavVideoSource("C:\Users\ADMIN\Downloads\[ALEXANDROS] - Pray [1440x1080i MPEG2 SSTV HD].ts")
crop(0, 154, 0, -170)
Addborders(0, 154, 0, 170)
animeIVTC(mode=1)
trim(400,4599).InpaintDelogo(Loc="1260,194,-20,-194", show=0, DynMask=5, Dyncolor=$868185, DynTune=190, DynColorTol=25, DynColorInf=1, DynTuneInf=1, DynTEdge=1, DynTEdgeThY=30, DynTEdgeInf=4, DynInflate=1)

VoodooFX
27th December 2022, 14:51
ok, i tweak and it's detect better but still can't desubtitles

Because you are using the bugged version!
In your parameters you are setting the 3 masks but using only one, you need to mix all those masks with DynMask 2 or 3.

kedautinh12
27th December 2022, 15:51
ok, with latest ver and some edit settings, it's work now, thanks

VoodooFX
27th December 2022, 16:18
I think you don't understand what you are doing with those parameters, maybe the example below will help:

v=LWLibavVideoSource("D:\[ALEXANDROS] - Pray [1440x1080i MPEG2 SSTV HD].ts").TFM.TDecimate.Crop(0, 154, 0, -170).Addborders(0, 154, 0, 170).Trim(400,4599)
x=v.crop(1260,194,-20,-194)

# the mask by brightness:
a=v.InpaintDelogo(Loc="1260,194,-20,-194", Show=4, DynMask=6, DynTune="110 - 155", DynTuneInf=1)
# the mask by color:
b=v.InpaintDelogo(Loc="1260,194,-20,-194", Show=4, DynMask=5, DynColor=$868185, DynColorTol=65, DynColorInf=2)
# the mask by edges:
c=v.InpaintDelogo(Loc="1260,194,-20,-194", Show=4, DynMask=7, DynTEdge=1, DynTEdgeThY=5, DynTEdgeInf=1)

# the combo mask (mix of the 3 masks [a+b+c]):
n=v.InpaintDelogo(Loc="1260,194,-20,-194", Show=4, DynMask=2, DynTune="110 - 155", DynTuneInf=1, DynColor=$868185, DynColorTol=65, DynColorInf=2, DynTEdge=1, DynTEdgeThY=5, DynTEdgeInf=1)

# the combo mask temporaly refined by using 40 frames:
m=v.InpaintDelogo(Loc="1260,194,-20,-194", Show=4, DynMask=3, DynTune="110 - 155", DynTuneInf=1, DynColor=$868185, DynColorTol=65, DynColorInf=2, DynTEdge=1, DynTEdgeThY=5, DynTEdgeInf=1, Dyn3Seq=40)

# Inpainting the temporal combo mask [+DynInflate=1]:
o=v.InpaintDelogo(Loc="1260,194,-20,-194", Show=0, DynMask=3, DynTune="110 - 155", DynTuneInf=1, DynColor=$868185, DynColorTol=65, DynColorInf=2, DynTEdge=1, DynTEdgeThY=5, DynTEdgeInf=1, Dyn3Seq=40, DynInflate=1)


StackHorizontal(x.AddBorders(0,0,2,0,$F0F080).Subtitle("Original"),
\ o.crop(1260,194,-20,-194).AddBorders(0,0,2,0,$F0F080).Subtitle("Inpainted"),
\ m.ConvertToYV12.AddBorders(0,0,2,0,$F0F080).Subtitle("T. Combo mask"),
\ n.ConvertToYV12.AddBorders(0,0,2,0,$F0F080).Subtitle("Combo mask"),
\ a.ConvertToYV12.AddBorders(0,0,2,0,$F0F080).Subtitle("DynMask6"),
\ b.ConvertToYV12.AddBorders(0,0,2,0,$F0F080).Subtitle("DynMask5"),
\ c.ConvertToYV12.Subtitle("DynMask7"))


https://images2.imgbox.com/aa/0a/5CZyjo6Z_o.png

kedautinh12
27th December 2022, 16:46
My edit script before your post. I think same same your :D
InpaintDelogo(Loc="1260,194,-20,-194", show=0, DynMask=2, Dyncolor=$858380, DynTune=120, DynColorTol=60, DynColorInf=1, DynTuneInf=1, DynTEdge=1, DynTEdgeThY=5, DynTEdgeInf=4, DynInflate=1)

kedautinh12
27th December 2022, 17:08
Your settings still don't clean from frame 2276-2306
https://i.imgur.com/ZqBVeF7.png
Scripts:
InpaintDelogo(Loc="1260,194,-20,-194", show=0, DynMask=3, DynTune="110 - 155", DynTuneInf=1, Dyncolor=$868185, DynColorTol=65, DynColorInf=2, DynTEdge=1, DynTEdgeThY=5, DynTEdgeInf=1, Dyn3Seq=40, DynInflate=1)
But fixed when change DynMask=3 to 2. Thanks

VoodooFX
27th December 2022, 17:41
But fixed when change DynMask=3 to 2. Thanks
That would reintroduce some rubbish in the mask, better change Dyn3Seq=40 to 20 instead.

kedautinh12
27th December 2022, 18:21
Thanks for your suggestions. Work like a charm :D

Emulgator
31st December 2022, 02:38
Wow. That is awesome. Just tried it here. Deep respect, VoodooFX.

StainlessS
31st December 2022, 10:19
Now go do, that Voodoo, that you do so well:- https://www.youtube.com/watch?v=jS_Shu8y0sI

He/She/It does do so well :)

VoodooFX
3rd January 2023, 12:02
Wow. That is awesome. Just tried it here. Deep respect, VoodooFX.

Thx, Emulgator. :)

VoodooFX
13th January 2023, 13:39
# Version 3.6 : 2023/01/12. New conditional: Auto max "Interp" for frames where logo is in ~solid background.
# "Optimize" is split to "Optimize1" & "Optimize2".
# Burnin version number into ebmp ["Ver-", positive analyze only].

Lil bit better at hidinng deblended logo remnants [Original vs v3.5 vs v3.6]:
https://i.imgur.com/J6WSzdE.png https://i.imgur.com/k7KA1RN.png https://i.imgur.com/kr9AqKq.png

kedautinh12
13th January 2023, 17:58
And old optimise is 1 or 2??

VoodooFX
13th January 2023, 18:32
And old optimise is 1 or 2??
Both.

RidgeShark
2nd March 2023, 03:42
The video I'm working with:
https://drive.google.com/file/d/1B2mbyCZUVUWFJNnpVYFRLzE_tB_loS5I/view?usp=sharing

I'm getting a Avisynth Open Failure:

System Exception: Integer Divide by Zero

And it points to line 1830 in InpaintDelogo.avsi which reads:

BasemaskY = Imgmask.ConvertToY8(Matrix="PC.601").mt_expand().mt_expand()

I'm just trying to get started with the basic parameters:
InpaintDelogo( mask="C:\mask.bmp", Automask=0, aMix=0, Loc="590,422,-40,-34", Mode="Inpaint")

I do have a Mask.bmp in place with the logo painted over in white, with a black background. And the loc coordinates are over the logo.

Usually I get a "Integer Divide by Zero" when there's a color space issue - it appears that might be the case here?

Appreciate any help.

VoodooFX
2nd March 2023, 10:56
I'm getting a Avisynth Open Failure:
System Exception: Integer Divide by Zero

Share your mask too, and your full avs script.
That video is in lossless, is this original form of it?

RidgeShark
3rd March 2023, 02:27
Share your mask too, and your full avs script.
That video is in lossless, is this original form of it?

Mask:
https://drive.google.com/file/d/1jE-gdz-ka_MttciBXFD-eyhP7-sx4JBQ/view?usp=share_link

The video's original form is a longer DVD VOB file. I converted it to Lagarith and kept the original YUV420 colorspace. But, I just tried to see if I could do a lossless MPEG2-only extraction of the needed footage using Mpg2Cut2, and it appears to have worked, so here's that if it can be helpful:

https://drive.google.com/file/d/1vPYD2Pgk35e7qAXpRwEX_iPuefVujGqu/view?usp=share_link

And the full script:
AviSource("C:\Work\VTS_09_1.avi")
ConverttoYV12(interlaced=true)
InpaintDelogo( mask="C:\mask.bmp", Automask=0, aMix=0, Loc="590,422,-40,-34", Mode="Inpaint")

VoodooFX
3rd March 2023, 16:39
No issues here on your files.
Try to run your script without InpaintDelogo, see if you get no error.
Then run script with only "Version()" in it and post its output.
Then share the output of "AVSMeter.exe -avsinfo". [ https://forum.doom9.org/showthread.php?t=174797 ]

RidgeShark
3rd March 2023, 20:49
No issues here on your files.
Try to run your script without InpaintDelogo, see if you get no error.
Then run script with only "Version()" in it and post its output.
Then share the output of "AVSMeter.exe -avsinfo".

The script without InpaintDelogo will load without error.

Running Version():
https://img84.pixhost.to/images/33/339491209_inpaint-00.jpg

AVSMeter Info:
https://drive.google.com/file/d/1RF4Fy2kBPbwKBiuV8_onm5cbStRgeApK/view?usp=sharing

VoodooFX
3rd March 2023, 22:48
AVSMeter Info:
https://drive.google.com/file/d/1RF4Fy2kBPbwKBiuV8_onm5cbStRgeApK/view?usp=sharing

WTF happened there? I would just delete whole plugins folder and start fresh... :D

I see five masktools, two QTGMC, lots of other dupes... zillion random files there.

For example:

C:\Program Files (x86)\AviSynth+\plugins\MaskTools.dll [1.5.1.0, 2021-10-27]
C:\Program Files (x86)\AviSynth+\plugins\masktools2-25.dll [2.1.0.0, 2021-10-27]
C:\Program Files (x86)\AviSynth+\plugins\mt_masktools-25.dll [2.0.36.0, 2021-10-27]
C:\Program Files (x86)\AviSynth+\plugins\mt_masktools-26.dll [2.0.36.0, 2021-10-27]
C:\Program Files (x86)\AviSynth+\plugins\masktools2.dll [2.2.18.0, 2021-10-27]


And you need to get latest versions of the required plugins.

EDIT:
Is it this DVD? -> https://www.amazon.com/Festival-of-3-D-Movie-Trailers/dp/B01GWCQA4O
I didn't knew you could sell trailers for $129.99. :D
Does the logo in those trailers go ON and OFF in every trailer like in your sample video?

Matt3o
10th March 2023, 16:46
Hi, I'm trying to do my first delogo on a short anime episode from a Japanese TV channel.
I tried many settings, and I seem to have settled with these ones:

LWLibAVVideoSource("D:\delogo.mkv")
#InpaintDelogo(mask="D:\mask.bmp", Automask=1, aMix=2, Loc="1124,24,-52,-636", Analyze=2)
InpaintDelogo(mask="D:\mask.bmp", Loc="1124,24,-52,-636", mode="both", Analyze=1, Inflate=2, Interp=2, IntSpd=4, oTune=3, optimize2=3, dpp=-3)
This is the resulting mask with show=2
https://i.imgur.com/h7BKcTM.png

Here is a before and after pic of frame 144:
https://i.imgur.com/522tI2w.png
https://i.imgur.com/tF2QHo9.png

Unfortunately on some frames, the logo is still visible. Frame 1279
https://i.imgur.com/1o4zeky.png

Is there anything I can do to improve it or is this the best I can achieve? I'll leave the drive (https://drive.google.com/drive/folders/1BlJuWIGjKqx-rJI6up7fZe3xr5ArrH0u?usp=sharing) link with the video and masks. Thanks in advance

VoodooFX
10th March 2023, 23:08
LWLibAVVideoSource("D:\delogo.mkv")
#InpaintDelogo(mask="D:\mask.bmp", Automask=1, aMix=2, Loc="1124,24,-52,-636", Analyze=2)
InpaintDelogo(mask="D:\mask.bmp", Loc="1124,24,-52,-636", mode="both", Analyze=1, Inflate=2, Interp=2, IntSpd=4, oTune=3, optimize2=3, dpp=-3)
Is there anything I can do to improve it or is this the best I can achieve?

Get better video source, this looks like some re-reencode.
Mode="Both" is wrong here, it's for semi-transparent logos, this logo is just transparent.
You analyzed frames at the end with no logo + fade-out animation, trim out those parts for analysis.
For settings like "IntSpd=4" leave 20px from the logo edges.



Unfortunately on some frames, the logo is still visible. Frame 1279

Use 'stronger' settings to deal with the severe deblend artifacts:

Trim(0,6960)
InpaintDelogo(mask="D:\mask.bmp", Show=2, Loc="1114,14,-42,-626", mode="Deblend", Inflate=2, IntSpd=4, Optimize2=2, dPP=-5)


https://i.imgur.com/iS9xHDH.png

Matt3o
11th March 2023, 00:53
Get better video source, this looks like some re-reencode.
Mode="Both" is wrong here, it's for semi-transparent logos, this logo is just transparent.
You analyzed frames at the end with no logo + fade-out animation, trim out those parts for analysis.
For settings like "IntSpd=4" leave 20px from the logo edges.




Use 'stronger' settings to deal with the severe deblend artifacts:

Trim(0,6960)
InpaintDelogo(mask="D:\mask.bmp", Show=2, Loc="1114,14,-42,-626", mode="Deblend", Inflate=2, IntSpd=4, Optimize2=2, dPP=-5)


Yes the source is not very good, sadly this is the only one I could find. I have recreated the mask trimming the fade-out animation, and used your suggested settings, and although it's blurrier (dPP=-5), the logo is almost unnoticeable so I'll keep it like this. Many thanks for your time

doctorkhv
2nd April 2023, 06:54
Deep respect, VoodooFX!!!
When using InpaintDelogo( mask="D:\003.png", Loc="0,0,0,0", Inflate=0 )
The color space is changing. see pictures
1. What should be changed in the script so that the color space does not change?
2. Is it possible to reduce the blur a little?

Used version v3.6 and AviSynth+3.7.2

https://i.imgur.com/kAgqUmF.png
https://i.imgur.com/cRq05Ml.png

VoodooFX
2nd April 2023, 12:28
Deep respect, VoodooFX!!!
When using InpaintDelogo( mask="D:\003.png", Loc="0,0,0,0", Inflate=0 )
The color space is changing. see pictures

I'm not sure what you are doing here, share the files and full script to test it. [no big files pls]

doctorkhv
3rd April 2023, 01:03
After processing
FFmpegSource2("X:\002.mp4")
InpaintDelogo( mask="X:\002.png", Loc="0,0,0,0", Inflate=0 )

Files
1.002.mp4 https://drive.google.com/file/d/1MkuaOg21oav308SQs9osI06fDoIbFqb8/view?usp=share_link
2.002.png https://drive.google.com/file/d/1KxJmoAjD7Lv5Qf---pZb--d44kUBILup/view?usp=share_link

Loaded into DaVinci Resolve and compared the original file and the file processed by InpaintDelogo.

VoodooFX
3rd April 2023, 02:01
Color doesn't change for me, and it can't change because there is no colorspace conversion here.
Look at screenshots [001.mp4, frame 20]:

Original:
https://thumbs2.imgbox.com/57/f9/2sBWkSEy_t.png (https://images2.imgbox.com/57/f9/2sBWkSEy_o.png)

After inpainting:
https://thumbs2.imgbox.com/fc/ef/8T81ByW7_t.png (https://images2.imgbox.com/fc/ef/8T81ByW7_o.png)

Your problem I guess is in the encoding settings. Share MediaInfo of your encoded file.

For less blur try:

InpaintDelogo( mask="X:\002.png", Loc="0,0,0,0", Inflate=0, oPPm=1, oPP=3)

doctorkhv
4th April 2023, 02:40
VoodooFX Thank you!

Maznak81
6th April 2023, 23:04
Hello. I need help. I can Loc or "Crop" the logo without problems. But when I'm opening the AVS script I get an error:

I don't know what 'color_white' means
InpaintDelogo.avsi (line1817)

Here's the script:

LoadPlugin("C:\MeGUI-64 bit\tools\dgindexnv\DGDecodeNV.dll")
DGSource("K:\TEST.dgi")
InpaintLoc(Loc="90,26,-1092,-636")
InpaintDelogo(mask="K:\xxx.bmp", Automask=1, Analyze=2, aMix=0, Loc="90,26,-1092,-636")
InpaintDelogo(mask="K:\xxx.bmp", Loc="90,26,-1092,-636", Mode="Inpaint")


Thank you very much for your response.

VoodooFX
7th April 2023, 00:25
Moved Logo Database to GitHub, you can add your logos there -> https://github.com/Purfview/InpaintDelogo/tree/main/Logo%20Database

Hello. I need help. I can Loc or "Crop" the logo without problems. But when I'm opening the AVS script I get an error:

I don't know what 'color_white' means
InpaintDelogo.avsi (line1817)

That means that "colors_rgb.avsi" is missing, it should be installed with Avisynth. Anyway, I've removed this dependency in pre-release version ["test" branch on GitHub].

Btw, remove or comment out InpaintLoc and the first instance of InpaintDelogo in your script.
And if your video is interlaced then you need to deinterlace it before delogo.

Maznak81
7th April 2023, 01:25
Thank you very much for your help !!! It works now!

doctorkhv
20th April 2023, 08:07
Hello VoodooFX
Help me get rid of spots in a quick scene.
InpaintDelogo( mask="X:\01amask.png", Loc="0,0,0,0", Inflate=0)
01amask.png and 01a.mov https://drive.google.com/drive/folders/1BZHQ74laF1rt_UYZYaN-u3FvgPBwan4f?usp=share_link
https://i.imgur.com/egyvIoH.png

drunksunk
24th April 2023, 20:21
How can I remove the white watermark on top right? https://i.imgur.com/4TvFxKq.jpg

VoodooFX
25th April 2023, 14:28
Hello VoodooFX
Help me get rid of spots in a quick scene.
Hi, try Turbo=-1.

VoodooFX
25th April 2023, 16:05
How can I remove the white watermark on top right? https://i.imgur.com/4TvFxKq.jpg

Did you read the first post, where did you stuck?

This is veeery big opaque logo, delogo wouldn't look nice, something like this:
https://thumbs2.imgbox.com/46/aa/aPuoz6Iq_t.jpg (https://images2.imgbox.com/46/aa/aPuoz6Iq_o.jpg)

https://thumbs2.imgbox.com/e6/ca/YbbysKn3_t.jpg (https://images2.imgbox.com/e6/ca/YbbysKn3_o.jpg)

doctorkhv
26th April 2023, 03:38
Hi, try Turbo=-1.

InpaintDelogo( mask="X:\01amask.png", Loc="0,0,0,0", Inflate=0, Turbo=-1)
does not help, the same defects remain

drunksunk
26th April 2023, 07:54
Did you read the first post, where did you stuck?

This is veeery big opaque logo, delogo wouldn't look nice, something like this:
https://thumbs2.imgbox.com/46/aa/aPuoz6Iq_t.jpg (https://images2.imgbox.com/46/aa/aPuoz6Iq_o.jpg)

https://thumbs2.imgbox.com/e6/ca/YbbysKn3_t.jpg (https://images2.imgbox.com/e6/ca/YbbysKn3_o.jpg)

This is the result I obtained with HitPaw (it seems less noticeable): https://streamable.com/dexf0a

Regarding the tool, I don't know the installation procedure aside from having AviSynth installed on my computer. I don't know which paramaters of the command I would need to run then, how you get the square box pixel coordinates within your images, if you need to create a mask file of the part you want to remove and that's an alternative of using the pixel coordinates, etc.

Alexkral
26th April 2023, 09:04
I'm having trouble getting this to work (at all) for subtitle removal. The subtitles are very large and opaque, with a thick dark halo. The video is Full HD, this is a sample:

https://imgur.com/a/ZWKPdFy

So with show=0 no matter what I do I can't get rid of the black border. Using different values for Dyntune and DynMask4H, there seems to be some inpainting inside the subtitles, but the result is bad, darker and different than the background. The only thing that helps is DynInflate=7, but then the result is very distorted. The other parameters don't seem to make any difference.

Using show=6 I can't see the black border on the black background, so I don't know how it can be useful for finetune DynMask4H. With show=4 the mask is perfectly visible and has hardly any artifacts.

I'm not sure if I should try a different DynMask, because reading the manual I don't think it's easy to find a clearer example of subtitles with a dark halo.

VoodooFX
26th April 2023, 15:28
I'm having trouble getting this to work (at all) for subtitle removal.
The only thing that helps is DynInflate=7, but then the result is very distorted.

These two sentences contradicts each other. Looks like you got it working but you didn't liked the result.
What did you expected to see inpainted in a such big hole?
Usually people remove subtitles from a higher quality video by using a lower quality unsubtitled video.

drunksunk
26th April 2023, 18:25
These two sentences contradicts each other. Looks like you got it working but you didn't liked the result.
What did you expected to see inpainted in a such big hole?
Usually people remove subtitles from a higher quality video by using a lower quality unsubtitled video.

Hello, did you see my message above?

VoodooFX
26th April 2023, 18:53
Hello, did you see my message above?
Yes, I did but didn't had time to look at your sample posted... still I don't understand where you stuck, what you are asking is written in the first post, and whole manual is in the script aka avsi file.
Do you understand basics of Avisynth? Can you see your video using AvS?

Btw, your shared frame image is 4K, when your HitPaw delogoed video sample is 1280x512. Maybe share your original video sample on Mega or Wetransfer.
That HitPaw delogo looks like simple deKafka kind of delogo, there are few AvS scripts with such effects.

Alexkral
26th April 2023, 23:03
These two sentences contradicts each other. Looks like you got it working but you didn't liked the result.
What did you expected to see inpainted in a such big hole?
Usually people remove subtitles from a higher quality video by using a lower quality unsubtitled video.

lol, what did I expect from something called InpaintDelogo? Obviously not a distorted mess, you can blame me for that.

Actually, I wouldn't say that something works because I like the result, but because I find it useful, which is clearly not the case. So there's no contradiction.

State-of-the-art AI inpainting algorithms are easily capable of inpainting much larger objects, so with each passing day there are fewer things related to inpainting that can't be expected.

drunksunk
26th April 2023, 23:11
0) Read help/manual (at the top of the script) about parameters mentioned below.

Which script?

VoodooFX
27th April 2023, 00:07
If DynInflate=7 is not enough and it still picks edges of a halo, then you can expand a mask this way:

v=LWLibAvVideoSource("D:\videofile.mkv")
x=v.InpaintDelogo(..., DynInflate=7, Show=4).mt_expand().mt_expand() # one mt_expand() expands by one pixel
v.InpaintDelogo(..., mask=x, DynMask=1, Show=4)


lol, what did I expect from something called InpaintDelogo? Obviously not a distorted mess, you can blame me for that.
What you expect me to inpaint into my fantasy without a sample and a script? For me, "distorted mess" is description of inpainting. :)


Actually, I wouldn't say that something works because I like the result, but because I find it useful, which is clearly not the case. So there's no contradiction.
Actually, it works when it does what it's meant to do, not if you find it useful.

VoodooFX
27th April 2023, 00:08
Which script?
InpaintDelogo.avsi, it's a text file, you can open it with Notepad.

drunksunk
27th April 2023, 08:21
InpaintDelogo.avsi, it's a text file, you can open it with Notepad.

For a noob like me, it doesn't tell me how to get the coordinates of the square box in your video frame. Also it doesn't provide some example commands explaining what they do so that you can copy parts of thtem and remove the arguments you don't need.

Making a black/white mask with Photoshop would result in better result? And then there are so many parameters I have no clue if better to use or not.

Could you tell me which command you run so that I can try it out on my side?

VoodooFX
27th April 2023, 10:49
For a noob like me, it doesn't tell me how to get the coordinates of the square box in your video frame.
I use Crop() (http://avisynth.nl/index.php/Crop) to get coords, as alternative you can use InpaintLoc(Loc="100,100,-100,-100") too if you like it, sometimes I get them just from AvsPmod's screen.
I see you mentioned Photoshop, you can get coords there too.


Also it doesn't provide some example commands explaining what they do so that you can copy parts of thtem and remove the arguments you don't need.
But it does, it's at the very end (https://github.com/Purfview/InpaintDelogo/blob/3dea6e23f0a6c5156c312d480f2524a5fb7a2c03/InpaintDelogo.avsi#L1145) of the manual there, and arguments have "explainings" there too.


Making a black/white mask with Photoshop would result in better result?
Depends from a logo and video.


And then there are so many parameters I have no clue if better to use or not.
Yes, there are more than hundred arguments, I think some of them are pointless, but users said that they need them.
Understanding comes with experience. Usually you need to use just the few parameters and leave others with the defaults.



Could you tell me which command you run so that I can try it out on my side?
That depends from a logo, I don't really know much about the logo you are trying to remove, it looks like opaque but I'm not sure.
Example of a command is in the first post and in the manual too.

drunksunk
27th April 2023, 11:29
Crop() isn't for resizing/cutting your video resolution?

So inside the extracted "InpaintDelogo-main" folder I need to create a file with unknown extension like "test-script", and I paste this code inside it

InpaintDelogo( mask="D:\mask.bmp", Automask=0, aMix=0, Loc="100,100,-100,-100", Mode="Inpaint")


And then how do you run it? How does it know on which target file to run the script?

VoodooFX
27th April 2023, 11:56
Crop() isn't for resizing/cutting your video resolution?

So inside the extracted "InpaintDelogo-main" folder I need to create a file with unknown extension like "test-script", and I paste this code inside it

And then how do you run it? How does it know on which target file to run the script?

Ha, I asked you if you understand what Avisynth is...
You need to start with Avisynth basics first before doing anything else.
Start from there: http://avisynth.nl/index.php/Main_Page [some stuff there is outdated]

You can run avs scripts with any program supporting them. You load videos in avs scripts with the source plugins.

For example you can use AvsPmod (https://forum.doom9.org/showthread.php?t=175823) like a GUI for things.

drunksunk
27th April 2023, 21:10
Ha, I asked you if you understand what Avisynth is...
You need to start with Avisynth basics first before doing anything else.
Start from there: http://avisynth.nl/index.php/Main_Page [some stuff there is outdated]

You can run avs scripts with any program supporting them. You load videos in avs scripts with the source plugins.

For example you can use AvsPmod (https://forum.doom9.org/showthread.php?t=175823) like a GUI for things.

I found this video from 2008 and that's it: https://www.youtube.com/watch?v=RXByaCFgIHc

I guess your file needs to call your file from Powershell using Avisynth exe?

doctorkhv
28th April 2023, 00:37
Hi, try Turbo=-1.
InpaintDelogo( mask="X:\01amask.png", Loc="0,0,0,0", Inflate=0, Turbo=-1) defects are the same

What to change in the script?

VoodooFX
28th April 2023, 11:05
InpaintDelogo( mask="X:\01amask.png", Loc="0,0,0,0", Inflate=0, Turbo=-1) defects are the same

What to change in the script?

But that is not true. :)

Your shared pic of frame 253 with "defects":

https://thumbs2.imgbox.com/7a/4a/rfJC7Ord_t.jpg (https://images2.imgbox.com/7a/4a/rfJC7Ord_o.jpg)

"Turbo=-1" [upper "defect" looks OK now]:

https://thumbs2.imgbox.com/b6/4c/bCjfTIkP_t.jpg (https://images2.imgbox.com/b6/4c/bCjfTIkP_o.jpg)

Customized inpainting setting to Sharpness=100, preBlur=0.01, postBlur=4, Radius=12 ["defects" are gone]:
Read the Note there (https://github.com/Purfview/InpaintDelogo/blob/3dea6e23f0a6c5156c312d480f2524a5fb7a2c03/InpaintDelogo.avsi#L899)carefully.

https://thumbs2.imgbox.com/50/d1/Nja117H7_t.jpg (https://images2.imgbox.com/50/d1/Nja117H7_o.jpg)

"mShow=3" [for reference, your mask with the holes overlaid ]:
(Changed the holes' color to red from black in latest commit to the test branch in GitHub.)

https://thumbs2.imgbox.com/95/da/2tFYhDXk_t.jpg (https://images2.imgbox.com/95/da/2tFYhDXk_o.jpg)

EDIT:
If you have many holes in your mask then set "Optimize1=0", because very likely there won't be anything to optimize, script runs slower for nothing.

EDIT2:
I looked at original video, I don't see any blemishes in most of those "holes" in frame 253.
You don't need to inpaint there... in those "defects" places.

VoodooFX
28th April 2023, 11:27
I found this video from 2008 and that's it: https://www.youtube.com/watch?v=RXByaCFgIHc

I guess your file needs to call your file from Powershell using Avisynth exe?

No, that's not how it works.

InpaintDelogo plugin and other plugins goes to Avisynth's plugins folder, you "call" them in your script.
Your script [AKA an user script] you save as .avs file.
Those .avs files you can open with the programs supporting Avisynth.
There is no such thing as "Avisynth.exe".

EDIT:
Actually you can open them in the programs not supporting Avisynth, but let's not go there atm, because you'll be even more confused.

EDIT2:
I've looked at Youtube, there I found Deinterlacing with AVISynth and QTGMC Tutorial (https://www.youtube.com/watch?v=C4PyyQoz6eo).
It's about QTGMC plugin, but should help you to grasp the principles of Avisynth.

drunksunk
28th April 2023, 22:38
No, that's not how it works.

InpaintDelogo plugin and other plugins goes to Avisynth's plugins folder, you "call" them in your script.
Your script [AKA an user script] you save as .avs file.
Those .avs files you can open with the programs supporting Avisynth.
There is no such thing as "Avisynth.exe".

EDIT:
Actually you can open them in the programs not supporting Avisynth, but let's not go there atm, because you'll be even more confused.

EDIT2:
I've looked at Youtube, there I found Deinterlacing with AVISynth and QTGMC Tutorial (https://www.youtube.com/watch?v=C4PyyQoz6eo).
It's about QTGMC plugin, but should help you to grasp the principles of Avisynth.
I copied all InpaintDelogo content into plugins64+, create a test folder with a file called script.avs, put the video.mp4 in same folder and now?

VoodooFX
28th April 2023, 23:02
I copied all InpaintDelogo content into plugins64+, create a test folder with a file called script.avs, put the video.mp4 in same folder and now?
"all InpaintDelogo content" is only one .avsi file.
You don't need to move your video files.
Open your .avs file with a program of your preference, for example: AvsPmod.

drunksunk
29th April 2023, 16:07
"all InpaintDelogo content" is only one .avsi file.
You don't need to move your video files.
Open your .avs file with a program of your preference, for example: AvsPmod.

That's just a text editor like any other right? So what code should I put in my .avs script and from where should I call it?

VoodooFX
29th April 2023, 16:23
That's just a text editor like any other right?
Not just a text editor, you can turn on the video preview there to see what you are doing in your script and many other things.
You can detach the preview window in the settings somewhere there.

So what code should I put in my .avs script
Whatever you like, read there: http://avisynth.nl/index.php/Main_Page

and from where should I call it?
I don't understand what you meant by this.

drunksunk
29th April 2023, 16:56
I get an error: https://imgur.com/Lfsr4Q3

Also I don't quite understand how you add a video in AvsPmod. I tried to drag and drop and that would add a "DirectShowSource()" line.

Could you please provide a working command so that I can test it on my end?

VoodooFX
29th April 2023, 17:43
I get an error: https://imgur.com/Lfsr4Q3
Error in red means that you don't have InpaintDelogo in plugins folder.
Dunno what that error in the window means. What is version of AvsPmod?

Also I don't quite understand how you add a video in AvsPmod. I tried to drag and drop and that would add a "DirectShowSource()" line.
Yep, that's how you can add it.
DirectShowSource() filter is outdated, I recommend LWLibAvVideoSource(), it comes from LSMASHSource plugin.

Could you please provide a working command so that I can test it on my end?

Here you go:
Version()
What it shows for you?

This one should work too:
ColorBarsHD()

StainlessS
29th April 2023, 18:22
VX, I noticed that you added a software to produce Subtitles from audio using AI, in subtitles forum.
Is you gonna add AI thingy to InpaintDelogo (or a new delogo whotsit), possible or no ?

Whisper - AI auto-transcription-translation :- https://forum.doom9.org/showthread.php?t=184859

https://i.imgur.com/BNVNKKg.png

EDIT: What kind of speed can one expect (I downed the 170MB-ish CPU version, 1.6-ish GB for GPU ver$ is a bit rich for me, is that much faster ?) ?.
EDIT: I got GTX 1070 Foundation Edition, 8GB Ram.

VoodooFX
29th April 2023, 19:16
VX, I noticed that you added a software to produce Subtitles from audio using AI, in subtitles forum.
Is you gonna add AI thingy to InpaintDelogo (or a new delogo whotsit), possible or no?
Last time I checked [end of the last year] few AI delogo implementations, there were some deal braking issues, but results were very promising, probably stuff needs to be touched by the right hands. [I don't plan to touch it... maybe, in unforeseeable future]


...or a new delogo whotsit
If I'll be not too sober tonight I can write some new whotsit for you, I always thought that deKafka, xLogo & ect. should be better, shouldn't be hard to improve those, no? :)


Whisper....

EDIT: What kind of speed can one expect (I downed the 170MB-ish CPU version, 1.6-ish GB for GPU ver$ is a bit rich for me, is that much faster ?) ?.
EDIT: I got GTX 1070 Foundation Edition, 8GB Ram.

If you have decent 4 real cores CPU you can achieve ~nearly real time on "medium" model, but that depends from audio content. I don't have GPU with CUDA, people say GPU is ~5x faster.

EDIT:
Actually I've GPU similar to your, but it's collecting dust in the boxroom, together with the desktop...
For English run "medium.en" model.
Transcription improvement in "medium" vs "large" model is pretty small, imo.

EDIT2:
Btw, in that screenshot there are no errors, despite that main Swedish actor talks rapidly in funky accent, even punctuation is perfect.
Actually, "No, sure." should be "Yes, sure.", but he pronounced something like "Yo" or German "Ja".

StainlessS
29th April 2023, 19:57
I only have the one GPU (I'm not really counting the crappy GT 520 [I think] in my No 2 machine).
However, I have accumulated 5 of the 1Litre tiny/mini/micro (Lenovo/HP/Dell) machines in the last few months,
and also a fanless dual Lan Industrial PC with 4 comms ports. (Advantech ARK-2250, maybe gonna try get pfsense Firewall on it).
I'm also sorta looking for uses for the tiny machines, maybe could use one for CPU based AI Subs extraction.
I dont have any AMD machines, but I think that the HP AMD Mini machines have a dedicated GPU.

drunksunk
29th April 2023, 19:57
Error in red means that you don't have InpaintDelogo in plugins folder.
Dunno what that error in the window means. What is version of AvsPmod?


Yep, that's how you can add it.
DirectShowSource() filter is outdated, I recommend LWLibAvVideoSource(), it comes from LSMASHSource plugin.



Here you go:
Version()
What it shows for you?

This one should work too:
ColorBarsHD()

I have InpaintDelogo in "plugin64+" folder so it should be detected. I change the code in the script to "Version()" but how do I run it?

VoodooFX
29th April 2023, 20:11
I change the code in the script to "Version()" but how do I run it?
There is a "triangle" button at the bottom left to toggle the preview window.
A mouse click on preview refreshes it if script was changed.

StainlessS
29th April 2023, 21:06
Btw, in that screenshot there are no errors, despite that main Swedish actor talks rapidly in funky accent, even punctuation is perfect.
Actually, "No, sure." should be "Yes, sure.", but he pronounced something like "Yo" or German "Ja".
I guess that you will be adding AI powered spoken language translation to the subs thingy too :)

EDIT:
I downed the 170MB-ish CPU version, 1.6-ish GB for GPU ver$ is a bit rich for me, is that much faster ?
I'll down the GPU ver$ in the pub for free.

EDIT: Sorry, I should maybe have posted in the Sutitles forum thread.

VoodooFX
29th April 2023, 22:06
I guess that you will be adding AI powered spoken language translation to the subs thingy too :)

There is translation option already.

Sorry, I should maybe have posted in the Sutitles forum thread.Yep.

doctorkhv
30th April 2023, 10:06
Hi, try Turbo=-1.

But that is not true. :)

Customized inpainting setting to Sharpness=100, preBlur=0.01, postBlur=4, Radius=12 ["defects" are gone]:
Read the Note there (https://github.com/Purfview/InpaintDelogo/blob/3dea6e23f0a6c5156c312d480f2524a5fb7a2c03/InpaintDelogo.avsi#L899)carefully.

"mShow=3" [for reference, your mask with the holes overlaid ]:
(Changed the holes' color to red from black in latest commit to the test branch in GitHub.)


VoodooFX thanks a lot for the very detailed answer!
Creating a PNG with a mask of any color and transparency with border feathering is not a problem. One can also share this long scene, but by what criteria?
What should be the script?
InpaintDelogo( mask="X:\01amask.png", Loc="0,0,0,0", Optimize1=0, Sharpness=100, preBlur=0.01, postBlur=4, Radius=12, Inflate=0, Turbo=-1)

VoodooFX
30th April 2023, 14:23
Creating a PNG with a mask of any color and transparency with border feathering is not a problem. One can also share this long scene, but by what criteria?
I don't understand what you meant here.



What should be the script?
InpaintDelogo( mask="X:\01amask.png", Loc="0,0,0,0", Optimize1=0, Sharpness=100, preBlur=0.01, postBlur=4, Radius=12, Inflate=0, Turbo=-1)

Not sure what you are asking here too.
Btw, Turbo is predefined presets for those inpainting parameters, you shouldn't be able to use Turbo when you change them from defaults.

drunksunk
30th April 2023, 18:58
So I click the triangle and I see nothing: https://i.imgur.com/3Tni56q.png

Does anyone know which is the best command to remove the top right watermark on this video (https://drive.google.com/drive/folders/1AnXe4TYFfPYwJTW08DU4np30WI60y56W)?

VoodooFX
30th April 2023, 20:03
So I click the triangle and I see nothing: https://i.imgur.com/3Tni56q.png

Does anyone know which is the best command to remove the top right watermark on this video (https://drive.google.com/drive/folders/1AnXe4TYFfPYwJTW08DU4np30WI60y56W)?

Not nothing, you can see version of Avisynth+ in the preview window at the bottom.
Add your video to the script to see your video.
Later I'll check your video.

drunksunk
1st May 2023, 10:44
Not nothing, you can see version of Avisynth+ in the preview window at the bottom.
Add your video to the script to see your video.
Later I'll check your video.

Any update with the video?

VoodooFX
1st May 2023, 13:07
Does anyone know which is the best command to remove the top right watermark on this video (https://drive.google.com/drive/folders/1AnXe4TYFfPYwJTW08DU4np30WI60y56W)?
Why do you want to remove logos from some youtube gaming videos?

Any update with the video?

Yes:


# Here you import your video:
LWLibAvVideoSource("D:\test4k.mp4")

# Here we crop black borders from video:
Crop(0,250,0,-250)

# Here I located logo coords [+20 pixels from logo edges]:
# Crop(3300,0,-240,-1466)

# Here we do delogo [first run with Automask=1 to get a basemask automatically, then set it to 0 to do analyze and delogo]
InpaintDelogo(Loc="3300,0,-240,-1466", mask="D:\mask.bmp", Automask=0, aMix=-2, NoBorderAt="top", AnalyzeTh=30, mode="Deblend", dPP=-5, Interp=3, Optimize2=2)

Before:
https://thumbs2.imgbox.com/41/86/U5e2foxL_t.png (https://images2.imgbox.com/41/86/U5e2foxL_o.png)

After:
https://thumbs2.imgbox.com/d8/4c/QUsBWdu0_t.png (https://images2.imgbox.com/d8/4c/QUsBWdu0_o.png)

drunksunk
1st May 2023, 22:58
Any clue what are these errors I keep having whenever opening AvsPmod? https://i.imgur.com/0E3vuga.png

Anyway "mask file not found" obviously, how did you generate that?


And I'd like to suggest that you add all dependencies to your repo on GitHub, it took me some time after every restart to see the errors and add the extra plugins.

VoodooFX
1st May 2023, 23:33
Any clue what are these errors I keep having whenever opening AvsPmod? https://i.imgur.com/0E3vuga.png
Ask in AvsPmod's thread.

Anyway "mask file not found" obviously, how did you generate that?
Read my previous post.

And I'd like to suggest that you add all dependencies to your repo on GitHub, it took me some time after every restart to see the errors and add the extra plugins.
All dependencies are posted there already. :confused:

RidgeShark
2nd May 2023, 01:22
A bit late with this, but thank you VoodooFX!

drunksunk
2nd May 2023, 01:25
First got error that it was missing, then I added the plugin but I get this: https://i.imgur.com/SLn2f8h.png

kedautinh12
2nd May 2023, 01:35
You can download FFTW-3.3.10-DLLs.rar here:
https://forum.doom9.net/showthread.php?p=1965537#post1965537

Copy and paste 32bit to SysWOW64, 64bit to System32

drunksunk
2nd May 2023, 01:43
Ok, now I can play the video with the changes, but it doesn't get exported.

VoodooFX
2nd May 2023, 02:05
First got error that it was missing, then I added the plugin but I get this: https://i.imgur.com/SLn2f8h.png

That is Neo_FFT3D's dependency, and on its page clearly written what and how to install it.

Ok, now I can play the video with the changes, but it doesn't get exported.

You meant encode. There are numerous tools to encode. Create another thread, ask there how to encode avs scripts.

drunksunk
2nd May 2023, 02:14
That is Neo_FFT3D's dependency, and on its page clearly written what and how to install it.



You meant encode. There are numerous tools to encode. Create another thread, ask there how to encode avs scripts.

I don't get it. What's the point of InpaintDelogo if it doesn't export the result?

VoodooFX
2nd May 2023, 02:21
A bit late with this, but thank you VoodooFX!

You are welcome. I hope you redone the basemask you posted there, it was pretty bad.
Actually I still have those files, I didn't decided if it's worth to add that logo to the database. Did that company added that logo to all DVDs or just that one with trailers DVD?

VoodooFX
2nd May 2023, 02:52
I don't get it. What's the point of InpaintDelogo if it doesn't export the result?
What is the point of Notepad if you can't bake waffles with it? :)

StainlessS
2nd May 2023, 09:24
Which NotePad menu is the waffle maker on (or is it in NotePad++) ?

Does Notepad have a midge killer function ?

Man, I hate dat dem midge thingies, my forehead and back itchy like hell. :(
[been gettin' eaten alive, last couple of days].

lollo2
2nd May 2023, 13:11
I don't get it. What's the point of InpaintDelogo if it doesn't export the result?

You are more and more boring. Learn AviSynth, how to install filters and their dependencies, and then you can blame for something.

Master VoodooFX You was far too kind with you!

kedautinh12
2nd May 2023, 13:51
Yeah, VX very kine when explain him but he need learn avisynth basic :D

VoodooFX
2nd May 2023, 15:09
He needs time, wrapping your head around Avisynth is not a one day's task.

I remember my first time reading about Avisynth, my first impression was "WTF is this". :D
I think I started using it in early 2000s for VdubMod to import unsupported video formats.

..midge..
I had to google this word. :)

StainlessS
2nd May 2023, 23:53
I had to google this word
Sand fly, aka 'baby mosquito", oder, mosquito like, but smaller whotsit.

EDIT: Still not nice, but nobody died from midge bite, yet. (maybe Il'll be the 1st)

drunksunk
5th May 2023, 01:37
This is the result I obtained with HitPaw (it seems less noticeable): https://streamable.com/dexf0a

Regarding the tool, I don't know the installation procedure aside from having AviSynth installed on my computer. I don't know which paramaters of the command I would need to run then, how you get the square box pixel coordinates within your images, if you need to create a mask file of the part you want to remove and that's an alternative of using the pixel coordinates, etc.

I tried this but I get error "increase analyzeth" and i increase to 100 but nothing changed.

InpaintDelogo(Loc="3020,450,-460,-1430", mask="D:\mask.bmp", Automask=1, aMix=-2, AnalyzeTh=100, mode="Deblend", dPP=-5, Interp=3, Optimize2=2)

VoodooFX
5th May 2023, 02:32
I tried this but I get error "increase analyzeth" and i increase to 100 but nothing changed.
OK, thanks for letting me know.

drunksunk
7th May 2023, 01:25
Doesn't the same command work well for opaque logos?

VoodooFX
7th May 2023, 13:06
Doesn't the same command work well for opaque logos?
Those settings are for a transparent logo [for that another video]. Anyway, for an "automask" run most of them are not used.
That error could mean that coords are wrong or there are no suitable frames to analyze. Set Analyze=3 to analyze all frames.
You better share the video or you'll have thousand other questions and I don't have a crystal ball to answer them.

drunksunk
7th May 2023, 20:10
The video is this one: https://forum.doom9.org/showpost.php?p=1986243&postcount=707

VoodooFX
7th May 2023, 20:14
The video is this one: https://forum.doom9.org/showpost.php?p=1986243&postcount=707

There is no video.

drunksunk
10th May 2023, 01:36
There is no video.

It's actually a video you edited yourself. Anywhere it was archived on Streamable so I reuploaded it here (https://drive.google.com/file/d/1Lhu1QQVd1prGc95IHZFasGXpIqcQ0fy4/view?usp=sharing).

VoodooFX
11th May 2023, 01:13
It's actually a video you edited yourself.
I couldn't edit video you never shared. I edited your image!
Anyway this logo is not a logo but some special effect from game, whole area around those letters has some effects.
You better use DoomDelogo (https://forum.doom9.org/showthread.php?t=184881) for this.

drunksunk
11th May 2023, 09:57
I couldn't edit video you never shared. I edited your image!
Anyway this logo is not a logo but some special effect from game, whole area around those letters has some effects.
You better use DoomDelogo (https://forum.doom9.org/showthread.php?t=184881) for this.

I know for a fact that it's a logo added on top because I have another video which is identical but without the logo. The only issue is that it's lower quality.

poisondeathray
11th May 2023, 13:43
I know for a fact that it's a logo added on top because I have another video which is identical but without the logo. The only issue is that it's lower quality.

How much "lower quality" ? Did you try align & merging them with a mask ?

VoodooFX
11th May 2023, 15:35
I have another video which is identical but without the logo.
Then share this another video.

poisondeathray
11th May 2023, 16:42
Anyway this logo is not a logo but some special effect from game, whole area around those letters has some effects.


It looks like some of the artifacts are from motion interpolation. They correspond to the errors in other parts of the frame on the odd frames . The other artifacts around the logo are compression artifacts. The original video is 30fps .

VoodooFX
11th May 2023, 18:53
Whatever this is, for me it looks like there is some blend around area then inconsistent blur on to it. Nothing left to deblend, even if it was clean blend then clip is too short to build deblend mask.
Whole area needs to by treated as a one big hole, I don't even know what inpaint settings should be used on such, if found they probably would be very slow.
When I was thinking about "Turbo" argument I had idea to dowsample stuff then inpaint, maybe such approach would work here.

drunksunk
17th May 2023, 02:34
Is it better to use InpaintDelogo before or after an AI Upscaler like Topaz AI Video?

kedautinh12
17th May 2023, 02:37
I think before and if your video interlaced, you need deinterlaced before use InpaintDelogo

VoodooFX
17th May 2023, 10:46
Is it better to use InpaintDelogo before or after an AI Upscaler like Topaz AI Video?
Before. But better is to not use upscaler at all.

drunksunk
17th May 2023, 22:00
I thought that with higher resolution and crispier edges the result would be better? Anyway, can't get a good mask out of this: https://i.imgur.com/6MrRVZu.png

Mask: https://i.imgur.com/Yej7xi2.png

Maybe I should create it manually with Photoshop?


I'm using this:

InpaintDelogo(Loc="1570,910,-30,-60", mask="D:\mask.bmp", Automask=1, aMix=-2, AnalyzeTh=100, mode="Deblend", dPP=-5, Interp=3, Optimize2=2)

VoodooFX
17th May 2023, 23:01
You are using parameters from another logo, this is not how it works. Read the manual!

drunksunk
18th May 2023, 15:27
You are using parameters from another logo, this is not how it works. Read the manual!

Do I just need to lower AnalyzeTh to fix it?

katzenjoghurt
18th May 2023, 18:55
Do I just need to lower AnalyzeTh to fix it?

With AnalyzeTh=255 pretty much all frames should be analyzed.

Easier:

InpaintDelogo(Loc="1570,910,-30,-60", mask="D:\mask.bmp", mode="Deblend", Automask=1, Analyze=3)

Analyze=3 will also analyze all frames. Default is 2.

VoodooFX
18th May 2023, 21:42
Do I just need to lower AnalyzeTh to fix it?
There is no magic button to "fix it", there are many ways for many different videos, you need to understand what the arguments do to get desired result.

Without video you are on your own.

drunksunk
19th May 2023, 01:36
There is no magic button to "fix it", there are many ways for many different videos, you need to understand what the arguments do to get desired result.

Without video you are on your own.

HERE (https://drive.google.com/drive/folders/1AnXe4TYFfPYwJTW08DU4np30WI60y56W?usp=share_link) is the video.

Honestly I think the upscaled version would have been better but the AVS plugin can't seem to open that (maybe 12GB is too big) and always says it cannot find the find somehow.

I tried to create the mask manually by using the SVG version of the logo, dunno if you can get a better result automatically. https://i.imgur.com/PpdLlG1.png

I think it would be actually cool if there was a function where you can pass an svg logo as an rgument and it looks for the logo within the frame and automatically scale it perfectly to fit and then generates a mask.

katzenjoghurt
19th May 2023, 19:59
When I was thinking about "Turbo" argument I had idea to dowsample stuff then inpaint, maybe such approach would work here.

I think that would be cool.
I once tried to inpaint a UHD Video with a really big logo.
No way to get a good result with default settings - the noise in the inpainted corner was way too distracting.

But the result was ok when I downsized the video to 480p, and inpainted the logo with Sharpness=1.
It was superblurry of course but also calm so that it didn't distract and still way better than with the original logo.

But there was no way to reproduce the same thing directly in the UHD source.
In the UHD video Sharpness=1 didn't create anyway near the same amount of blur as it did in 480p.
dPP/oPP couldn't compensate for that.

drunksunk
21st May 2023, 03:05
So nobody knows how to fix?

drunksunk
27th May 2023, 17:44
Anybody still alive?

katzenjoghurt
29th May 2023, 10:17
Anybody still alive?

I'll chime in, even if I only have a mediocre solution for you.

1) Get a better version of that video from here:
https://assets14.ign.com/videos/zencoder/1920/211e97c678636e1461aa50b31714e8a4-5000000-1426343076-w.mp4
(It's a 817MB file with a 5000kbps encoding rather than your 3000kbps clip)

2) It's actually pretty tricky to create a proper mask due to (I guess)
a) encoding artifacts
b) very transparency parts of the logo
c) hard enbedded subtitles overlapping with the logo at times - InpaintDelogo will add them to the mask

So I selected only parts where the subtitles aren't overlapping with the logo.

Trim(0,340) + Trim(1235,3662) + Trim(4152,4684) + Trim(4982,6685) + Trim(7068,8111) + Trim(8344,8878) \
+ Trim(9325,9495) + Trim(10091,10560) + Trim(10815,11348) + Trim(11603,13157) + Trim(13328,14477) \
+ Trim(14605,16117) + Trim(16372,17713) + Trim(17884,18756) + Trim(18927,19991) + Trim(20779,22674) \
+ Trim(22993,25399) + Trim(25591,26293) + Trim(26655,27336) + Trim(27741,30147) + Trim(34852,35022)

InpaintDelogo(mask="V:\Logos\Test\IGN.bmp", Loc="1572, 906, -20, -60", Mode="Deblend", Automask=1, Analyze=3)

But still I had to overpaint some gaps manually afterwards with MS Paint.

Here's the resulting mask:
https://i.ibb.co/RSWVvc0/IGN.png

3)
The deblending analysis I did with these parameters:
InpaintDelogo(mask="V:\Logos\Test\IGN.bmp", Loc="1572, 906, -20, -60", Mode="Deblend", Automask=0, Analyze=-2, Deep=5, Optimize2=2, Interp=0)

Keep the the trims as the overlapping subtitles will also be a problem here.

Due to that overlapping, interpolation would also warp the subtitles in a pretty nasty way. So I disabled it with Interp=0.
But (also) due to that more remains of the logo are visible, especially whenever the background is rather bright.

We can't fight it with more blurring (by going to lover dPP levels) as that would also blur the subtitles.

https://i.ibb.co/pJgJnB4/Bild-2023-05-29-110840979.png (https://imgbb.com/)

https://i.ibb.co/x671g1Y/Bild-2023-05-29-111307449.png (https://imgbb.com/)




Check it out for yourself.
Download the mask (https://i.ibb.co/RSWVvc0/IGN.png) above, reconvert it to bmp and try these lines:
(edit: trims added)


Trim(0,340) + Trim(1235,3662) + Trim(4152,4684) + Trim(4982,6685) + Trim(7068,8111) + Trim(8344,8878) \
+ Trim(9325,9495) + Trim(10091,10560) + Trim(10815,11348) + Trim(11603,13157) + Trim(13328,14477) \
+ Trim(14605,16117) + Trim(16372,17713) + Trim(17884,18756) + Trim(18927,19991) + Trim(20779,22674) \
+ Trim(22993,25399) + Trim(25591,26293) + Trim(26655,27336) + Trim(27741,30147) + Trim(34852,35022)

InpaintDelogo(mask="V:\Logos\Test\IGN.bmp", Loc="1572, 906, -20, -60", Mode="Deblend", Automask=0, Analyze=-2, Deep=5, Optimize2=2, Interp=0)


Hope that helps.

VoodooFX
29th May 2023, 16:35
@katzenjoghurt Nice result!

I see you used negative Analyze, were results with positive worse?

katzenjoghurt
29th May 2023, 19:00
Hey VoodooFX,

I find Analyze=-2 (or -1), Deep=5 still useful in many cases.
Please never remove it. :)
Here it helps with the IGN icon.

Source:
https://i.ibb.co/34jGpQK/Bild-2023-05-29-195527365.png (https://imgbb.com/)

Analyze=3:
https://i.ibb.co/BnjQ7Jr/Bild-2023-05-29-195709425.png (https://imgbb.com/)

Analyze=2:
https://i.ibb.co/YjpXzMb/Bild-2023-05-29-195853815.png (https://imgbb.com/)

Analyze=-2:
https://i.ibb.co/tH5Kxbz/Bild-2023-05-29-200123099.png (https://imgbb.com/)

drunksunk
30th May 2023, 01:27
Thanks for the great work. Is it normal that you still get a sign on the bottom right corner? https://imgur.com/a/pCZfds7

My code looks like this:


LWLibAvVideoSource("D:\Z_DELOGO\IGN.mp4")

InpaintDelogo(mask="D:\Z_DELOGO\IGN.bmp", Loc="1572, 906, -20, -60", Mode="Deblend", Automask=0, Analyze=-2, Deep=5, Optimize2=2, Interp=0)

Also, what's the difference between using a bmp mask vs png?

katzenjoghurt
30th May 2023, 09:14
Thanks for the great work. Is it normal that you still get a sign on the bottom right corner? https://imgur.com/a/pCZfds7


Argh. My bad. I mentioned that you would need to keep the trims for deblend analysis but my "quick guide" at the end neglected it.
I edited it.

The "signs" are the result of InpaintDelogo analyzing frames where the subtitles overlap with the logo. With the Trims these frames will be skipped.

1) Add the Trims
2) delete the old created .ebmp deblend files or add ReAnalyze=1 for one run
3) The "signs" should be gone now.
4) Remove the Trims.


Also, what's the difference between using a bmp mask vs png?

Oh. I just wasn't aware that InpaintDelogo happily accepts pngs.

VoodooFX
30th May 2023, 13:14
Hey VoodooFX,

I find Analyze=-2 (or -1), Deep=5 still useful in many cases.
Please never remove it. :)
Strange, negative Analyze should be useful only in very rare cases like in some very short clips.

VoodooFX
30th May 2023, 16:17
Here are my results on that 480MB zzz.mp4 file.

Getting a basemask with Automask:

LWLibAvVideoSource("D:\zzz.mp4")
InpaintDelogo(mask="D:\mask.bmp", Loc="1570, 904, -28, -58", Analyze=-4, Automask=1, aMix=3)



Getting a deblend mask [no need for trims with Analyze 1/-1] and delogo:

LWLibAvVideoSource("D:\zzz.mp4")
InpaintDelogo(mask="D:\mask.bmp", Loc="1570, 904, -28, -58", Mode="Deblend", Analyze=1, dPP=-5)


1) Original [frame 6554]:
https://images2.imgbox.com/d9/4f/PxxMGG7N_o.png

2) Delogo Analyze=1
https://images2.imgbox.com/89/83/h7PKmynh_o.png

3) Delogo Analyze=-1, Deep=5:
https://images2.imgbox.com/31/2a/XD6TDulL_o.png

In #3 there are less artifacts on that circle at the left but rest looks a bit worse than 2.

Actually negative Analyze looks worse than positive, that artifacts reduction comes from deblend iteration aka Deep [which is not implemented for positive Analyze].

kedautinh12
30th May 2023, 16:57
Why you don't add deep for positive Analyze??

VoodooFX
30th May 2023, 22:15
Why you don't add deep for positive Analyze??
I didn't see it useful anywhere with positive Analyze and in general it's a nonsensical "hack".

EDIT:
Just tested now, AnalyzeTh=45 produced similar reduction on artifacts on that circle without making worse the rest of deblend like Deep:

LWLibAvVideoSource("D:\zzz.mp4")
InpaintDelogo(mask="D:\mask.bmp", Loc="1570, 904, -28, -58", Mode="Deblend", Analyze=1, AnalyzeTh=45, dPP=-5)

https://images2.imgbox.com/26/e7/WGdHdQZ8_o.png

drunksunk
4th June 2023, 14:40
So, using the higher quality 817MB video, which of all proposed solutions gives the best results?

VoodooFX
4th June 2023, 18:36
So, using the higher quality 817MB video, which of all proposed solutions gives the best results?
But that's what YOU should tell us.

drunksunk
10th June 2023, 22:21
Why do you want to remove logos from some youtube gaming videos?



Yes:


# Here you import your video:
LWLibAvVideoSource("D:\test4k.mp4")

# Here we crop black borders from video:
Crop(0,250,0,-250)

# Here I located logo coords [+20 pixels from logo edges]:
# Crop(3300,0,-240,-1466)

# Here we do delogo [first run with Automask=1 to get a basemask automatically, then set it to 0 to do analyze and delogo]
InpaintDelogo(Loc="3300,0,-240,-1466", mask="D:\mask.bmp", Automask=0, aMix=-2, NoBorderAt="top", AnalyzeTh=30, mode="Deblend", dPP=-5, Interp=3, Optimize2=2)

Before:
https://thumbs2.imgbox.com/41/86/U5e2foxL_t.png (https://images2.imgbox.com/41/86/U5e2foxL_o.png)

After:
https://thumbs2.imgbox.com/d8/4c/QUsBWdu0_t.png (https://images2.imgbox.com/d8/4c/QUsBWdu0_o.png)

I used the same rule you used here, just different coordinates but I get a poor result with this video (https://www.youtube.com/watch?v=QUjf9DbLxtk).

The logo is basically the same, just a bit smaller, so I thought the same rules would work fine.

VoodooFX
11th June 2023, 14:32
I used the same rule you used here, just different coordinates but I get a poor result with this video (https://www.youtube.com/watch?v=QUjf9DbLxtk).

The logo is basically the same, just a bit smaller, so I thought the same rules would work fine.

Post your full avs script.

drunksunk
12th June 2023, 00:05
Post your full avs script.

# Here you import your video:
LWLibAvVideoSource("D:\Z_DELOGO\b\copy.mp4")

# Here I located logo coords [+20 pixels from logo edges]:
#Crop(1650,50,190,180)

# Here we do delogo [first run with Automask=1 to get a basemask automatically, then set it to 0 to do analyze and delogo]
InpaintDelogo(Loc="1650,50,190,180", mask="D:\mask.bmp", Automask=1, aMix=-2, NoBorderAt="top", AnalyzeTh=30, mode="Deblend", dPP=-5, Interp=3, Optimize2=2)

VoodooFX
12th June 2023, 15:38
You don't need NoBorderAt on this video. And you are analyzing frames without logo and frames with logo fade in/out animations, exclude those parts of video with Trim().
On frames with logo animation use mode=Inpaint.

drunksunk
12th June 2023, 22:45
You don't need NoBorderAt on this video. And you are analyzing frames without logo and frames with logo fade in/out animations, exclude those parts of video with Trim().
On frames with logo animation use mode=Inpaint.

You need to duplicate the InpaintDelogo command for some frames with mode=Inpaint? Not sure I understood that well.

VoodooFX
13th June 2023, 23:21
I've looked at that video, looks like logo is animated whole clip, you can't deblend it.
Just use inpaint on it.

mode=Inpaint, Turbo=-1


Before:
https://thumbs2.imgbox.com/67/a4/sh5euKEy_t.jpg (https://images2.imgbox.com/67/a4/sh5euKEy_o.jpg)

After:
https://thumbs2.imgbox.com/f0/c2/lxyAlzzZ_t.jpg (https://images2.imgbox.com/f0/c2/lxyAlzzZ_o.jpg)

drunksunk
16th June 2023, 02:50
I've looked at that video, looks like logo is animated whole clip, you can't deblend it.
Just use inpaint on it.


Nice, ty.

I didn't see it useful anywhere with positive Analyze and in general it's a nonsensical "hack".

EDIT:
Just tested now, AnalyzeTh=45 produced similar reduction on artifacts on that circle without making worse the rest of deblend like Deep:

LWLibAvVideoSource("D:\zzz.mp4")
InpaintDelogo(mask="D:\mask.bmp", Loc="1570, 904, -28, -58", Mode="Deblend", Analyze=1, AnalyzeTh=45, dPP=-5)

https://images2.imgbox.com/26/e7/WGdHdQZ8_o.png
It's amazing how good the result is with this setting, looks perfect almost everywhere except certain parts where you can slightly see the halo effect left by the logo. If I wanted to push a little further getting completely rid of the logo but risking the overlapping text becoming blurrier, what would be the setting to tweak for that?

VoodooFX
16th June 2023, 03:30
If I wanted to push a little further getting completely rid of the logo but risking the overlapping text becoming blurrier, what would be the setting to tweak for that?
Then you don't want to use "1" from Optimize2 argument which is enabled by default. Set Optimize2=2.

drunksunk
8th July 2023, 08:37
1) Get a better version of that video from here:
https://assets14.ign.com/videos/zencoder/1920/211e97c678636e1461aa50b31714e8a4-5000000-1426343076-w.mp4
(It's a 817MB file with a 5000kbps encoding rather than your 3000kbps clip)

How did you manage to find the real video location on the website? When analyzing the network traffic, the best I can find is the .m3u file of the stream for reconstructing the file using ffmpeg, but somehow you managed to find the actual mp4 source and I wonder how you did that.

Example: https://www.ign.com/articles/2015/02/06/making-bloodborne-part-1-souls-evolved-ign-first

https://assets7.ign.com/videos/zencoder/1920/022886772aa71c37e3cde38f1a188569-8000000-1426350275-w.m3u8

Also, do you think this mask would work fine for all videos as long as the type of logo to remove is the same?

InpaintDelogo(mask="D:\mask.bmp", Loc="1570, 904, -28, -58", Mode="Deblend", Analyze=1, AnalyzeTh=45, dPP=-5)

drunksunk
17th July 2023, 00:33
Can somebody tell me how to improve my mask? I use this:

InpaintDelogo(Loc="1590,910,-10,0", mask="D:\Z_DELOGO\d\mask.bmp", Automask=1, Analyze=3)

But the logo gets removed well only for left half, while right half has some extra stuff that gets captured.

File is THIS (https://drive.google.com/file/d/1HJYJcKSfH-jo9jDHGWmknC3Ood0yHkHr/view?usp=drive_link)

VoodooFX
17th July 2023, 13:50
Is that logo only last for 13 seconds?

These settings produce good basemask:


LWLibAvVideoSource("D:\file.mp4")

InpaintDelogo(Loc="1600,912,-20,-6", mask="D:\morbid.bmp", Automask=1, Analyze=-4, FrB=136, aMix=-5)


https://i.imgur.com/2S7CnsG.png

drunksunk
19th July 2023, 21:26
What about this other video (https://drive.google.com/file/d/1X2y6QhmfpaINpHYnTUKaT03IE-D_DlzC/view?usp=sharing)?

I used this:

InpaintDelogo(Loc="1540,870,-70,-30", mask="D:\Z_DELOGO\e\mask.bmp", Automask=1, Analyze=-4, aMix=-5)

But I noticed there are still some small white particles left. Trying to tweak the aMix does never trully give perfect result all-around.

VoodooFX
19th July 2023, 22:53
What about you "answering" questions with questions?

drunksunk
29th July 2023, 17:24
What about you "answering" questions with questions?

Yes, sorry that was only 13s indeed.

drunksunk
29th July 2023, 18:02
I think I found a bug in InpaintDelogo when using portable (loose files) AviSynth+ installation instead of Windows installer: https://i.imgur.com/uLkcWJ9.png

VoodooFX
29th July 2023, 18:35
I think I found a bug in InpaintDelogo when using portable (loose files) AviSynth+ installation instead of Windows installer: https://i.imgur.com/uLkcWJ9.png

It's not a bug, it's a message telling you what to do:
"Load 'ImageSeq.dll' with 'LoadPlugin' or install Avisynth+."

drunksunk
29th July 2023, 18:52
It's not a bug, it's a message telling you what to do:
"Load 'ImageSeq.dll' with 'LoadPlugin' or install Avisynth+."
The fact is that AviSynth+ is installed, but it's installed as loose files and it's references inside AvsPmod settings in "Custom AviSynth directory".

drunksunk
29th July 2023, 19:19
After months I'm still unable to automask correctly...

What am I doing wrong? Mask looks perfect, but when applied the end result is garbage... https://i.imgur.com/wakI9KN.png

Automask=1, mode="Deblend", Analyze=2

Clip is THIS (https://drive.google.com/file/d/1j9yOsgfBCaj40Qcj-zS3Rr1rKhxaOgKZ/view?usp=drive_link)

drunksunk
30th July 2023, 01:40
The problem is that there is no legend with alla the parameters, possible values and what they do.

VoodooFX
30th July 2023, 12:23
The fact is that AviSynth+ is installed, but it's installed as loose files and it's references inside AvsPmod settings in "Custom AviSynth directory".
The real fact is that you didn't installed AviSynth+, you just copied files and plugins are not autoloaded, in such case you need to load them manually with LoadPlugin().

What am I doing wrong? Mask looks perfect, but when applied the end result is garbage... https://i.imgur.com/wakI9KN.png

Automask=1, mode="Deblend", Analyze=2

The basemask is not important for the actual deblending process.
Automask just creates a black/white basemask which is enough only for Inpaint, for Deblend additional deblending masks are auto-created on the first run when Automask is not on.
With "Analyze=2" on this short clip you don't get good deblending masks, that's why you get the garbage result.

The problem is that there is no legend with alla the parameters, possible values and what they do.
The real problem is that you don't read what is posted for you.
I remember answering you multiple times what and where to read.

After months I'm still unable to...
Unable to read posts!? Just kidding... :D

drunksunk
30th July 2023, 13:38
The real fact is that you didn't installed AviSynth+, you just copied files and plugins are not autoloaded, in such case you need to load them manually with LoadPlugin().



The basemask is not important for the actual deblending process.
Automask just creates a black/white basemask which is enough only for Inpaint, for Deblend additional deblending masks are auto-created on the first run when Automask is not on.
With "Analyze=2" on this short clip you don't get good deblending masks, that's why you get the garbage result.


The real problem is that you don't read what is posted for you.
I remember answering you multiple times what and where to read.


Unable to read posts!? Just kidding... :D
I looked at GitHub, looked at first post, etc. but couldn't find the entire list of parameters like you can for ffmpeg and other tools, so I don't know what dPP, Interp, Optimize, AnalyzeTh, aMix, etc. do. Generally when you download an OSS tool you get either get a file with all the instructions or they have a website with the documentation on how to use the tool.

Could you please suggest what parameters should I use for the best result and why you chose those parameters to help me understand the thought process?

VoodooFX
30th July 2023, 14:24
I looked at...
Maybe 6th will be your lucky number. :)

Here you go, links to 5 previous answers I found:

https://forum.doom9.org/showthread.php?p=1987281
https://forum.doom9.org/showthread.php?p=1986329
https://forum.doom9.org/showthread.php?p=1986315
https://forum.doom9.org/showthread.php?p=1986329
https://forum.doom9.org/showthread.php?p=1986299

drunksunk
30th July 2023, 14:53
Maybe 6th will be your lucky number. :)

Here you go, links to 5 previous answers I found:

https://forum.doom9.org/showthread.php?p=1987281
https://forum.doom9.org/showthread.php?p=1986329
https://forum.doom9.org/showthread.php?p=1986315
https://forum.doom9.org/showthread.php?p=1986329
https://forum.doom9.org/showthread.php?p=1986299

So, since the logo is almost completely opaque, I cannot use Deblend on it? With Inpaint I get much better results but there are still some leftover artifacts.

VoodooFX
30th July 2023, 15:18
I have no idea what you mean and I don't see any logical connection to the post you quoted.

drunksunk
30th July 2023, 21:08
I have no idea what you mean and I don't see any logical connection to the post you quoted.
I meant that by looking at documentation in the script, I read that Deblend is only valid for transparent logos, while the video I provided has basically opaque logo so that doesn't work well. I tryed all previous settings and none of them could remove the logo without being slightly noticeable using the Inpaint mode.

VoodooFX
30th July 2023, 21:30
If you mean "bilibili" logo then it's transparent, there is not enough good frames for analysis, even if there were enough, that AV1 video is so much damaged by compression that you wouldn't get good Deblend results anyway.

Actually all videos you posted here are very low or low quality, just use Inpaint on them.

drunksunk
30th July 2023, 22:09
If you mean "bilibili" logo then it's transparent, there is not enough good frames for analysis, even if there were enough, that AV1 video is so much damaged by compression that you wouldn't get good Deblend results anyway.

Actually all videos you posted here are very low or low quality, just use Inpaint on them.

Are there extra parameters I could you to improve the final result or just an Analyze=2 and then apply the mask with mode=Inpaint is all I can do? I tried also DoomDelogo but that's worse.

VoodooFX
30th July 2023, 22:56
Check if Turbo=-1 makes it better.

TrickyTrix
3rd August 2023, 22:42
I used InpaitDelogo with great results a few times with Inpaint mode.
Now I wanted to try Deblend mode on https://www.youtube.com/watch?v=XOiZGSkjygs (ignore the color logo in the beginning and in the end because I'll edit that out later)

My script:
LWLibAvVideoSource("F:\Sheepish_wolf\The_Sheepish_Wolf_(1942).mp4")
InpaintDelogo(automask=0, mask="F:\Sheepish_wolf\logomask.bmp", Loc="1510,886,-178,-100", mode="Deblend")

Mask is created with: InpaintDelogo(automask=0, mask="F:\Sheepish_wolf\logomask.bmp", Loc="1510,886,-178,-100")

Is it normal that you can see transparent defects on dark surfaces after running the script (for instance from 49 to 51 sec)? It's great as is, but I have to ask :)

VoodooFX
4th August 2023, 06:53
Share the masks.
Deblend defects are expected on the low quality videos from Youtube.

TrickyTrix
4th August 2023, 16:36
Here is the mask.

VoodooFX
4th August 2023, 16:47
Don't use attachments in this forum, you can upload to wetransfer or mega ect.
By "masks" I meant .ebmp file.

TrickyTrix
4th August 2023, 19:00
Don't use attachments in this forum, you can upload to wetransfer or mega ect.
By "masks" I meant .ebmp file.
Here it is:
https://mega.nz/file/8sURVQIb#_n7LlV9litR-_DB8k-_Zp6ln2lsbnHma50FAKoTspWs

VoodooFX
4th August 2023, 19:51
Don't know why but I got a lil bit better masks: https://we.tl/t-ULUDdL4gQV

Original vs My vs Yours [with Interp=0, dPP=0 to see pure deblend effect]:

https://i.imgur.com/crpyr0q.png https://i.imgur.com/9UG9pmZ.png https://i.imgur.com/BNVlakE.png

Maybe you didn't excluded non-logo/logo-animation parts when doing analysis. [.mp4 I downloaded is ~180MB]


...can see transparent defects...

I guess it's like on the 2970 frame:

https://i.imgur.com/i4iY4rx.png

It looks like usual Youtube "damage", you could ask the utube uploader for the original undamaged video.

"Optimize2=2, IntSpd=3, dPP=-5" can make it look better like this:

https://i.imgur.com/NkmfkpB.png

But it will make blurry detailed areas where deblending is OK.
You can apply different delogo settings on different parts of video by using Trim().

EDIT:
You can use .ebmp file directly with mask argument -> mask="D:\_mask.bmp_InpaintDelogo3_1510-886-178-100_A2-30.ebmp"

drunksunk
6th August 2023, 00:07
If you can get Deblend mode to just fades the logo a bit but not fully remove it, what setting do you need to tweak to make the removal harder and remove that last bit of transparency? video is this https://t.ly/YXgW1

color
7th August 2023, 17:34
https://i.ibb.co/6F1BM0J/New-File-12-010027.jpg

It has worked perfectly with one color logos, but this...I can get rid of the white (blended away), but the black one is more problematic.

https://we.tl/t-mSWMlUf1yy

I am using the standard thingie:

InpaintDelogo(mask="logo.bmp", Loc="760,580,-90,-50", Mode="Deblend", Automask=0)

kedautinh12
7th August 2023, 23:32
With this logo, i think use mode Inpaint is better

VoodooFX
8th August 2023, 00:45
If you can get Deblend mode to just fades the logo a bit but not fully remove it, what setting do you need to tweak to make the removal harder and remove that last bit of transparency?
If you can't deblend it then you can't. Use Inpaint.

VoodooFX
8th August 2023, 00:59
It has worked perfectly with one color logos, but this...I can get rid of the white (blended away), but the black one is more problematic.

https://we.tl/t-mSWMlUf1yy

Both black and white areas looks same for me.
Before vs After [frame 13585 after trim]:

https://i.imgur.com/bdMCqBx.png https://i.imgur.com/VvTnfZF.png


LWLibAvVideoSource("D:\New File (12).avi")
Trim(118,30904) # Exclude non logo/logo animation for analysis
InpaintDelogo(mode="Deblend", mask="D:\CN.bmp", Loc="12,18,-18,-16")

color
8th August 2023, 08:51
Both black and white areas looks same for me.
Before vs After [frame 13585 after trim]:

https://i.imgur.com/bdMCqBx.png https://i.imgur.com/VvTnfZF.png


LWLibAvVideoSource("D:\New File (12).avi")
Trim(118,30904) # Exclude non logo/logo animation for analysis
InpaintDelogo(mode="Deblend", mask="D:\CN.bmp", Loc="12,18,-18,-16")


Thats what I use, but it looks a bit like this I mean.

I missed the image, sorry:

https://i.ibb.co/9wrwC1m/ss.jpg

optimizer does blur it a little and makes it a little bit more invisible, but not that great.

https://i.ibb.co/k0MrNCH/New-File-12-025794.jpg

frame 025794 when using the "trim"

VoodooFX
8th August 2023, 17:39
Then use Inpaint. Read there about utube videos -> https://forum.doom9.org/showthread.php?p=1990401

color
8th August 2023, 18:07
Then use Inpaint. Read there about utube videos -> https://forum.doom9.org/showthread.php?t=176860

hmm, well inpaint does not look so good. It was recorded directly from tv, but I guess its not enought to get better results. It need to be raw as well.

VoodooFX
8th August 2023, 18:17
It was recorded directly from tv, but I guess its not enought to get better results.
Did you captured original digital stream or recorded it to some lossless codec?

color
8th August 2023, 18:23
Did you captured original digital stream or recorded it to some lossless codec?

Capture the original stream on the hard drive in my DVD-recorder (when I had that one, many years ago), I did choose 720p as resolution, I thought it would give better result, it was more than 10 years ago now. I don't remember if it was through hdmi or scart however, but If i remember correctly hdmi was the only way to be able to save 720, It did give better result when selecting to burn on dvd it gave crisper image than using 576 at the beginning when recording...

VoodooFX
8th August 2023, 18:54
So, not the original digital stream and not lossless.

katzenjoghurt
11th August 2023, 10:48
When I was thinking about "Turbo" argument I had idea to dowsample stuff then inpaint, maybe such approach would work here.

Hi VoodooFX.
Are planning to implement some pre-downsamped inpainting feature one day?

I think it would help to reduce distraction from inpainting noise.
I noticed: The higher the resolution the more distracting wrong reconstructions in inpainting become.

I tried to fight that with blur... but it didn't help too much. Couldn't achieve enough blurryness.

If I reduce UHD videos to FullHD inpainting works a lot better... but of course I'd rather like to keep the video in UHD.

VoodooFX
11th August 2023, 17:06
New version v3.7:

# Version 3.7 : 2023/08/11. Fixed: Broken "YColorSolidIns" arg [code typo].
# Fixed: Bug with "isHD" variable.
# Added 'Mask' path check before running 'Automask'.
# New params: "UVAlphaFromY", "SubPrefix", "SubPostfix".
# Removed "colors_rgb.avsi" dependancy.
# Changed "mShow" to red instead of black.


Are planning to implement some pre-downsamped inpainting feature one day?

Back then I looked at it and it seemed so much work to fully implement it...
I'll check today if some quick limited implementation is possible.

katzenjoghurt
11th August 2023, 17:11
Thanks for considering, VoodooFx! :thanks:

VoodooFX
11th August 2023, 17:33
Thanks for considering, VoodooFx! :thanks:

Just counted, there are 121 arguments, and some with a double function crammed in... I guess it would be no harm for another one. :D
How we name it? Maybe "Turbo2"?

VoodooFX
12th August 2023, 01:16
I noticed: The higher the resolution the more distracting wrong reconstructions in inpainting become.

I tried to fight that with blur... but it didn't help too much. Couldn't achieve enough blurryness.

Do you adjust inpainting settings? Defaults are tuned for SD - HD, Turbo=-1/-2 are more for HD-UHD.

Check the test branch for Turbo2: ;)


# Int "Turbo2" : Pre-downsampled inpainting, sets an resolution divisor for Loc area and masks.
# Meant to speedup inpainting, and improve delogo with the big masks/resolutions.

VoodooFX
12th August 2023, 18:43
With Turbo2 you can get similar effect like with Uglarm but much faster.

Here some comparison with the benchmark results:

https://i.imgur.com/Ptul5eQ.png


Previous sample is "720p", here the hole is in "4K":

https://thumbs2.imgbox.com/ca/c0/JZy1ms32_t.jpg (https://images2.imgbox.com/ca/c0/JZy1ms32_o.jpg)


EDIT:
Remember that with high Turbo2 you need to have bigger borders around logo, like ~8 * Turbo2.

katzenjoghurt
13th August 2023, 16:55
Wow. Didn't expect you'd add it THAT fast. Thanks so much, VoodooFX!!
I'll try it out as soon as I can.

Do you adjust inpainting settings? Defaults are tuned for SD - HD, Turbo=-1/-2 are more for HD-UHD.


Yes, I did.

drunksunk
13th August 2023, 23:29
If you can't deblend it then you can't. Use Inpaint.

Isn't that I just suck at deblending? If I can remove it but there's still a bit of transparency left, I think it's because I'm using the wrong settings.

katzenjoghurt
13th August 2023, 23:54
A super general question but I still dare to ask it here:

I'm only diving into VapourSynth recently due to some substantial speed benefits I get with AI / GPU frame interpolation there.
So, don't laugh... I'm a total VS noob.

Is there any existing way to "wrap" InpaintDelogo so that it can be used with VapourSynth?
(Not asking for a port)

Tried to make InpaintDelogo run with AvsProxy (https://github.com/sekrit-twc/avsproxy) but that eventually failed due to 64bit dependencies... *headscratch*

VoodooFX
14th August 2023, 01:29
Isn't that I just suck at deblending? If I can remove it but there's still a bit of transparency left, I think it's because I'm using the wrong settings.

Could be.
No one knows as you never post full avs scripts nor delogo files/masks.

VoodooFX
14th August 2023, 01:37
Is there any existing way to "wrap" InpaintDelogo so that it can be used with VapourSynth? (Not asking for a port)

No idea. Maybe @Selur knows.
Search VapourSynth's sub-forum, there are threads like this: https://forum.doom9.org/showthread.php?t=175141

Tried to make InpaintDelogo run with AvsProxy (https://github.com/sekrit-twc/avsproxy) but that eventually failed due to 64bit dependencies... *headscratch*

Probably failed do to missing 32bit plugins/AvS+: "Embed 32-bit Avisynth 2.6 or Avisynth+ environment within 64-bit VapourSynth."

katzenjoghurt
14th August 2023, 08:11
Thanks, VoodooFX!


Probably failed do to missing 32bit plugins/AvS+: "Embed 32-bit Avisynth 2.6 or Avisynth+ environment within 64-bit VapourSynth."

Yea - the error I encountered eventually in some AvsProxy log:
AvisynthError_: Cannot load a 64 bit DLL in 32 bit Avisynth: 'C:/Program Files (x86)/AviSynth+/plugins64/AddGrainC.dll'.




By the way, didn’t mention it: Your Turbo2 results look great and super-promising! *thumbsup*
The UHD reconstruction looks (obviously) much better with Turbo2 and really hope it’s more stable.

Was unfortunately distracted with my VapourSynth/CUDA journey and I really want to take time exploring your new Turbo2 feature.
Again: Didn’t expect you to be *that* fast. :)

drunksunk
14th August 2023, 21:08
Could be.
No one knows as you never post full avs scripts nor delogo files/masks.

InpaintDelogo(Loc="2220,0,0,-1370", mask="D:\Z_DELOGO\Projects\1\masky.bmp", Mode="Deblend", Analyze=1, dPP=-5)

Masks are here (https://imgur.com/a/MRfEkBF). I tryed both Photoshop and autogeneration using Delogo.

VoodooFX
14th August 2023, 22:29
InpaintDelogo(Loc="2220,0,0,-1370", mask="D:\Z_DELOGO\Projects\1\masky.bmp", Mode="Deblend", Analyze=1, dPP=-5)

Masks are here (https://imgur.com/a/MRfEkBF). I tryed both Photoshop and autogeneration using Delogo.

You shared only the basemask files, there are .txt and .ebmp files too...

Anyway, below is Original vs Your vs My.

https://i.imgur.com/rR7ywZP.png

https://i.imgur.com/hz23gjV.png

https://i.imgur.com/SquZ8QZ.png

My script:
# InpaintDelogo(Loc="2220,0,0,-1370", mask="D:\chef.bmp", Analyze=-4, Automask=1, aMix=4) # This to get the basemask

InpaintDelogo(Loc="2220,0,0,-1370", mask="D:\chef.bmp", Mode="Deblend", Analyze=-4, dPP=-5) # This to delogo

drunksunk
15th August 2023, 01:46
Yours is actually still quite visible for me, more than in your screenshot.

VoodooFX
15th August 2023, 02:12
yours is actually still quite visible for me, more than in your screenshot.
Okay.

drunksunk
16th August 2023, 03:39
Okay.

Not okay, it's just that I don't understand why. lol I copied your commands to generate the mask and then deblend it, but the end result is a still quite visible logo.

VoodooFX
16th August 2023, 11:09
Not okay, it's just that I don't understand why. lol I copied your commands to generate the mask and then deblend it, but the end result is a still quite visible logo.
I'll repeat it for the last time:
FULL avs script! ALL files created by InpaintDelogo! Screenshots with the frame numbers!

katzenjoghurt
20th August 2023, 21:19
With Turbo2 you can get similar effect like with Uglarm but much faster.

Here some comparison with the benchmark results:
[...]

Hi again, VoodooFX.

with the weekend I finally had enough time to investigate the Turbo2 feature... and for me it's definitely a keeper!!

Did several checks yesterday and a few full reencodings over night and today, and I really like the results.
In the past I couldn't achieve what is possible now: Inpainting in UHD without too much distraction.


How we name it? Maybe "Turbo2"?

Coming back to that question:
My 2 cents: I'd find "Downsample" more descriptive. Or "oDS"? Or does that sound too much like a part of the post-processing params?

For me it's more a quality feature than a pure speed-up feature.

But it's your tool - and from my side I mainly hope you keep the parameter at all. :thanks:

katzenjoghurt
21st August 2023, 09:09
By the way… your Uglarm comparison awoke a longing for smoothed edges. 😇 :rolleyes:

https://i.imgur.com/UyyQBgy.png

kedautinh12
21st August 2023, 09:19
Hi, i meet problem with this tittle, i try both 3 mode with parameter relate and all analyze but can't delogo
https://i.imgur.com/Q44i1no.png
Mask
https://i.imgur.com/mr1muYc.png
Script:
InpaintDelogo(mask="C:\Logos\mask1.bmp", Analyze=2, Automask=0, aMix=-6, Loc="88,860,-870,-56", Mode="Both", otune=10, oTinflate=2)
Video:
https://drive.google.com/file/d/1uRrj8I8tlLs0hWhxz5xtdzoP-neYI73C/view?usp=sharing

VoodooFX
21st August 2023, 13:00
Your mask is hollow and I don't see reason for "Both".

kedautinh12
21st August 2023, 13:35
Your mask is hollow and I don't see reason for "Both".

I mean try 3 mode but don't work

VoodooFX
21st August 2023, 14:09
I mean try 3 mode but don't work
I understood what you meant.

kedautinh12
21st August 2023, 14:21
I understood what you meant.

I try both 3 mode "both", "inpaint", "deblend" but don't work

VoodooFX
21st August 2023, 14:42
I try both 3 mode "both", "inpaint", "deblend" but don't work
Yeah, that's is exactly what I understood from your first post.

Do you understand what I answered? Your basemask is hallow, it doesn't cover the logo you want to remove.

kedautinh12
21st August 2023, 15:02
Yeah, that's is exactly what I understood from your first post.

Do you understand what I answered? Your basemask is hallow, it doesn't cover the logo you want to remove.

I know, but how to make a mask cover all, i try with amix but can't

katzenjoghurt
21st August 2023, 15:18
I know, but how to make a mask cover all, i try with amix but can't

Didn’t have a look at your video myself, but…
Did you take care to trim() to only the section where the logo is actually visible?

I see that it’s not there during the first seconds.


If everything fails you could also fill the holes manually in Paint or so. But I’m sure there’s another way.


Btw. “both” looks about right as the inner part is transparent. Not sure though if it’s transparent enough.
https://i.imgur.com/HZo13iL.jpg

kedautinh12
21st August 2023, 16:16
I trimed but still don't make mask cover all

kedautinh12
21st August 2023, 16:22
Ok, I use Photoshop to paint all white colors but it still doesn't work perfectly with 3 modes
https://i.imgur.com/JmAfU2K.png
Mask:
https://i.imgur.com/Rmoi5sy.png
Scripts:
LoadPlugin("C:\Megui\MeGUI-2944-64\tools\lsmash\LSMASHSource.dll")
LWLibavVideoSource("C:\Users\ADMIN\Downloads\Orphans no Namida -live ver.- - MISIA PV.video-muxed.mkv", format="YUV420P8")
AnimeIVTC(mode=1)
propSet("_FieldBased",0)
trim(333,7304).InpaintDelogo(mask="C:\Logos\mask1.bmp", Analyze=2, Automask=0, aMix=-6, Loc="88,860,-870,-56", Mode="Inpaint")

VoodooFX
21st August 2023, 19:39
I know, but how to make a mask cover all, i try with amix but can't

You can get some PhotoShop course. Btw, your mask doesn't look full white.

Below is example how to get mask with Avisynth:

LWLibAvVideoSource("D:\Orphans no Namida -live ver.- - MISIA PV.ts").TFM
v=Trim(500, 9116)

m=v.Trim(9116,-1).ExtractY.Crop(88,860,-870,-56).mt_binarize(30).mt_expand.mt_expand

v.InpaintDelogo(mask=m, Loc="88,860,-870,-56", mode="Inpaint")

StackVertical(v.Crop(88,860,-870,-56), m.ConvertToYV12, last.Crop(88,860,-870,-56))


Frame 2433:

https://i.imgur.com/pRmIKAP.png

kedautinh12
22nd August 2023, 01:28
Got it, thanks

katzenjoghurt
31st August 2023, 21:08
Hey VoodooFX,

Regarding Turbo2:

Out of your mind: Do you have an idea why I would have to rise Inflate together with Turbo2 for thinner elements in logos?

I rise Turbo2 and suddenly I see artifacts. I can counter them though with Inflate... until I reach the prameter limit of course. :)

If you have no idea right away, I will try to create a sample.

VoodooFX
1st September 2023, 11:53
Do you have an idea why I would have to rise Inflate together with Turbo2 for thinner elements in logos?

If you have no idea right away, I will try to create a sample.

If mask has thin elements then probably they can disappear with high Turbo2, because mask is downscaled.
Yes, share a video sample with mask.

Lirk
16th September 2023, 18:59
Is there FFmpeg Delogo filter port for AviSynth? It looks like "dekafka", but with soft edges blur.

katzenjoghurt
17th September 2023, 12:17
If mask has thin elements then probably they can disappear with high Turbo2, because mask is downscaled.
Yes, share a video sample with mask.

Hi again, VoodooFX.
Finally the promised sample (contains source, logo file, mask):
https://wetransfer.com/downloads/d9e3b5c0c5c3e49d5e7507a43e6b40da20230917111048/007a2dafc0f5f6e2aed4ac3a838dde6520230917111058/aaabad?trk=TRN_TDL_01&utm_campaign=TRN_TDL_01&utm_medium=email&utm_source=sendgrid

Logo:
https://i.imgur.com/uNjCAk6.png

Mode="Inpaint", Optimize1=0, Turbo2=1:
https://i.imgur.com/eVUP4PN.png

Mode="Inpaint", Optimize1=0, Turbo2=3
https://i.imgur.com/rCcrRUf.png

Mode="Inpaint", Optimize1=0, Turbo2=3, Inflate=3
https://i.imgur.com/lXFqc7z.png

tuanden0
4th November 2023, 17:42
@VoodooFX,

Could you give me any example for extracting hardsubbed video?

VoodooFX
4th November 2023, 21:52
@katzenjoghurt I'll fix it in a normal release. Not soon, maybe after I'll implement all features requested for Standalone Faster-Whisper...

@VoodooFX,

Could you give me any example for extracting hardsubbed video?

I don't have any at hand, there should be plenty in this thread.
If something will be unclear then share your avs script with a video sample [where subs are in the brightest backgrounds].

katzenjoghurt
5th November 2023, 18:13
@katzenjoghurt I'll fix it in a normal release. Not soon, maybe after I'll implement all features requested for Standalone Faster-Whisper...

:thanks:👍

doctorkhv
10th December 2023, 06:23
Hello,
Can't configure DeLogo parameters.
Logo in the upper right corner.

https://images2.imgbox.com/7b/cb/6pboEQ58_o.jpg
https://images2.imgbox.com/05/4f/F7vpObm3_o.jpg

Video source https://workupload.com/file/C5KUsGd5W7y
Image source https://workupload.com/file/3PBTYE8naKp

InpaintDelogo( mask="X:\01\120.png", Loc="0,0,0,0", Analyze=-4, Optimize2=2, Inflate=0, Turbo=-1)

kedautinh12
10th December 2023, 10:47
First, choose the location of the logo with InpaintLoc
InpaintLoc(Loc="3560,170,-170,-1790")
https://imgur.com/ZHGVx7f

Second, create a mask with Automask=1. Cause your example video is short so I use Analyze=3
InpaintDelogo(mask="C:\Logos\mask1.bmp", Loc="3560,170,-170,-1790", Automask=1, aMix=-9, Analyze=3)
https://imgur.com/sWLBdXX

Finally, use Automask=0 to use mask for Delogo step and add some parameters. With mode=deblend will get a better result almost but when the logo moves to the boy's hat, the logo will appear so I replaced it with inpaint
InpaintDelogo(mask="C:\Logos\mask1.bmp", Loc="3560,170,-170,-1790", Automask=0, aMix=-9, Analyze=3, Mode="Inpaint", Optimize1=1, Optimize2=3, Interp=3, IntSpd=4, dPP=-5)
https://imgsli.com/MjI1MTQ5/0/1

VoodooFX
10th December 2023, 18:07
Hello,
Can't configure DeLogo parameters.
Logo in the upper right corner.

Video source https://workupload.com/file/C5KUsGd5W7y
Image source https://workupload.com/file/3PBTYE8naKp

InpaintDelogo( mask="X:\01\120.png", Loc="0,0,0,0", Analyze=-4, Optimize2=2, Inflate=0, Turbo=-1)

1) The mask is bad, it's not full white.
2) Every parameter doesn't make sense.
3) As nothing makes sense, what exactly you are trying to do with that logo?

doctorkhv
21st December 2023, 01:32
1) The mask is bad, it's not full white.
2) Every parameter doesn't make sense.
3) As nothing makes sense, what exactly you are trying to do with that logo?
Thank you!
Tell me, so as not to be distracted by trifles, what can be added to the script like
InpaintDelogo( mask="D:\01.png", Loc="0,0,0,0", Inflate=0)
I can add and change values
Analyze=-4, Optimize2=2, Turbo=-2,
what else can you add?

Your tutorial at https://github.com/Purfview/InpaintDelogo/ is difficult for me to understand.
Sincerely,
Eugene

kedautinh12
21st December 2023, 01:55
Thank you!
Tell me, so as not to be distracted by trifles, what can be added to the script like
InpaintDelogo( mask="D:\01.png", Loc="0,0,0,0", Inflate=0)
I can add and change values
Analyze=-4, Optimize2=2, Turbo=-2,
what else can you add?

Your tutorial at https://github.com/Purfview/InpaintDelogo/ is difficult for me to understand.
Sincerely,
Eugene

Did you try my suggestion?

doctorkhv
21st December 2023, 02:07
Which suggestion? Of course I will accept all suggestions!

kedautinh12
21st December 2023, 02:22
Which suggestion? Of course I will accept all suggestions!

Did you read all post?
https://forum.doom9.org/showthread.php?p=1994964#post1994964

doctorkhv
21st December 2023, 03:24
Did you read all post?
https://forum.doom9.org/showthread.php?p=1994964#post1994964

Only now I realized that it was you who wrote your post to me.
Thanks a lot!!!
But now I was asking about something else, about the GENERAL parameters of the script.

VoodooFX
21st December 2023, 22:17
Your tutorial at https://github.com/Purfview/InpaintDelogo/ is difficult for me to understand.

Then post what you don't understand.
I can't comment on your script because it's some random copy/paste with no sense, don't paste there things you don't understand.

Start from the base mask, I guess.

doctorkhv
22nd December 2023, 07:13
VoodooFX Thanks for your reply!

In my understanding your script has:
1. Mask.
I can change the parameters: dimensions, smoothing the inner and outer contours, blurring, adding grain...
2. Interpolation within the frame. The parameters are not clear to me.
3. Interpolation of neighboring frames. The parameters are not clear to me.

Thank you for your creativity!

VoodooFX
22nd December 2023, 09:41
In my understanding your script has:
1. Mask.


Yes there is such parameter as "mask" and other ~120 ones.

VoodooFXI can change the parameters: dimensions, smoothing the inner and outer contours, blurring, adding grain...


There are no such named parameters.

VoodooFX
2. Interpolation within the frame. The parameters are not clear to me.


Which ones?

VoodooFX
3. Interpolation of neighboring frames. The parameters are not clear to me.


There is no such thing in InpaintDelogo.
So, I don't know how non-existing parameters are "not clear".

EDIT:
Conclusion: Something is fundamentally wrong...

EDIT2:
What "tutorial" did you read exactly?

doctorkhv
22nd December 2023, 09:54
I'll keep quiet so as not to irritate you.

kedautinh12
22nd December 2023, 09:59
You need read more about info in InpaintDelogo.avsi

VoodooFX
22nd December 2023, 10:36
I'll keep quiet so as not to irritate you.

Good choice, there is no point in posting the abstract fantasies instead of articulating your issue.

The parameters are not clear to me.


Your issue is not clear to me. State you issue or you are just wasting your time here.

kalehrl
24th December 2023, 18:55
WOW! This is great!
Before:
https://ibb.co/Xt6N7jp
After:
https://ibb.co/jkF0KGj

VoodooFX
26th December 2023, 12:46
WOW! This is great!
Before:
https://ibb.co/Xt6N7jp
After:
https://ibb.co/jkF0KGj

Solid back around logo is easy case. :)

kedautinh12
26th December 2023, 12:53
Yeah, black background very esy to use delogo, i'm scared about ground with dynamic color. @VX, any option for this case?

VoodooFX
26th December 2023, 13:00
Yeah, black background very esy to use delogo, i'm scared about ground with dynamic color. @VX, any option for this case?
Option for what?

kedautinh12
26th December 2023, 13:03
Option for what?

Option to delogo with deblend mode for dynamic color background. Some time logo still show if the background change to other colos

VoodooFX
26th December 2023, 13:16
Option to delogo with deblend mode for dynamic color background. You don't need any option as deblend works by default on that. When on solid background it can safely switch to inpainting.

Some time logo still show if the background change to other colos
That's an issue of the damaged transparency by compression. In such cases don't use "1/3" optimization in "Optimize2".

doctorkhv
29th December 2023, 07:43
Hello,
Can't configure DeLogo parameters.

Video source https://workupload.com/file/6kk55AKyq7H
Image source https://workupload.com/file/tULBdZPZpKk

InpaintDelogo( mask="X:\01a.png", Loc="0,0,0,0", Automask=0, Optimize2=2, Inflate=0, Turbo=-1)

kedautinh12
29th December 2023, 10:51
Why you set loc="0,0,0,0"? Your logo square but your mask circle white?

kedautinh12
29th December 2023, 10:53
First, choose the location of the logo with InpaintLoc
InpaintLoc(Loc="3560,170,-170,-1790")
https://imgur.com/ZHGVx7f

Second, create a mask with Automask=1. Cause your example video is short so I use Analyze=3
InpaintDelogo(mask="C:\Logos\mask1.bmp", Loc="3560,170,-170,-1790", Automask=1, aMix=-9, Analyze=3)
https://imgur.com/sWLBdXX

Finally, use Automask=0 to use mask for Delogo step and add some parameters. With mode=deblend will get a better result almost but when the logo moves to the boy's hat, the logo will appear so I replaced it with inpaint
InpaintDelogo(mask="C:\Logos\mask1.bmp", Loc="3560,170,-170,-1790", Automask=0, aMix=-9, Analyze=3, Mode="Inpaint", Optimize1=1, Optimize2=3, Interp=3, IntSpd=4, dPP=-5)
https://imgsli.com/MjI1MTQ5/0/1

Try with my example

VoodooFX
29th December 2023, 12:40
Hello,
Can't configure DeLogo parameters.


But you are not configuring anything, it's same copy/paste from your previous video.

Try with my example

Your example is weird. :)
You are using "Inpaint" but ~half of the parameters there are for "Deblend"...

kalehrl
29th December 2023, 20:24
Is anyone else having problems running Inpaintdelogo together with QTGMC?
I don't seem to be able to run them in the same script.
This script load fine in MeGUI but then I start encoding, MeGUI crashes:
LoadPlugin("D:\Programs\MeGUI\tools\lsmash\LSMASHSource.dll")
LWLibavVideoSource("D:\Videos\Encodes\File.mkv")
AssumeTFF()
QTGMC(Preset="Fast")
SelectEven()
crop(0, 60, 0, -62)

__film = last
__t0 = __film.trim(4780, 120954)
__t0

InpaintDelogo(mask="D:\mask.bmp", Loc="1480,2,-106,-900", Mode="Inpaint")
When I remove InpaintDelogo line, it starts encoding just fine.
Also, when I remove QTGMC line, encoding works fine.

VoodooFX
29th December 2023, 22:17
Is anyone else having problems running Inpaintdelogo together with QTGMC?
I don't seem to be able to run them in the same script.
This script load fine in MeGUI but then I start encoding, MeGUI crashes.

Never had such problem.

In MeGUI's avs script creator add "version()" and check what it shows. And can you preview your script?

What MeGUI, QTGMC & InpaintDelogo versions?


You can replace:
__film = last
__t0 = __film.trim(4780, 120954)
__t0

with:
trim(4780, 120954)

kedautinh12
30th December 2023, 01:39
I have same problem with latest ver too, i fix it by encode with QTGMC first time and encode with InpaintDelogo second time

VoodooFX
30th December 2023, 01:46
I have same problem with latest ver too, i fix it by encode with QTGMC first time and encode with InpaintDelogo second time

What MeGUI, QTGMC & InpaintDelogo versions?

Share a test sample with script & mask where I can reproduce it.

kedautinh12
30th December 2023, 08:51
With MeGUI-2944-64 (https://onedrive.live.com/?id=54E2524007FBC7DD%211116&cid=54E2524007FBC7DD), QTGMC (https://github.com/realfinder/AVS-Stuff/blob/113f9646c4f0c11406d6057096a6d0fbb630ce21/avs%202.6%20and%20up/QTGMC.avsi), InpaintDelogo (https://github.com/Purfview/InpaintDelogo/blob/5fe65a94d3b783b7d43378a6c14d20159e69f1a1/InpaintDelogo.avsi), Sample (https://drive.google.com/file/d/1xnbHJmDcgEpcBKsCqFFGNTeZmu-lJq7Z/view?usp=drive_link), and scripts:
DGSource("C:\Users\ADMIN\Downloads\Ashita ga Kuru nara - JUJU with JAY'ED PV.dgi")
QTGMC(Preset="Very Slow", Sharpness=0).SelectEven().prefetch(4)
trim(29,0).InpaintDelogo(mask="C:\Logos\Logo_SSTV1440i.bmp", Automask=1, aMix=0, Loc="38,36,-1286,-904")

I always stuck in step make mask

kalehrl
30th December 2023, 13:05
In MeGUI's avs script creator add "version()" and check what it shows. And can you preview your script?
https://i.ibb.co/pdcmB2T/New-File000239.png (https://imgbb.com/)

Yes, I can preview the script both in MeGUI and avspmod.
What MeGUI, QTGMC & InpaintDelogo versions?
The latest 32bit versions of all files.
I've only recently installed avisynth+ and all the plugins.
You can replace:

__film = last
__t0 = __film.trim(4780, 120954)
__t0

with:

trim(4780, 120954)
It didn't make a difference.

Funny enough, if I use preset "Super fast" instead of "Fast" the encoding works fine.

kedautinh12
30th December 2023, 15:35
https://i.ibb.co/pdcmB2T/New-File000239.png (https://imgbb.com/)

Yes, I can preview the script both in MeGUI and avspmod.

The latest 32bit versions of all files.
I've only recently installed avisynth+ and all the plugins.

It didn't make a difference.

Funny enough, if I use preset "Super fast" instead of "Fast" the encoding works fine.

Try latest ver
https://gitlab.com/uvz/AviSynthPlus-Builds

kalehrl
30th December 2023, 19:23
Did it fix your problem with QTGMC and InpaintDelogo?

kalehrl
30th December 2023, 21:14
Try latest ver
https://gitlab.com/uvz/AviSynthPlus-Builds

I tried replacing AviSynth.dll, DevIL.dll in C:\Windows\System32 and DirectShowSource.dll, VDubFilter.dll, TimeStretch.dll, Shibatch.dll, ImageSeq.dll, ConvertStacked.dll in C:\Program Files (x86)\AviSynth+\plugins+ but Version() still shows the old number.

doctorkhv
30th December 2023, 21:37
Video source https://workupload.com/file/6kk55AKyq7H
Image source https://workupload.com/file/tULBdZPZpKk

I changed the settings InpaintDelogo
InpaintDelogo( mask="X:\01a.png", Loc="0,0,0,0", Automask=1, Optimize2=2, Inflate=0, Turbo=-2)

Maybe I should cut the video into fragments?

VoodooFX
30th December 2023, 22:44
With MeGUI-2944-64 (https://onedrive.live.com/?id=54E2524007FBC7DD%211116&cid=54E2524007FBC7DD), QTGMC (https://github.com/realfinder/AVS-Stuff/blob/113f9646c4f0c11406d6057096a6d0fbb630ce21/avs%202.6%20and%20up/QTGMC.avsi), InpaintDelogo (https://github.com/realfinder/AVS-Stuff/blob/113f9646c4f0c11406d6057096a6d0fbb630ce21/avs%202.6%20and%20up/QTGMC.avsi), Sample (https://drive.google.com/file/d/1xnbHJmDcgEpcBKsCqFFGNTeZmu-lJq7Z/view?usp=drive_link), and scripts:
DGSource("C:\Users\ADMIN\Downloads\Ashita ga Kuru nara - JUJU with JAY'ED PV.dgi")
QTGMC(Preset="Very Slow", Sharpness=0).SelectEven().prefetch(4)
trim(29,0).InpaintDelogo(mask="C:\Logos\Logo_SSTV1440i.bmp", Automask=1, aMix=0, Loc="38,36,-1286,-904")

I always stuck in step make mask

The link for InpaindDelogo is wrong.
What means stuck? "Crash" is not same as "stuck".

Don't do stupid things and it wouldn't be "stuck". I imagine that doing triple "Very Slow" QTGMC deinterlace on a single thread is - "stuck". :D
That converts to what?! Roughly to ~12 times slower? What if you would try multiple analyses? That would convert to days instead of an hour...

VoodooFX
30th December 2023, 22:58
Maybe I should cut the video into fragments?

Wrote you that posting fantasies is futile.
Maybe start answering the questions, then we can figure it out your issue.

Copy/pasting the script I gave you few years ago to remove some spots from your video is not some magic wand you can use on everything.

VoodooFX
30th December 2023, 23:06
Yes, I can preview the script both in MeGUI and avspmod.

The latest 32bit versions of all files.
I've only recently installed avisynth+ and all the plugins.

It didn't make a difference.

Funny enough, if I use preset "Super fast" instead of "Fast" the encoding works fine.

Your perception of "the latest" can be way different than mine...

Anyway, check if "AVSMeter.exe yourscript.avs" crash. If it does then post what it shows.

Share a reproducible sample with stuff.

doctorkhv
30th December 2023, 23:34
Wrote you that posting fantasies is futile.
Maybe start answering the questions, then we can figure it out your issue.

Copy/pasting the script I gave you few years ago to remove some spots from your video is not some magic wand you can use on everything.

I agree this is a very difficult video, but on New Year all dreams come true :)

kedautinh12
31st December 2023, 02:25
I tried replacing AviSynth.dll, DevIL.dll in C:\Windows\System32 and DirectShowSource.dll, VDubFilter.dll, TimeStretch.dll, Shibatch.dll, ImageSeq.dll, ConvertStacked.dll in C:\Program Files (x86)\AviSynth+\plugins+ but Version() still shows the old number.

What's your Windows? x64 or x86?

kedautinh12
31st December 2023, 02:27
The link for InpaindDelogo is wrong.
What means stuck? "Crash" is not same as "stuck".

Don't do stupid things and it wouldn't be "stuck". I imagine that doing triple "Very Slow" QTGMC deinterlace on a single thread is - "stuck". :D
That converts to what?! Roughly to ~12 times slower? What if you would try multiple analyses? That would convert to days instead of an hour...

Look at the script, i try with prefetch(4)

VoodooFX
31st December 2023, 02:48
Look at the script, i try with prefetch(4)

Your prefetch doesn't do anything. Look at the manual, and multiple posts explaining why and what:


Int "Analyze":
Not MT compatible...
Clip is parsed ~few times...

kedautinh12
31st December 2023, 04:52
I'm crash too, fixed InpaintDelogo link

kalehrl
31st December 2023, 09:33
What's your Windows? x64 or x86?

Windows 11, 64bit.

kalehrl
31st December 2023, 09:52
Your perception of "the latest" can be way different than mine...

Anyway, check if "AVSMeter.exe yourscript.avs" crash. If it does then post what it shows.

Share a reproducible sample with stuff.

AVSMeter doesn't crash:

https://i.ibb.co/VV5FqzF/Untitled.png (https://ibb.co/8Mty7fy)

Please find the sample files (video sample, mask.bmp and script) here:
https://www.mediafire.com/file/1sgnal1e6fgbf26/Files.zip/file

kedautinh12
31st December 2023, 13:10
AVSMeter doesn't crash:

https://i.ibb.co/VV5FqzF/Untitled.png (https://ibb.co/8Mty7fy)

Please find the sample files (video sample, mask.bmp and script) here:
https://www.mediafire.com/file/1sgnal1e6fgbf26/Files.zip/file

Ok, move x64 .dll to system32 and plugins64+, move x86 .dll to syswow64 and plugins+. I know you confused about systems32 and syswow64, don''t ask me, blame Microsoft

VoodooFX
31st December 2023, 19:40
I'm crash too, fixed InpaintDelogo link

Is it MeGUI crash? What with AvSMeter?
For me your example doesn't crash in MeGUI's avs script preview.
I used LWLibAvVideoSource instead of your DGSource.
Check if kalehri's example crash for you.


Please find the sample files (video sample, mask.bmp and script) here:
https://www.mediafire.com/file/1sgnal1e6fgbf26/Files.zip/file

Your example doesn't crash too when encoding in MeGUI.



My versions:
Avisynth+ 3.7.3 [from the original repo]
MeGUI v2944 x86
LSMASHSource r1156
QTGMC v3.361s
InpaintDelogo v3.8-test2

I think you both have one thing in common - same QTGMC version, so start looking at that.

kalehrl
2nd January 2024, 09:52
I tried QTGMC v3.361s and some other versions but still the same.
I also tried the latest version of LSMASHSource but it didn't help.

VoodooFX
2nd January 2024, 11:01
I tried QTGMC v3.361s and some other versions but still the same.

Can you post output of "AvSMeter.exe -avsinfo"?

real.finder
2nd January 2024, 14:12
I suggest checking the used plugins in qtgmc since qtgmc is just script that use plugins like mvtools and nnedi3

kalehrl
2nd January 2024, 14:18
Can you post output of "AvSMeter.exe -avsinfo"?

Microsoft Windows [Version 10.0.22631.2861]
(c) Microsoft Corporation. All rights reserved.

D:\Programs\AVSMeter3090>AvSMeter.exe -avsinfo

AVSMeter 3.0.9.0 (x86), (c) Groucho2004, 2012-2021

VersionString: AviSynth+ 3.7.3 (r4003, 3.7, i386)
VersionNumber: 2.60
File / Product version: 3.7.3.0 / 3.7.3.0
Interface Version: 10
Multi-threading support: Yes
Avisynth.dll location: C:\Windows\SysWOW64\avisynth.dll
Avisynth.dll time stamp: 2023-07-15, 23:00:38 (UTC)
PluginDir2_5 (HKLM, x86): C:\Program Files (x86)\AviSynth+\plugins
PluginDir+ (HKLM, x86): C:\Program Files (x86)\AviSynth+\plugins+


[C 2.5 Plugins (32 Bit)] [Version, Time stamp]
C:\Program Files (x86)\AviSynth+\plugins+\AvsInPaint.dll [1.3.0.0, 2021-10-25]

[C++ 2.6 Plugins (32 Bit)] [Version, Time stamp]
C:\Program Files (x86)\AviSynth+\plugins+\AddGrainC.dll [1.8.4.0, 2022-02-15]
C:\Program Files (x86)\AviSynth+\plugins+\ClipBlend_x86.dll [1.1.0.0, 2018-11-27]
C:\Program Files (x86)\AviSynth+\plugins+\ConvertStacked.dll [n/a, 2023-07-15]
C:\Program Files (x86)\AviSynth+\plugins+\DePan.dll [2.13.1.6, 2020-05-22]
C:\Program Files (x86)\AviSynth+\plugins+\DePanEstimate.dll [2.10.0.4, 2020-05-22]
C:\Program Files (x86)\AviSynth+\plugins+\dfttest.dll [1.9.7.0, 2021-10-28]
C:\Program Files (x86)\AviSynth+\plugins+\DirectShowSource.dll [n/a, 2023-07-15]
C:\Program Files (x86)\AviSynth+\plugins+\fft3dfilter.dll [2.10.0.0, 2021-10-18]
C:\Program Files (x86)\AviSynth+\plugins+\FrameSel_x86.dll [2.20.0.0, 2018-04-20]
C:\Program Files (x86)\AviSynth+\plugins+\grunt.dll [1.0.2.0, 2020-04-30]
C:\Program Files (x86)\AviSynth+\plugins+\ImageSeq.dll [n/a, 2023-07-15]
C:\Program Files (x86)\AviSynth+\plugins+\LSMASHSource.dll [1161.0.0.0, 2023-12-24]
C:\Program Files (x86)\AviSynth+\plugins+\masktools2.dll [2.2.30.0, 2022-02-19]
C:\Program Files (x86)\AviSynth+\plugins+\mvtools2.dll [2.7.45.0, 2021-06-08]
C:\Program Files (x86)\AviSynth+\plugins+\neo_fft3d.dll [1.0.0.0, 2021-08-17]
C:\Program Files (x86)\AviSynth+\plugins+\nnedi3.dll [0.9.4.63, 2023-11-19]
C:\Program Files (x86)\AviSynth+\plugins+\RgTools.dll [1.2.0.0, 2021-05-26]
C:\Program Files (x86)\AviSynth+\plugins+\RT_Stats_x86.dll [2.0.12.0, 2018-11-25]
C:\Program Files (x86)\AviSynth+\plugins+\Shibatch.dll [n/a, 2023-07-15]
C:\Program Files (x86)\AviSynth+\plugins+\tcolormask.dll [1.2.2.0, 2022-06-11]
C:\Program Files (x86)\AviSynth+\plugins+\TDeint.dll [1.9.0.0, 2023-12-10]
C:\Program Files (x86)\AviSynth+\plugins+\TimeStretch.dll [n/a, 2023-07-15]
C:\Program Files (x86)\AviSynth+\plugins+\TIVTC.dll [1.0.28.0, 2023-12-10]
C:\Program Files (x86)\AviSynth+\plugins+\VDubFilter.dll [n/a, 2023-07-15]
C:\Program Files (x86)\AviSynth+\plugins+\vsTEdgeMask.dll [1.0.1.0, 2022-05-26]

[Scripts (AVSI)] [Time stamp]
C:\Program Files (x86)\AviSynth+\plugins+\colors_rgb.avsi [2022-10-06]
C:\Program Files (x86)\AviSynth+\plugins+\GrainFactory3.avsi [2023-12-29]
C:\Program Files (x86)\AviSynth+\plugins+\InpaintDelogo.avsi [2023-12-29]
C:\Program Files (x86)\AviSynth+\plugins+\QTGMC.avsi [2023-12-29]
C:\Program Files (x86)\AviSynth+\plugins+\Zs_RF_Shared.avsi [2023-12-29]

[Uncategorized files] [Time stamp]
C:\Program Files (x86)\AviSynth+\plugins+\colors_rgb.txt [2022-10-06]



[Plugin errors/warnings]
________________________________________________________________________________

Function duplicates:

"undefined" : "[InternalFunction]"
"Undefined" : "C:\Program Files (x86)\AviSynth+\plugins+\Zs_RF_Shared.avsi"

________________________________________________________________________________

D:\Programs\AVSMeter3090>

VoodooFX
2nd January 2024, 20:55
I updated all stuff, no crash, tested with "medium" preset too.
Here is my plugins folder reduced to bare minimum to run your script -> EDIT: DELETED


Btw, did you updated "AvisynthWrapper.dll" for MeGUI? But I think it shouldn't work at all for you without this update.

kalehrl
2nd January 2024, 21:10
Thanks. I'll try with your plugins.
I'm using developer server in MeGUI so I think I should have all files updated.

VoodooFX
2nd January 2024, 21:14
I'm using developer server in MeGUI so I think I should have all files updated.

MeGUI is abandonware, you can't have that update through the MeGUI's updates.

There it's -> https://drive.google.com/open?id=1JfiokTy2IOqOn1VTXN0eXQEDCC3vUdN4

kalehrl
2nd January 2024, 21:28
BINGO! That AvisynthWrapper.dll fixed the problem. I didn't replace any other plugins. Many thanks.

VoodooFX
2nd January 2024, 22:27
BINGO! That AvisynthWrapper.dll fixed the problem. I didn't replace any other plugins. Many thanks.

My first thought was that it's AvisynthWrapper issue, but I thought that InpaintDelogo alone should crash too.

Just tested the outdated AvisynthWrapper, strangely QTGMC and InpaintDelogo works when separate but not together. Dunno why, @pinterf should know.


@kedautinh12 check if you have proper AvisynthWrapper.
Or actually your issue is "stuck" instead of "crash"? :sly:

VoodooFX
3rd January 2024, 10:06
@kalehrl
Btw, there are bugs with MeGUI's avs preview. Use AvsPmod!

kalehrl
3rd January 2024, 21:13
I'm learning to use StaxRip but it's more difficult than MeGUI but I guess I'll have to now that MeGUI is basically abandoned.

charles-roberts
19th January 2024, 08:10
I have no use for InpaintDelogo ATM, but interested in learning about it.

Saved the manual to read over coming months:
https://raw.githubusercontent.com/Purfview/InpaintDelogo/18341ca8a1250ad7b4f5ab1e4298802ecf2060db/InpaintDelogo.avsi

What GUI could I use to select an opaque logo and display "Loc" values?

Is there a way to input "tilted square" or "diamond shape" "Loc" values?

-----------------------------------------


A final long question: What is val "mask"?

Thought Inpainting was tracking image around "lets say an opaque fixed position Logo" to reconstruct theoretical image behind Logo.

So I am confused what the mask is for and what "val" relates to?

Quote: Resolution of the image must be same as video clip's frame.
So if the video was 1920x1080 the mask is 1920x1080 and white?
---------

Clip based mask:
"mask" accepts clip input, resolution must be same as "Loc" area.
Dynamic mask expected to be full range Y8 or will be converted.
Static mask must be one frame clip otherwise it will be treated as a dynamic mask.

Is the "Clip based mask" a totally different type of mask?
Quote: resolution must be same as "Loc" area.
Are we talking of a single frame video clip the size of Logo?
If so, can it be mp4?

I am very confused what this mask stuff is about.
For example, the val "mask" seems to refer to video resolution, say 1920x1080.
The Clip based mask seems to refer to the Logo size, which might be 20x20.

Is there a simple explanation to help me understand "val", "clip input" and how the two different Masks are used?

kalehrl
19th January 2024, 09:24
What GUI could I use to select an opaque logo and display "Loc" values?
I don't think there is a GUI. Not even avspmod has sliders to adjust Loc values.
Is there a way to input "tilted square" or "diamond shape" "Loc" values?
I don't think so but the resulting mask will be in the shape of the logo whatever shape it is.
A final long question: What is val "mask"?
It is basically an image which will be placed over the logo to try to remove it.
Basically, these are the simplest steps to take:
1. Define Loc values like this for example:
InpaintLoc(Loc="1036,40,-44,-510")
https://i.ibb.co/4JQNwBz/New-File-7-014545.png (https://ibb.co/4JQNwBz)
2. Create automask:
InpaintDelogo(mask="D:\Videos\Encodes\smurfs.bmp", Automask=1, Loc="1036,40,-44,-510", Mode="Inpaint")
This is the resulting mask:
https://i.ibb.co/34jz6hf/smurfs.png (https://ibb.co/34jz6hf)
3. Encode using the final command:
InpaintDelogo(mask="D:\Videos\Encodes\smurfs.bmp", Loc="1036,40,-44,-510", Mode="Inpaint")
https://i.ibb.co/M8zPvQt/14514014545.png (https://ibb.co/M8zPvQt)

charles-roberts
19th January 2024, 10:05
I don't think there is a GUI. Not even avspmod has sliders to adjust Loc values.

I was just thinking about a way of seeing the video frame and coordinate values around the Logo!

I have been looking at "Shotcut" program.
Shotcut provides a video zoom scope to aid in inspecting images.

Still looking at the details.
What do you think?
https://forum.shotcut.org/t/video-zoom-scope/15654
https://forum.shotcut.org/t/video-scopes/19996
-------

Regarding selection around other shapes?
I read what you said about: "but the resulting mask will be in the shape of the logo whatever shape it is."

But I would still like to know, can you select more then one area?
Like a video with two Logos in separate fixed locations!
Or a single complex shaped Logo in fixed location, that is then divided into multiple "Loc" value sets for processing!

VoodooFX
19th January 2024, 13:43
What GUI could I use to select an opaque logo and display "Loc" values?

AvsPmod (https://forum.doom9.org/showthread.php?t=175823).

Is there a way to input "tilted square" or "diamond shape" "Loc" values?


There is no point in doing any of this. Probably you are thinking about "mask".

A final long question: What is val "mask"?



https://github.com/Purfview/InpaintDelogo/blob/13e27f3deb83ef4415543351d362111015959e82/InpaintDelogo.avsi#L261

what "val" relates to?


http://avisynth.nl/index.php/Script_variables

Because "mask" here accepts the strings and the clips.

I am very confused what this mask stuff is about.


https://www.youtube.com/watch?v=OtVR9_Ua-C8

I have been looking at "Shotcut" program...

Ask at "Shotcut" forums.

But I would still like to know, can you select more then one area?

You can select only a one area with "Loc".


Like a video with two Logos in separate fixed locations!

You can run another instance for second logo, or you can select whole frame if you want.

color
26th January 2024, 10:33
How do I do so it pull into from the left and right instead of all size?

VoodooFX
26th January 2024, 16:37
How do I do so it pull into from the left and right instead of all size?

I can't understand what you are asking.
Share your full avs script with masks and a video sample!

color
26th January 2024, 20:38
I can't understand what you are asking.
Share your full avs script with masks and a video sample!

I can not share cause I don't know.

I want the it to pull the image => and <= not all sides. I think it was called "Pixel Aspect" in DeLogo.

VoodooFX
26th January 2024, 22:21
I can not share cause I don't know.

I want the it to pull the image => and <= not all sides.

Still, I've no idea what "pull the image" or "=> and <= " means.
Share what you know.


I think it was called "Pixel Aspect" in DeLogo.

There was something named like that, an useless arg doing practically nothing.

color
27th January 2024, 08:53
Still, I've no idea what "pull the image" or "=> and <= " means.
Share what you know.




There was something named like that, an useless arg doing practically nothing.


I don't know how to make it clearer, sorry....I do not want this when inpaint.

https://i.ibb.co/YPMjmyN/img-01.png

I want this:

https://i.ibb.co/p13rRT7/img-02.png

I am editing a text in a movie and it has lines, so when using it and putting on a new text (another font that is not 100% same) does not good wwhen its like the first image, but much better if it can pull from left and right instead of all sides.

I wrote the same as my post and let chatGTP do explain it more clearly.

"I have a video with a logo that I want to remove using a delogo tool. The issue is that the current tool I'm using removes content uniformly from all sides, which doesn't look natural in my video. I'm looking for a delogo tool that can intelligently pull or stretch the background from the left and right sides, creating a more seamless and natural appearance."

For example, thats why I want to know how to make it pull from left and right instead of all sides, cause it does not look correct.

lets say this is original:
https://i.ibb.co/M8HckTY/Untitled-1.png

and lets say this is the text I want to add to it after "delogo"
https://i.ibb.co/F62fNSm/img-03.png

but I need to pull from left to right instead of all sides, so it could look like this:
https://i.ibb.co/tYXdr0C/img-01.png

I need it to work with the mask to be even clearer, so I can not just put a square and pull together, then I will loose alot of image.

VoodooFX
27th January 2024, 09:27
Try Turbo=-1 or Turbo=-2 presets.
And if you want to block something from bottom and top then "crop" with Loc the video at those places.

Guilbert
11th February 2024, 18:43
Hi,

I'm having trouble OCRing the part of the sample I sent you, VoodooFX.
Can you please take a look?

Here is my parameters:
Loc="300,840,-300,-60", Show=4, DynMask=4, DynMask4H=150, DynTune=180, DynMaskUp=2, SubMinDur=4, FourCC="X264"

VoodooFX
11th February 2024, 19:09
Here is my parameters

Your parameters doesn't work or the sample is wrong. Post the working ones.

Guilbert
11th February 2024, 20:11
Okay, it's because I used LanczosResize(1920, 1080).

Here is the parameters:
Loc="300,560,-300,-40", Show=4, DynMask=4, DynMask4H=150, DynTune=180, DynMaskUp=2, SubMinDur=4, FourCC="X264"

(I sent you another sample.)

Thanks.

VoodooFX
11th February 2024, 22:29
You won't get rid completely of the titles behind the subtitles.
Try this:


InpaintDelogo(Loc="300,570,-300,-50", Show=4, DynLocUp=2, DynMask=3, Dyn3Seq=20, DynTune=160, DynTEdge=1, DynTEdgeThY=50, DynTEdgeInf=4, KillNoise=5, KillBlobs=-5, Extract=-1, CorrTh=0.7, ImgDir="D:\img")

Guilbert
11th February 2024, 23:51
Strangely, no images were extracted (on the whole movie).

https://i.ibb.co/pjHTRHM/Capture-d-cran-2024-02-11-234232.png

VoodooFX
11th February 2024, 23:56
It extracted all subtitles from your sample.

Guilbert
12th February 2024, 00:09
Indeed. Thank you, it helped a lot!

HeinrichI
14th March 2024, 11:27
Hello. Can you give me some advice? Launched analysis by command:
InpaintDelogo( mask="Unfabulous\Unfabulous.bmp", Automask=1, Loc="450,0,150,174")
4 files were created:
https://i.ibb.co/yXZ8x0c/Files.png
But when I run the preview after, with the command
InpaintDelogo( mask="Unfabulous\Unfabulous.bmp", Loc="450,0,150,174", Mode="Deblend") then instead of removing the logo, colored spots appeared:
https://i.ibb.co/pyTB92k/2024-03-14-132153.png
The logo itself:
https://i.ibb.co/KNfb4Fw/2024-03-14-132627.png

kedautinh12
14th March 2024, 13:27
You need show your mask image

HeinrichI
14th March 2024, 13:46
You need show your mask image
Unfabulous.bmp:https://i.ibb.co/kK0CFvd/Unfabulous.png
Unfabulous_AutomaskTemp_A2.bmp:https://i.ibb.co/t87G3V6/Unfabulous-Automask-Temp-A2.png

VoodooFX
14th March 2024, 14:07
Launched analysis by command:
InpaintDelogo( mask="Unfabulous\Unfabulous.bmp", Automask=1, Loc="450,0,150,174")
4 files were created:

ebmp file is not created by Automask=1.

But when I run the preview after, with the command
InpaintDelogo( mask="Unfabulous\Unfabulous.bmp", Loc="450,0,150,174", Mode="Deblend") then instead of removing the logo, colored spots appeared:

Because logo is not transparent, so there is nothing to deblend.

kalehrl
14th March 2024, 14:52
Any advice how to create a mask for this kind logo:

https://i.ibb.co/MZjYxSp/Untitled.png (https://imgbb.com/)

It is faint and the resulting automask is no good because I just get a jumbled mask like this:

https://i.ibb.co/tMNDDLZ/output3-Automask-Temp-A2.png (https://imgbb.com/)

I used this command:
InpaintDelogo(mask="D:\Videos\Encodes\output3.bmp", Automask=1, Analyzeth=70, Loc="1800,908,-36,-0", Mode="Inpaint")

HeinrichI
14th March 2024, 14:57
ebmp file is not created by Automask=1.

How to create ebmp? I still don’t understand it from the description in the script.
Because logo is not transparent

The logo is still slightly transparent, as you can see in this shot.
https://i.ibb.co/VCccTW1/102-Unfabulous-The-Secret-avi-20240314-165255-211-2.png

VoodooFX
14th March 2024, 15:18
How to create ebmp? I still don’t understand it from the description in the script.

It's created automatically by analysis on the first deblend delogo run.

The logo is still slightly transparent, as you can see in this shot.

Probably not transparent enough for video compression level. Or maybe you are doing something wrong.

VoodooFX
14th March 2024, 15:23
Any advice how to create a mask for this kind logo:

https://i.ibb.co/MZjYxSp/Untitled.png (https://imgbb.com/)

I've no idea what "this kind" means.
This image looks like any other random image.

kalehrl
14th March 2024, 16:05
I don't known how to describe it. It's very transparent and faint. The whole video file is pretty dark and automask fails to create a proper mask using the default values. Are there any advanced options which may help?

VoodooFX
14th March 2024, 16:10
Can you share the video?

kalehrl
14th March 2024, 19:44
It's 47 minutes long. How much video do you need? I need to cut it because my upload speed is slow.
EDIT: Link removed.
I hope it's enough.

VoodooFX
14th March 2024, 20:21
Use Analyze=1 or Analyze=2 with NoBorderAt="bottom".

Then for high transparency logos you want to use higher aMix when getting basemask.

kalehrl
14th March 2024, 20:59
Thank you. Those extra options did the trick.
One more question. You noticed that the video has 2 logos.
How can I create 2 masks with automask?

kedautinh12
14th March 2024, 21:22
Thank you. Those extra options did the trick.
One more question. You noticed that the video has 2 logos.
How can I create 2 masks with automask?

Make a mask first, do the second later

kalehrl
14th March 2024, 22:11
I did it that way but then I end up with 2 masks which significantly slow down the encoding.
I think having 1 mask with 2 logos will result in faster encoding.

HeinrichI
14th March 2024, 22:29
On another episode of the series, where I'm trying to remove the logo, the transparency is better, and the removal works, but at times there is colored noise, how can I reduce it?
https://i.ibb.co/NyxxtPd/2024-03-15-002328.png
https://i.ibb.co/4dyj4Vw/2024-03-15-002830.png

VoodooFX
14th March 2024, 22:44
On another episode of the series, where I'm trying to remove the logo, the transparency is better, and the removal works, but at times there is colored noise, how can I reduce it?

Try these:
Inflate=2, Optimize2=2, dPP=-5

Btw, if resolution is same then you can use these masks on that previous episode too.

VoodooFX
14th March 2024, 22:46
I think having 1 mask with 2 logos will result in faster encoding.

No, it wouldn't.

VoodooFX
15th March 2024, 04:47
Unfabulous_AutomaskTemp_A2.bmp:https://i.ibb.co/t87G3V6/Unfabulous-Automask-Temp-A2.png

You didn't left enough space at the right side, and other sides have too large borders. This can have negative impact on generation of ebmp masks.

Remove 30 pixels at left.
Add 6 pixels at right.
Remove 16 pixels at top.
Remove 40 pixels at bottom.

Floatingshed
8th April 2024, 15:45
I am getting an error message repeatedly, I don't understand.
"Source clip must have at least two frames for alpha computation"
Clip is over 18000 frames...

VoodooFX
8th April 2024, 21:58
I am getting an error message repeatedly, I don't understand.
"Source clip must have at least two frames for alpha computation"
Clip is over 18000 frames...

Share your full avs script and mask. And cut video sample if possible.

Floatingshed
9th April 2024, 14:37
Thanks for the offer of help.
Script, mask and video clip here:
https://wetransfer.com/downloads/bbd19d832769a6d3353b944c10e4afc220240409133239/eb7ce3760c7f831b0d7c00f53b234f6820240409133239/19bad1?trk=TRN_TDL_01&utm_campaign=TRN_TDL_01&utm_medium=email&utm_source=sendgrid

VoodooFX
9th April 2024, 18:27
Thanks for the offer of help.
Script, mask and video clip here:

You didn't left at least 10 pixels around logo in Loc.
The basemask is not good.
Video quality is crap - you'll have crap deblend result.

TrickyTrix
2nd August 2024, 12:56
InpaintDelogo is a fantastic tool for removing logos, but I failed to create masks for some videos below and I don't know why
https://mega.nz/folder/AsUWGaZJ#NzqG_wzzmw_BYZvd2KgPJg
I used InpaintDelogo(automask=1, mask="C:\xy\logomask.bmp", Loc="376,16,-26,-318")
but all I get is black rectangle for e10, e12, e13, e14, e15 and e16.
But interestingly enough, for e11 I get a perfect mask and I don't see any visual difference between e11 and those other e1x videos.
What could be the problem and is there a way to fix it?

VoodooFX
4th August 2024, 00:20
but I failed to create masks for some videos below and I don't know why


Short clips don't have enough suitable frames to build a good mask, as all those clips have exact same logo you should joint all them in script and then build the masks.

TrickyTrix
4th August 2024, 10:54
They are 7 minute cartoons with semi transparent Boomerang logo from 1st till the last frame, it doesn't make any sense for InpaintDelogo not to create the mask.
I tried the good mask I got on other cartoons, but since it is a logo from a TV, logo is not always in the same exact position pixel wise, so the final results are very bad.

VoodooFX
5th August 2024, 02:00
Oh I see, logo in e11 video looks like normal "blend":

https://i.imgur.com/UFmEo32.png

When logos in the other videos looks like "add blend" or whatever:

https://i.imgur.com/HyeC9Lw.png

TrickyTrix
5th August 2024, 08:53
But logo is still static and located in the same place. So, I still don't understand why InpaintDelogo won't produce a mask for it.

Floatingshed
14th August 2024, 14:22
How do we deal with a logo that fades in after the start of the programme?
If InpaintDelogo is active on pictures without logo it creates a logo.
Which 'appears' to fade out as the logo actually fades in...

VoodooFX
14th August 2024, 20:24
But logo is still static and located in the same place. So, I still don't understand why InpaintDelogo won't produce a mask for it.

It won't because InpaintDelogo is for normal logo blends, not for any other blend effects (https://en.m.wikipedia.org/wiki/Blend_modes).
Later I'll show you how to remove "add" blend logo.


How do we deal with a logo that fades in after the start of the programme?

Use inpaint mode on those fadein/out frames. Btw, and don't analyze such frames with animations.

VoodooFX
14th August 2024, 22:32
@TrickyTrix Here is how manually deblend those "add blend" logos:



# Video with "add" blend. (Not the normal blend!)
o=LWLibAvVideoSource("D:\e10.avi")

# Here we find frame with logo in solid background
m=o.trim(11267,-1).ConvertToY8

# Measure background brightness value and subtract it from the frame so background is ~0 to get the "add" mask:
addmask=m.Tweak(bright=-18, coring=false)

# Here we get the black and white basemask for PP (postprocess):
basemask=m.mt_binarize(25).crop(376,16,-26,-318)

# Here we subtract addmask from video as it's opposite of "add":
o.Overlay(addmask, x=0, y=0, mode="subtract", opacity=1)

# Hack to PP the logo remnants with InpaintDelogo
# YAlphaTweak=-255, UVAlphaFromY=1 to ensure that InpainDelogo's deblend process has no effect on the video
InpaintDelogo(mask=basemask, Loc="376,16,-26,-318", mode="deblend", YAlphaTweak=-255, UVAlphaFromY=1)


Original, Subtracted, PP:

https://i.imgur.com/esz1cxc.png https://i.imgur.com/7iPJoda.png https://i.imgur.com/iTHA57F.png

EDIT:
For the script to work get 3.8-test3 version from the test branch -> https://github.com/Purfview/InpaintDelogo/tree/test

TrickyTrix
15th August 2024, 12:36
@TrickyTrix Here is how manually deblend those "add blend" logos:



# Video with "add" blend. (Not the normal blend!)
o=LWLibAvVideoSource("D:\e10.avi")

# Here we find frame with logo in solid background
m=o.trim(11267,-1).ConvertToY8

# Measure background brightness value and subtract it from the frame so background is ~0 to get the "add" mask:
addmask=m.Tweak(bright=-18, coring=false)

# Here we get the black and white basemask for PP (postprocess):
basemask=m.mt_binarize(25).crop(376,16,-26,-318)

# Here we subtract addmask from video as it's opposite of "add":
o.Overlay(addmask, x=0, y=0, mode="subtract", opacity=1)

# Hack to PP the logo remnants with InpaintDelogo
# YAlphaTweak=-255, UVAlphaFromY=1 to ensure that InpainDelogo's deblend process has no effect on the video
InpaintDelogo(mask=basemask, Loc="376,16,-26,-318", mode="deblend", YAlphaTweak=-255, UVAlphaFromY=1)


Original, Subtracted, PP:

https://i.imgur.com/esz1cxc.png https://i.imgur.com/7iPJoda.png https://i.imgur.com/iTHA57F.png

EDIT:
For the script to work get 3.8-test3 version from the test branch -> https://github.com/Purfview/InpaintDelogo/tree/test

Thank you for pointing out different blending effects and showing me how to do this new deblending in new InpaintDelogo plugin.
Please tell me how would I measure background brightness value (I used your value for all these videos)?

Since it's a test branch it might be of use to report that on e12 you can see a gray Boomerang logo on frames around 680 and 1222, but it might be a completely normal artefact from this type of deblending, I wouldn't know.

VoodooFX
15th August 2024, 18:29
...showing me how to do this new deblending in new InpaintDelogo plugin.
InpaintDelogo doesn't do any deblending in that script... The line with "Overlay" does actual delogo.


Please tell me how would I measure background brightness value (I used your value for all these videos)?

AvsPmod (https://forum.doom9.org/showthread.php?t=175823) shows values of pixel at the bottom of the preview screen, you need the first value of "yuv".


Since it's a test branch it might be of use to report that on e12 you can see a gray Boomerang logo on frames around 680 and 1222, but it might be a completely normal artefact from this type of deblending, I wouldn't know.

It's normal artifact for such low quality videos as these.
You can use stronger postprocess settings -> "dPP=-5" & "Optimize2=2", best would be to use them only on the frames with those stronger artifacts.
Here is how to apply the different settings on the different parts of the video:


o=LWLibAvVideoSource("D:\e12.avi")

m=o.trim(10979,-1).ConvertToY8
addmask=m.Tweak(bright=-20,coring=false)
basemask=m.mt_binarize(27).crop(376,16,-26,-318)

d=o.Overlay(addmask, x=0, y=0, mode="subtract", opacity=1)

a1=d.Trim(0, 645).InpaintDelogo(mask=basemask, Loc="376,16,-26,-318", mode="deblend", YAlphaTweak=-255, UVAlphaFromY=1)
a2=d.Trim(646, 1353).InpaintDelogo(mask=basemask, Loc="376,16,-26,-318", mode="deblend", YAlphaTweak=-255, UVAlphaFromY=1, dPP=-5, Optimize2=2)
a3=d.Trim(1354, 0).InpaintDelogo(mask=basemask, Loc="376,16,-26,-318", mode="deblend", YAlphaTweak=-255, UVAlphaFromY=1)

a1++a2++a3

Enthusiast
21st August 2024, 10:09
First of all, I would like to express my gratitude for this delightful instrument. And secondly, I would like to ask for help.

I have a video with an animated black logo in the center. In some parts of the video, it is clearly visible, in some, it is not. If it were stable I could just make a mask and inpaint it. But it is moving and black as some parts of the frame. Could I somehow delete it from the video?

https://i.postimg.cc/cHgnLz0w/test-video-mp4-00-00-01-2024-08-14-12h15m53s770.jpg
https://i.postimg.cc/76FTGNZc/test-video-mp4-00-00-02-2024-08-14-12h16m28s996.jpg


Here is the sample https://file.io/pBiZAcI8d5vf

VoodooFX
21st August 2024, 13:23
But it is moving and black as some parts of the frame.

And I don't see a pattern in logo movements. Avisynth doesn't have object tracking tool...

Try Premiere or some AI tool.

Enthusiast
23rd August 2024, 08:42
And I don't see a pattern in logo movements. Avisynth doesn't have object tracking tool...

Try Premiere or some AI tool.

Is it possible to use an animated mask with Inpaint Delogo?

VoodooFX
23rd August 2024, 09:59
Is it possible to use an animated mask with Inpaint Delogo?


Yes, for example if mask has same dimensions as video:

m=LWLibAvVideoSource("D:\mask.mkv")
InpaintDelogo(mask=m, Loc="0,0,-0,-0")

Enthusiast
24th August 2024, 09:57
Yes, for example if mask has same dimensions as video:

m=LWLibAvVideoSource("D:\mask.mkv")
InpaintDelogo(mask=m, Loc="0,0,-0,-0")

Amazing, I thought it only understands BMP files!

kalehrl
25th August 2024, 10:08
Yes, for example if mask has same dimensions as video:

m=LWLibAvVideoSource("D:\mask.mkv")
InpaintDelogo(mask=m, Loc="0,0,-0,-0")

Is there an option to automatically create video like automask?

VoodooFX
25th August 2024, 19:53
Is there an option to automatically create video like automask?

Read the manual about DynMask.

Floatingshed
10th September 2024, 18:52
Read the manual about DynMask.

Are there any dynamic logo removal examples?

VoodooFX
11th September 2024, 01:13
Are there any dynamic logo removal examples?

For example: https://forum.doom9.org/showthread.php?p=1980298#post1980298

Search the thread.

Floatingshed
12th September 2024, 15:09
For example: https://forum.doom9.org/showthread.php?p=1980298#post1980298

Search the thread.

Yes, I did that before asking. I'm afraid I didn't find it very enlightening, it assumes a lot.
I am trying to remove, or at least mitigate, a very intrusive burned-in timecode. Can you please give me some easy to follow pointers?

Thanks.

VoodooFX
12th September 2024, 19:01
Yes, I did that before asking. I'm afraid I didn't find it very enlightening, it assumes a lot.
I am trying to remove, or at least mitigate, a very intrusive burned-in timecode. Can you please give me some easy to follow pointers?

There are 5 dynamic mask examples in that post, what's more to give?

Can you share a sample of your video?

dot75
1st October 2024, 17:27
Hello, can you help me? I would like to erase this logo. I can't make it transparent, the red is still visible.


https://i.postimg.cc/bSspcvM7/00624.png (https://postimg.cc/bSspcvM7)

https://i.postimg.cc/d0dT10gL/mask.png (https://postimages.org/)


InpaintDelogo( mask="C:\temp\Test\SubP2\eva4\eva5\mask.bmp",
\ Automask=0, aMix=-30,Loc="482,652,-0,-30",
\ Mode="inpaint",
\ Analyze=-3, FrW=642, FrS=0,dPP=0,Show=0, Inflate=0)

VoodooFX
1st October 2024, 21:26
InpaintDelogo( mask="C:\temp\Test\SubP2\eva4\eva5\mask.bmp",
\ Automask=0, aMix=-30,Loc="482,652,-0,-30",
\ Mode="inpaint",
\ Analyze=-3, FrW=642, FrS=0,dPP=0,Show=0, Inflate=0)

The mask doesn't look right.
Can you explain what dPP is doing there?
Btw, logo doesn't even fit into Loc.

Share the video.

dot75
1st October 2024, 21:39
The mask doesn't look right.
Can you explain what dPP is doing there?
Btw, logo doesn't even fit into Loc.

Share the video.

https://www.swisstransfer.com/d/1043a6d8-e81a-4080-9d45-1d53e635764d