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 3rd June 2014, 20:08   #1  |  Link
Floatingshed
Registered User
 
Join Date: Nov 2008
Posts: 324
Film dirt removal script

I use the following script (stolen from here years ago!)to very effectively remove film dirt and it has served me well. However, I have several clips consisting of hybrid 50i video and 25p film and I'd like to apply the filter on just the film sections.

I need help to either make the script work with multiple calls or somehow ignore the 50i sections, but this worries me as often you find the film sections are out of phase and "look" interlaced as the film frame changes between fields.

Any help much appreciated. Thanks.

Code:
function Dirt(clip clap,int "limit")
{
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\mvtools v1.11.4.5\mvtools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\Mask tools v2.0.36.0\mt_masktools-26.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\Mask tools v1.5.1.0\MaskTools.dll")


_grey=false
limit = default(limit,60)


bvec = clap.MVAnalyse(isb=false, blksize=8, delta=1, pel=2, truemotion=true, idx=4)
fvec = clap.MVAnalyse(isb=true, blksize=8, delta=1, pel=2, truemotion=true, idx=4)
backw = clap.MVFlow(bvec)
forw  = clap.MVFlow(fvec)
clt = interleave(backw,clap,forw)
clt = clt.RemoveDirt(limit)

return clt.SelectEvery(3,1)

}


function RemoveDirt(clip input, int limit)
{
  clensed=input.Clense(grey=false, cache=4)
  alt=input.RemoveGrain(2)
  return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=4,cthreshold=6, gmthreshold=40,dist=1,dmode=2,debug=false,noise=limit,noisy=12,grey=false)
}
Floatingshed is offline   Reply With Quote
Old 3rd June 2014, 23:20   #2  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
Quote:
Originally Posted by Floatingshed View Post
...but this worries me as often you find the film sections are out of phase and "look" interlaced as the film frame changes between fields.
You could use TFM on the whole thing first, before the dirt removal. Set PP=0 so the real interlaced sections don't get post-processed.

Quote:
I need help to either make the script work with multiple calls...
That's easy enough to accomplish. I use ReplaceFramesSimple for such things. It's part of stickboy's RemapFrames filter. Here's an example of its use:

A=Last
B=A.Dirt()#or however you call the filter
ReplaceFramesSimple(A,B,Mappings="[1000 2000] [4000 5000] [8000 10000]")#the beginning and end frame numbers each time it's called.
manono is offline   Reply With Quote
Old 4th June 2014, 10:07   #3  |  Link
Floatingshed
Registered User
 
Join Date: Nov 2008
Posts: 324
ReplaceFramesSimple sounds just the thing, I'll give it a try. Thanks.
Floatingshed is offline   Reply With Quote
Old 5th June 2014, 00:23   #4  |  Link
Floatingshed
Registered User
 
Join Date: Nov 2008
Posts: 324
ReplaceFramesSimple worked a treat, thanks for the suggestion.
Using TFM completely messed up the interlaced parts, so I'm guessing I had it set wrong...
Floatingshed is offline   Reply With Quote
Old 5th June 2014, 03:19   #5  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
Quote:
Originally Posted by Floatingshed View Post
ReplaceFramesSimple worked a treat, thanks for the suggestion.
You're welcome. I use it a lot myself for 'selective filtering'.
Quote:
Using TFM completely messed up the interlaced parts, so I'm guessing I had it set wrong...
Wrong field order, maybe? Or maybe I was just plain wrong about suggesting its use on a mix of pure interlace, phase shifted, and progressive material, and expecting it not to do anything to the interlaced and progressive sections, even with 'PP=0' set.
manono is offline   Reply With Quote
Old 5th June 2014, 19:50   #6  |  Link
Floatingshed
Registered User
 
Join Date: Nov 2008
Posts: 324
Setting order=1 and AssumeTFF (it is TFF) and Separatefields after gives 4 forward fields and one backward field on the interlaced parts and exactly what you would expect on the film parts.
So TFM doesn't seem to be the way to go here. But ReplaceFramesSimple has solved my problem. Thanks.

Last edited by Floatingshed; 5th June 2014 at 20:01.
Floatingshed is offline   Reply With Quote
Old 5th June 2014, 20:48   #7  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
Sorry then. I should have tested first. You could always try and isolate the phase-shifted parts and use TFM together with ReplaceFramesSimple on them alone. But it might be too much work to be worth it for you.
manono is offline   Reply With Quote
Reply

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 17:06.


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