Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 9th December 2019, 19:39   #61  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
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.

Quote:
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
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 9th December 2019, 19:48   #62  |  Link
VoodooFX
Banana User
 
VoodooFX's Avatar
 
Join Date: Sep 2008
Posts: 985
By default InpaintDelogo doesn't do any analysis too, only if you want to get the mask automatically or deblend the logo.
VoodooFX is offline   Reply With Quote
Old 27th December 2019, 00:48   #63  |  Link
TCmullet
Registered User
 
Join Date: Nov 2003
Posts: 365
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.
TCmullet is offline   Reply With Quote
Old 27th December 2019, 11:16   #64  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
@ 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.

Code:
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].
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 27th December 2019 at 11:48.
StainlessS is offline   Reply With Quote
Old 28th December 2019, 00:51   #65  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
Quote:
Originally Posted by TCmullet View Post
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.

Last edited by manono; 28th December 2019 at 00:54.
manono is offline   Reply With Quote
Old 28th December 2019, 08:11   #66  |  Link
VoodooFX
Banana User
 
VoodooFX's Avatar
 
Join Date: Sep 2008
Posts: 985
December is very busy... I don't have much time StainlessS.

Quote:
Originally Posted by TCmullet View Post
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:

Quote:
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".
VoodooFX is offline   Reply With Quote
Old 29th December 2019, 00:01   #67  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,078
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...

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:
Quote:
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:
Quote:
Loc="22,12,-588,-328"
InpaintDelogo(automask=1, analyze=4, fr1=10329, mask="d:\logomask.bmp", Loc=Loc)
Or like this:
Quote:
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:
Quote:
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

Last edited by manolito; 29th December 2019 at 01:25.
manolito is offline   Reply With Quote
Old 29th December 2019, 00:41   #68  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
Quote:
Originally Posted by manolito View Post
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.

Quote:
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.

Last edited by manono; 29th December 2019 at 00:49.
manono is offline   Reply With Quote
Old 29th December 2019, 01:19   #69  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,078
Quote:
Originally Posted by manono View Post
Any photo editor can do the job. I use the freeware PhotoFiltre.
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...

Happy New Year
manolito
manolito is offline   Reply With Quote
Old 29th December 2019, 03:02   #70  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
Quote:
Originally Posted by manolito View Post
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.
manono is offline   Reply With Quote
Old 29th December 2019, 10:22   #71  |  Link
RieGo
Registered User
 
Join Date: Nov 2009
Posts: 59
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

Code:
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
RieGo is offline   Reply With Quote
Old 29th December 2019, 14:05   #72  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,078
Quote:
Originally Posted by RieGo View Post
-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.p...66#post1893966
It will convert your input to the required format for InpaintDelogo.


Quote:
-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...
From the manual:
Quote:
# 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
manolito is offline   Reply With Quote
Old 30th December 2019, 11:26   #73  |  Link
RieGo
Registered User
 
Join Date: Nov 2009
Posts: 59
Quote:
Originally Posted by manolito View Post
Have a look at this script by StainlessS:
https://forum.doom9.org/showthread.p...66#post1893966
It will convert your input to the required format for InpaintDelogo.
Thanks! i missed that one
RieGo is offline   Reply With Quote
Old 13th May 2020, 16:04   #74  |  Link
JohnDoe
Registered User
 
Join Date: Aug 2015
Posts: 15
Moving Watermarks

Maybe anyone have a idea for this Problem:

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

Thanks!

Last edited by JohnDoe; 13th May 2020 at 16:10.
JohnDoe is offline   Reply With Quote
Old 31st August 2020, 00:37   #75  |  Link
JohnDoe
Registered User
 
Join Date: Aug 2015
Posts: 15
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.
Attached Files
File Type: txt test.avs.txt (7.6 KB, 177 views)
JohnDoe is offline   Reply With Quote
Old 31st August 2020, 14:13   #76  |  Link
VoodooFX
Banana User
 
VoodooFX's Avatar
 
Join Date: Sep 2008
Posts: 985
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.
VoodooFX is offline   Reply With Quote
Old 31st August 2020, 21:07   #77  |  Link
JohnDoe
Registered User
 
Join Date: Aug 2015
Posts: 15
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
JohnDoe is offline   Reply With Quote
Old 2nd September 2020, 00:16   #78  |  Link
VoodooFX
Banana User
 
VoodooFX's Avatar
 
Join Date: Sep 2008
Posts: 985
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..
VoodooFX is offline   Reply With Quote
Old 21st October 2020, 15:30   #79  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
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
__________________
See My Avisynth Stuff
real.finder is offline   Reply With Quote
Old 21st October 2020, 17:48   #80  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Not sure but I think that ExInpaint is less temporally stable than AvsInpaint, better for still image but not video.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Reply

Tags
delogo, hardsubs, ocr, remove, watermark

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 19:47.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.