VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors.
Please consider supporting us by disabling your ad blocker or buy a VSO converter software :)
+ Reply to Thread
Results 1 to 13 of 13
Thread
  1. Member
    Join Date
    Feb 2017
    Location
    Victoria
    Search PM
    [Noob alert] Can you pls help me, I have used avisynth years ago on my old XP machine & could work around it fine, but now I need to install it on my new machine which is Windows 7 64bit & I am having endless issues argh help me pls!

    First off, now I see there is "avisynth", "avisynth+", "vapoursynth"... what do I want? I think vapoursynth requires a whole new learning so I might ditch that idea. What is avisynth+? I tried downloading the latest avisynth 2.61 alpha from the videohelp downloads but my avira quarantined it straight away. How do I make an exception? Do I just turn off Avira's "real-time protection" while I download & install?

    How do I set up a simple script with RemoveDirtMC? My problem is that avisynth resources (plugins, scripts etc) are all over the place, often contradictory, I don't know what's latest, what's obsolete etc? I want to use FFMpegSource to open up a simple mpeg2 file but can't even get that simple thing to work (with avisynth+ that is). Where do I download RemoveDirt and FFMpegSource from & know they are the right versions for me?

    And then there is all this intrusive Win7 headache with "permissions" & things, can't even download a plugin into my avisynth+ project files plugin folder... and even then, which plugin folder? Lol, "plugin" or "plugin+" or "plugin64" or "plugin64+" or... lol!

    As you can see, I'm in a bit of a pickle, and would appreciate some guidance if possible! First things first, which avisynth & how to install without AVira barking at me?

    Thank you for any help!
    Quote Quote  
  2. Member
    Join Date
    Feb 2017
    Location
    Victoria
    Search PM
    OK I managed to install avisynth 2.61 alpha by disabling Avira real-time protection. Cool that's sorted. I won't worry about avisynth+ or vapoursynth. I installed it by right-clicking & "run as administrator" - correct?

    OK now I need to get hold of FFMpegSource so I can load my mpg video file - correct? How do I do that pls?
    Quote Quote  
  3. I recommend you use LSMASH instead of ffmpegsource.

    MPEG video is best loaded by DgMpegdec. Create an index with DgIndex the open that index file in your AviSynth script with Mpeg2Source().
    Quote Quote  
  4. Member
    Join Date
    Feb 2017
    Location
    Victoria
    Search PM
    Great thanks, jagabo! I used DGMpegDec instead, worked fine, now I can open up my d2v file in AVsMod, brilliant.

    The video in question is an old rare black and white movie that's been scraped up off some TV station's floor, it's full of vertical scratches. I don't even know if it's fixable but I'd like to try.

    I'm trying Descratch which is helping but still there are scratches & marks.
    Quote Quote  
  5. Member
    Join Date
    Feb 2017
    Location
    Victoria
    Search PM
    I'll show you an example pic.

    So far I have this:

    LoadPlugin("C:\~\DGDecode.dll")
    LoadPlugin("C:\~\descratch.dll")
    MPEG2Source("C:\~\video.d2v")
    Descratch(mindif=1)

    before
    Click image for larger version

Name:	01.jpg
Views:	71
Size:	40.0 KB
ID:	40559

    after
    Click image for larger version

Name:	02.jpg
Views:	73
Size:	39.7 KB
ID:	40560
    Quote Quote  
  6. I transfer movie film for a living. Vertical scratches are extremely difficult to remove in post, with AVISynth or with any other tool. Unlike dirt spots which exist for exactly one frame and are therefore easy to identify and then remove simply by comparing the current frame with the two adjacent frames, vertical scratches tend to persist at more-or-less the same place, from frame-to-frame. However, note the modifier "more-or-less." Unfortunately, scratches tend to wander around, left to right, and also usually shorten and lengthen a bit (for those that don't go all the way from the top to the bottom). Thus, you can't use a fixed mask, like you would for removing a logo, and you can't use motion estimation to line up adjacent frames and look for differences.

    About the only way to get rid of scratches -- and it works really well -- is to do a "wet-gate" film transfer where you coat the film with a slightly viscous fluid that fills in the scratches, but doesn't harm the film. VideoFred, over in the doom9.org forum does this and has written about his work. You'll also find thousands of posts about the subject if you Google it.

    So, if you have access to the film, and the scratches are actually on the film, then that is the way to go. However, if this is a print of a negative, and the scratches were on the negative, then you are out of luck. Same goes is you no longer have access to the film. If either of those are the case, then what you are doing is the best solution I know of which, as you are finding out, helps a little, but doesn't get you too far.

    If you are interested, here is some before/after of some of my restoration work which shows you the kind of improvements with can be made using AVISynth scripts:

    https://www.youtube.com/watch?v=tBAHzO7rJS0

    If you play this forward to the beach scene which begins at about the 1:05 mark, you will see that I was able to get rid of some scratches, although they were not a large and persistent as what you are dealing with. The AVISynth plugin that let me do this is RemoveDirt. It is used inside of a motion-estimated function which improves the dirt removal by moving the two adjacent frames so that they better line up with the current frame. If you turn up the dirt removal parameter, it will sometimes start to remove scratches, although it will also tend to remove small objects. I do a lot of work with old football films, and have to manually deal with kicks and pass plays because the dirt remove often removes the ball in flight.

    Here are some very useful posts by VideoFred over at doom9.org:

    Film Transfer Tutorial

    The power of Avisynth: new 8mm film restoring examples

    The power of Avisynth: restoring old 8mm films.

    Capturing and restoring old 8mm films
    Quote Quote  
  7. Member
    Join Date
    Feb 2017
    Location
    Victoria
    Search PM
    Thank you, johnmeyer. Some very nice work there! No I don't have access to the original reel. It was telecined by a TV studio tech & given to a movie collector in the U.S. and then passed down the chain to my friend here in Australia - who I am trying to help by cleaning it up somewhat. I have used avisynth quite a bit in the past so thought I'd give it a go.

    Yes the vertical scratches are quite nasty, Descratch works a little but like all filtering it is a fine line.

    I'll keep plodding away at it. Thanks for the links. I have yet to try RemoveDirt. Finding all the bits and pieces needed is quite a challenge!
    Quote Quote  
  8. If you want to upload a minute of footage, you can either post the link here or send it via PM and I'll take a shot at it to see what can be done. I do a lot of restoration work and am always creating (or stealing from doom9.org and this forum) all sorts of new ways to improve video and film.
    Quote Quote  
  9. Member
    Join Date
    Feb 2017
    Location
    Victoria
    Search PM
    That's very kind of you! Here is a short segment is it long enough? (~15MB). As you can see it is very poor quality! (This is a particularly bad bit, it does improve a bit). Let me know if you need a longer segment, or a different scene whatever, ok?

    https://www.mediafire.com/?vnw5oiutz3d7c4w

    I have been trying to get RemoveDirt to work but just doesn't seem to want to cooperate with me...? I have a script for RemoveDirtMC_SE.avsi here but it is baulking on the NLmeanCL2 plugin? All I can find is KNLmeansCL?
    Quote Quote  
  10. First, you will not get anywhere unless you first get rid of the telecine. None of the filters will work correctly on telecined material.

    Fortunately it is nothing but garden variety 3:2 pulldown, so this two-line script removes it:

    Code:
    TFM()
    TDecimate()
    I then ran it through my version of VideoFred's film restoration script that I heavily modified to deal with Polavision instant film. Your film has a order of magnitude more dirt and gunk than regular amateur film.

    This is the result produced by those two operations:

    IVTC'd and Restored (Still Contains Scratches)

    As you can see, almost all the transient (i.e., unique to one frame) artifacts have been removed, leaving just the scratches. Also, because motion stabilization was applied as part of step two of my process, the scratches are a little more stable.

    I then briefly tried the Descratch filter on this restored material, and it did seem to do quite a bit. However, I don't have time to play around with all the settings. I used these settings:

    Code:
    descratch(source,asym=10,mindif=4,maxgap=1,minlen=25,maxlen=2048,maxangle=5.0,border=2)
    It definitely removed quite a few scratches, but did a lousy job blending the result after removal, and it missed the big huge scratch.

    Here is one frame from the original, after IVTC:



    Here is the same frame after running it through the film restoration script and applying the Descratch filter:



    [edit]In looking at this result, I applied too much sharpening.[/end edit]

    So, this gets you to the point where you can concentrate on the scratches. Try playing around with the various Descratch settings. I wasn't able to produce a result that was better than the original and, in fact, the result was considerably more distracting. Perhaps others will have other plugins to suggest, or Descratch settings that will work better than what I tried.
    Last edited by johnmeyer; 14th Feb 2017 at 12:03. Reason: added comment about sharpening
    Quote Quote  
  11. Member
    Join Date
    Feb 2017
    Location
    Victoria
    Search PM
    That is fantastic! You managed to clean it up without sacrificing any details, in fact I can see a tad more detail in your restored clip! Can you post the script you used for this by any chance?

    Yes I think a scratch like that big white thing would have to be painted out somehow... way too much work involved.

    I am more than happy with what you have achieved! I have VideoFred's script here, I just wondered how much of it you have modified for this clip?

    Thanks again, JohnMeyer, I really appreciate all your help!
    Quote Quote  
  12. I posted the latest version of my script in three consecutive posts at doom9.org:

    Capturing and restoring old 8mm films

    I later modified this script to deal with the horrendous chemical pollution inherent in Polaroid's Polavision, their short-lived instant movie film. I have not posted that, but if you'd like to try it out, here is that script, which I modified further to work on your film. Thus, except for the IVTC step which I did with a separate script (it was just TFM followed by TDecimate), this is everything I did to produce the video I uploaded. I then imported that into a separate script just to work on Descratch. I was not very happy with the Descratch results.

    BTW, you might want to reduce the PRE_sharp_ness= 85 to something more like 50, and denoising_strength=600 to something more like 300. This may reduce some of the apparent detail increase, which you have already noted, but it will also reduce the unwanted sharpening artifacts. It is a tradeoff.

    So, here's the exact script I used.

    Code:
    # film restoration script by videoFred.
    # denoising, resizing, stabilising, sharpening, auto-levels and auto-white balance.
    #
    # Modified by John Meyer, October 7, 2012
    # Modified by John Meyer, July 7, 2015 (fix errors)
    # Modified for Polavision (large dirt removal) by John Meyer, October 15, 2013
    #
    # Changes made by Meyer (June 8, 2010):
    #   1. Replaced the MVDegrainMulti function, which was part of the original MVTools
    #      with the equivalent function using the newer and faster MVTools2.
    #   2. Added RemoveDirt function prior to Degrain in order to eliminate large dust spots. This
    #      substantially improves the dirt removal capabilities of this script. The user will need to 
    #      download this plugin at:
    #          http://www.removedirt.de.tf/
    #   3. Eliminated a great deal of sharpening. The original script did sharpening in at least four places.
    #      With grainy film stock, this sometimes created objectionable grain. Also, the limitedSharpenFaster
    #      function, while excellent for video, is uncessarily slow, and isn't really needed for this low 
    #      resolution source. Too much sharpening can make the film look too much like video.
    #   4. Added multithreading. I was able to roughly triple the script performance. It may be possible to
    #      substantially increase this, perhaps as much as 12x instead of 3x. However, the autolevels function
    #      would have to be replaced.
    #   5. Fixed several things I found. The result3 option didn't have the manual color correction code, so I 
    #      added that back in. All the numbered "stab" variables (stab1, stab2, etc.) aren't needed except 
    #      for providing a test function for stabilization. I eliminated all of this to streamline the script.
    #   6. Deflicker seemed redundant, given all the averaging that takes place with MDegrain, and also the averaging
    #      that is done when the autolevels outputs are selected. 
    #   7. I reduced the number of frames used for averaging autolevels from the default (which is 5) to 2.
    #      I probably should add a variable in the header so the user can change this. Something else to do
    #      in the future ...
    #   8. I added yet another set of crop parameters. I did this because both my capture and my output are 
    #      done using NTSC DV AVI which is 720x480. However, 8mm film is almost exactly square, so the captured
    #      720x480 video has black bars on the side. These need to be cropped off prior to doing motion 
    #      stabilization, but then added back prior to the final output, which must still be 720x480 with the
    #      black bars on the side.
    #   9. I reduced the default depan settings to 20, which is what was recommended in the original script. I
    #      also reduced the post-depan cropping. I did this so I could keep as much of the original frame
    #      as possible.
    #  10. I removed the second denoising and sharpening function. It just seemed to be too much, and made the 
    #      result too artificial
    #  11. I removed the MVFLowFPS interpolation. I did this during one of dozens and dozens of attempts
    #      to improve the speed of the script. I should probably add this back, but if I do so, I also 
    #      need to make it work correctly for interlaced output. If the goal is to show this on an NTSC or PAL
    #      television set, then it is not correct to convert from the film fps to 25 fps progressive (PAL) or
    #      29.97 fps progressive (NTSC). Instead, this should be done as follows (example given is NTSC):
    #
    #         MFlowFPS(source,super,backward_vec, forward_vec, num=60000, den=1001,ml=200)
    #         SeparateFields()
    #         SelectEvery(4, 0, 3)
    #         Weave()
    #
    #      This yields interlaced 29.97, which has twice the temporal resolution as 29.97 progressive, and will
    #      therefore look correct on a TV set. I have done a lot of this as part of my Kinescope to video
    #      conversion scripts. For those scripts, the goal is to make the filmed version of a TV show look
    #      like it was actually videotaped. However, for something that originated on film, this "does violence"
    #      to the original feel of the media. It is true that it can make horizontal pans less "juddery," but
    #      it won't feel like film anymore. Also, this technique does break down, espcially with fast motion
    #      in the foreground.
    #  12. Removed the unecessary "coloryuv(off_U=blue,off_V=red)" statement from the denoising section.
    #  13. Added killaudio() statement to prevent lockups when using SetMTMode().
    #
    # Changes made on October 7, 2012
    #
    #   1. Modified RemoveDirtMC function to do estimation in two steps. This improves performance and quality.
    #   2. Modified MDegrain to do estimation in two steps. This provides roughly the same quality with blocksize=8
    #      as what I was getting with blocksize=4, but with virtually no performance penalty
    #   3. Updated to use special build of MVTools2 that works with SVP.
    #   4. Moved Autolevels inside special multi-threading section in order to improve performance with autolevels.
    #   5. Removed all trim commands because I do all editing outside the script (in Vegas).
    #   6. Included two alternative ways to do frame interpolation: SVP and InterFrame. The InterFrame script is probably better
    #      but I included the SVP code because it may provide a starting point for more customized approaches. Neither is enabled by default.
    #
    # Changes made on October 15, 2013
    
    #====================================================================================
    
    #VIDEO FILE
    #----------------------------------------------------------------------------------------------------------------------------
    #Change the following line to point to your video file
    film="e:\fs.avi"
    
    
    #GENERAL PARAMETERS
    #----------------------------------------------------------------------------------------------------------------------------
    result="result4"                                 #specify the wanted output here 
    play_speed=24 * (1001.0 / 1000.0)                                     #play speed (8mm=16; Super8=18; 16mm sound=24)
    
    
    #COLOR AND LEVELS PARAMATERS
    #----------------------------------------------------------------------------------------------------------------------------
    saturation=1.0                                                  #for all outputs
    gamma=1.0                                                       #for all outputs 
    blue= -0  red=-0                                                #manual color adjustment, when returning result3 & result4. Values can be positive or negative
    black_level=0  white_level=255 output_black=0  output_white=255 #manual levels, when returning result2 & result4
     
    
    #SIZE, CROP AND BORDERS PARAMETERS
    #----------------------------------------------------------------------------------------------------------------------------
    CLeft=4  CTop=4  CRight=4  CBottom=4                         #crop values after Depan and before final resizing 
    W=720  H=480                                                     #final size after cropping 
    bord_left=0        bord_top=0     bord_right=0     bord_bot=0    #720p= borders 150
    in_bord_left=0  in_bord_top=0  in_bord_right=0  in_bord_bot=0  #Borders around input that must be removed
    
    
    #STABILISING PARAMETERS
    #----------------------------------------------------------------------------------------------------------------------------
    maxstabH=8                                                      #maximum values for the stabiliser (in pixels) 20 is a good start value 
    maxstabV=8
    est_left=40  est_top=40  est_right=40  est_bottom=40             #crop and contast values for special Estimate clip
    est_cont=1.6
    
    #DENOISING PARAMETERS
    #----------------------------------------------------------------------------------------------------------------------------
    denoising_strength=600                     #denoising level of first denoiser: MVDegrain() 
    block_size=   16                           #block size of MVDegrain
    block_size_v= 16
    block_over=    8                           #block overlapping of MVDegrainMulti()
    
    dirt_strength=93                            #sets amount of dirt removal (big spots)
    
    #FOUR STEP SHARPENING PARAMETERS
    #--------------------------------------------------------------------------------------------------------------------------------
    #PRE_sharp_ness= 120   PRE_radi_us= 3              #presharpening (UnsharpMask) just after first denoising
    PRE_sharp_ness= 85   PRE_radi_us= 3              #presharpening (UnsharpMask) just after first denoising
    
    LSF_sharp_ness=160 LSF_radi_us=2  LSF_sub=1.5     #second sharpening parameters (LimitedSharpenFaster) sub=subsampling
    
    #Sharp_Strength = 0.4
    Sharp_Strength = 0.07
    
    
    #AUTO LEVELS PARAMETER
    #--------------------------------------------------------------------------------------------------------------------------------
    X=4   #X is a special parameter for reducing the autolevels effect on the whites
    X2=4  #X2 is a special parameter for reducing the autolevels effect on the blacks 
    
    
    #NUMBER OF THREADS
    #--------------------------------------------------------------------------------------------------------------------------------
    threads=6
    
    
    # END VARIABLES, BEGIN SCRIPT
    #=================================================================================================================================
    
    
    SetMemoryMax(1000)
    
    LoadPlugin ("mvtools2.dll")        #Version 2.5.11.9    2/24/2012
    LoadPlugin("autolevels.dll")       #Version 0.6.0.0     1/09/2011
    LoadPlugin("Deflicker.dll")        #Version 0.4.0.0     8/16/2004
    Loadplugin("Depan.dll")            #Version 1.10.0.0    4/09/2007
    LoadPlugin("DepanEstimate.dll")    #Version 1.9.2.0     3/25/2007
    LoadPlugin("fft3dfilter.dll")      #Version 2.1.1.0     2/20/2007
    Loadplugin("mt_masktools.dll")     #Version 2.0.23.0    3/14/2008
    loadplugin("RemoveDirtSSE2.dll")   #Version 0.9         5/05/2005    
    Loadplugin("RemoveGrainSSE2.dll")  #Version 0.9         5/01/2005
    #Loadplugin("removegrain.dll")     #Version 0.9         5/01/2005
    Loadplugin("warpsharp.dll")        #                    4/05/2010
    
    
    #Use the following for alternative frame interpolation
    #loadplugin("svpflow1.dll")        #Version 1.2.1.0     5/29/2012
    #loadplugin("svpflow2.dll")        #Version 1.3.1.0     6/02/2012 
    #Import("InterFrame2.avsi")        #Version 2.1.0       6/27/2012
    
    #Import("LimitedSharpenFaster.avs")         #Not used in this script, but available if someone wants to experiment
    #LoadPlugIn("LimitedSupport_09Jan06B.dll")  #Used with LimitedSharpenFaster
    
    #load_stdcall_plugin("C:\Program Files\AviSynth 2.5\plugins\yadif.dll")
    
    #Remove all setmtmode statements (there are three in this script) if not using multi-threaded (MT) AVISynth
    setmtmode(5,threads)
    source1= Avisource(film).killaudio().assumefps(play_speed).converttoYV12()
    #source1= Avisource(film).assumefps(play_speed).converttoYV12()
    
    #Include Polavision vertical line removal
    cropped_source=source1.crop(in_bord_left,in_bord_top,-in_bord_right,-in_bord_bot)               #remove any black borders on input video
    setmtmode(2)
    
    
    
    #STABILIZING
    #....................................................................................................................................................................
    stab_reference= cropped_source.crop(est_left,est_top,-est_right,-est_bottom).tweak(cont=est_cont).MT_binarize(threshold=80).greyscale().invert()
    mdata=DePanEstimate(stab_reference,trust=1.0,dxmax=maxstabH,dymax=maxstabV)
    
    #Deflicker may cause color shift !
    #stab=DePanStabilize(cropped_source,data=mdata,cutoff=0.5,dxmax=maxstabH,dymax=maxstabV,method=1,mirror=15).deflicker()
    stab=DePanStabilize(cropped_source,data=mdata,cutoff=0.5,dxmax=maxstabH,dymax=maxstabV,method=1,mirror=15)
    
    
    #DENOISING
    #...................................................................................................................................................................
    input_to_removedirt=stab.crop(CLeft,CTop,-CRight,-CBottom)
    stabcrop=RemoveDirtMC(input_to_removedirt,dirt_strength,false)
    
      prefiltered = RemoveGrain(stabcrop,2)
      superfilt =   MSuper(prefiltered, hpad=32, vpad=32,pel=2)
      super=        MSuper(stabcrop, hpad=32, vpad=32,pel=2)
    
      halfblksize= (block_size>4)   ? block_size/2 : 4
      halfoverlap= (block_over>2)   ? block_over/2 : 2
    
      bvec1 =  MAnalyse(superfilt, isb = true,  delta = 1, blksize=block_size, overlap=block_over,dct=0)
      bvec1 =  MRecalculate(super, bvec1, blksize=halfblksize, overlap=halfoverlap,thSAD=100) 
    
      fvec1 =  MAnalyse(super, isb = false, delta = 1, blksize=block_size, overlap=block_over,dct=0)
      fvec1 =  MRecalculate(super, fvec1, blksize=halfblksize, overlap=halfoverlap,thSAD=100)
    
      bvec2 =  MAnalyse(super, isb = true,  delta = 2, blksize=block_size, overlap=block_over,dct=0)
      bvec2 =  MRecalculate(super, bvec2, blksize=halfblksize, overlap=halfoverlap,thSAD=100)
    
      fvec2 =  MAnalyse(super, isb = false, delta = 2, blksize=block_size, overlap=block_over,dct=0)
      fvec2 =  MRecalculate(super, fvec2, blksize=halfblksize, overlap=halfoverlap,thSAD=100)
    
    #  bvec3 =  MAnalyse(super, isb = true,  delta = 2, blksize=block_size, overlap=block_over,dct=0)
    #  bvec3 =  MRecalculate(super, bvec3, blksize=halfblksize, overlap=halfoverlap,thSAD=100)
    
    #  fvec3 =  MAnalyse(super, isb = false, delta = 2, blksize=block_size, overlap=block_over,dct=0)
    #  fvec3 =  MRecalculate(super, fvec3, blksize=halfblksize, overlap=halfoverlap,thSAD=100)
    
    
    #super = stabcrop.MSuper(pel=2)
    #bvec1 =  MAnalyse(super, isb = true,  delta = 1, blksize=block_size, overlap=block_over,dct=0)
    #fvec1 =  MAnalyse(super, isb = false, delta = 1, blksize=block_size, overlap=block_over,dct=0)
    #bvec2 =  MAnalyse(super, isb = true,  delta = 2, blksize=block_size, overlap=block_over,dct=0)
    #fvec2 =  MAnalyse(super, isb = false, delta = 2, blksize=block_size, overlap=block_over,dct=0)
    #bvec3 = MAnalyse(super, isb = true,  delta = 3, blksize=block_size, overlap=block_over,dct=0)
    #fvec3 = MAnalyse(super, isb = false, delta = 3, blksize=block_size, overlap=block_over,dct=0)
    
    
    #Use the second line below, and un-comment two lines above if you want to average more frames. Doesn't seem necessary for most work IMHO.
    denoised=stabcrop.MDegrain2(super, bvec1,fvec1,bvec2,fvec2,thSAD=denoising_strength).levels(0,gamma,255,0,255).tweak(sat=saturation).unsharpmask(PRE_sharp_ness,PRE_radi_us,0)
    #denoised=stabcrop.MDegrain3(super, bvec1,fvec1,bvec2,fvec2,bvec3,fvec3,thSAD=denoising_strength).tweak(sat=saturation).unsharpmask(PRE_sharp_ness,PRE_radi_us,0)
    
    
    #SHARPENING
    #...................................................................................................................................................................
    sharp1=denoised.sharpen(Sharp_Strength)	
    #sharp1=limitedSharpenFaster(denoised,smode=1,strength=LSF_sharp_ness,overshoot=50,radius=LSF_radi_us, ss_X=LSF_sub, SS_Y=LSF_sub, dest_x=W - bord_left - in_bord_left - bord_right - in_bord_right,dest_y=H - bord_top - in_bord_top - bord_bot - in_bord_bot)
    
    PreBorderFrame = sharp1.Lanczos4Resize(W - bord_left - in_bord_left - bord_right - in_bord_right, H - bord_top - in_bord_top - bord_bot - in_bord_bot)
    
    #FRAME INTERPOLATION (optional)
    #...................................................................................................................................................................
    
    #superfps= MSuper(PreBorderFrame,pel=2)
    #backward_vec2 = MAnalyse(superfps, isb = true,blksize=16)
    #forward_vec2  = MAnalyse(superfps, isb = false,blksize=16)
    #PreBorderFrame = MFlowFps(PreBorderFrame,superfps, backward_vec2, forward_vec2, num=60000, den=1001, ml=200).SeparateFields().SelectEvery(4, 0, 3).Weave()
    
    #Change SetMTMode for Autolevels
    
    #SetMTMode(5,threads)
    
    #RESULT1: AUTOLEVELS,AUTOWHITE
    #......................................................................................................................................................................
    result1= PreBorderFrame.coloryuv(autowhite=true).addborders(X,0,0,0,$FFFFFF).addborders(0,0,X2,0,$000000).autolevels(filterRadius=2).crop(X,0,-X2,-0).addborders(bord_left+in_bord_left, bord_top+in_bord_top, bord_right+in_bord_right, bord_bot+in_bord_bot)
    
    #RESULT3: AUTOLEVELS, MANUAL COLOR CORRECTIONS
    #.....................................................................................................................................................................
    result3= PreBorderFrame.coloryuv(off_U=blue,off_V=red).addborders(X,0,0,0,$FFFFFF).addborders(0,0,X2,0,$000000).autolevels(filterRadius=2).crop(X,0,-X2,-0).addborders(bord_left+in_bord_left, bord_top+in_bord_top, bord_right+in_bord_right, bord_bot+in_bord_bot)
    
    #SetMTMode(2)
    
    
    #RESULT2: MANUAL LEVELS, AUTOWHITE
    #......................................................................................................................................................................
    result2= PreBorderFrame.levels(black_level,gamma,white_level,0,255).coloryuv(autowhite=true).addborders(bord_left+in_bord_left, bord_top+in_bord_top, bord_right+in_bord_right, bord_bot+in_bord_bot)
    
    #RESULT4: MANUAL LEVELS, MANUAL COLOR CORRECTIONS
    #.....................................................................................................................................................................
    result4= PreBorderFrame.coloryuv(off_U=blue,off_V=red).levels(black_level,gamma,white_level,0,255).addborders(bord_left+in_bord_left, bord_top+in_bord_top, bord_right+in_bord_right, bord_bot+in_bord_bot)
    
    #PARAMETERS FOR THE COMPARISONS
    #.....................................................................................................................................................................
    W2= W+bord_left+bord_right
    H2= H+bord_top+bord_bot
    source4=Lanczos4Resize(source1,W2,H2)
    
    
    #COMPARISONS: ORIGINAL VS RESULTS
    #......................................................................................................................................................................
    resultS1= stackhorizontal(subtitle(source4,"original",size=28,align=2),subtitle(result1,"autolevels, autowhite",size=28,align=2))
    resultS2= stackhorizontal(subtitle(source4,"original",size=28,align=2),subtitle(result2,"autowhite, manual levels correction",size=28,align=2))
    resultS3= stackhorizontal(subtitle(source4,"original",size=28,align=2),subtitle(result3,"autolevels, manual color correction",size=28,align=2))
    resultS4= stackhorizontal(subtitle(source4,"original",size=28,align=2),subtitle(result4,"manual colors and levels correction",size=28,align=2))
    
    
    Eval(result)
    
    
    # END SCRIPT, BEGIN FUNCTIONS
    #=================================================================================================================================
    
    
    #REMOVE DIRT FUNCTION
    #......................................................................................................................................................................
    function RemoveDirt(clip input, int "limit", bool "_grey")
    {
      clensed=input.Clense(grey=_grey, cache=4)
      alt=input.RemoveGrain(2)
      return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=30,cthreshold=8, gmthreshold=40,dist=3,dmode=2,debug=false,noise=limit,noisy=4, grey=_grey)
    
      # Alternative settings
      # return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=4,cthreshold=6, gmthreshold=40,dist=1,dmode=2,debug=false,noise=limit,noisy=12,grey=_grey,show=true)
      # return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=6,cthreshold=8, gmthreshold=40,dist=3,tolerance= 12,dmode=2,debug=false,noise=limit,noisy=12,grey=_grey,show=false)
    }
    
    function RemoveDirtMC(clip, int "limit", bool "_grey")
    {
      _grey=default(_grey, false)
      limit = default(limit,6)
    
    #  prefiltered = fft3dfilter(clip,sigma=1,sigma2=2,sigma3=3,sigma4=5,bw=64,bh=64)
      
      prefiltered = RemoveGrain(clip,2)
      superfilt = MSuper(prefiltered, hpad=32, vpad=32,pel=2)
    
      super=MSuper(clip, hpad=32, vpad=32,pel=2)
    
      bvec = MAnalyse(superfilt,isb=true,  blksize=16, overlap=2,delta=1, truemotion=true)
      fvec = MAnalyse(superfilt,isb=false, blksize=16, overlap=2,delta=1, truemotion=true)
    
    # Increase thSAD if moving objects are being removed!!
      bvec_re = Mrecalculate(super,bvec,blksize=8, overlap=0,thSAD=20)
      fvec_re = Mrecalculate(super,fvec,blksize=8, overlap=0,thSAD=20)
    
      backw = MFlow(clip,super,bvec_re,thSCD1=900,thSCD2=200)
      forw  = MFlow(clip,super,fvec_re,thSCD1=900,thSCD2=200)
    
      clp=interleave(forw,clip,backw)
      clp=clp.RemoveDirt(limit,_grey)
    
    
    # Alternative to RemoveDirt call above
    #  clp     = clp.DeSpot(p1=20, p2=4, pwidth=30, pheight=30, mthres=22, merode=33, sign=1,  seg=0, color=false, \
    #                       motpn=false, fitluma=true, mark_v=255)
    
    #  clp     = clp.invert.DeSpot(p1=12, p2=6, pwidth=18, pheight=16, mthres=22, merode=25, p1percent=10, sign=1, show=Show, seg=1, \
    #                       color=true, motpn=false, mark_v=255).invert
    
    
      clp=clp.SelectEvery(3,1)
      return clp
    }
    
    #This function is the previous way to do motion estimation. It is slower and not as accurate.
    function RemoveDirtMC_old(clip,int limit, bool "_grey")
    {
      _grey=default(_grey, false)
      limit = default(limit,6)
      i=MSuper(clip,pel=2)
      fvec = MAnalyse(i,isb=false, blksize=16, delta=1, truemotion=true)
      bvec = MAnalyse(i,isb=true,  blksize=16, delta=1, truemotion=true)
      backw = MFlow(clip,i,bvec)
      forw  = MFlow(clip,i,fvec)
      clp=interleave(forw,clip,backw)
      clp=clp.RemoveDirt(limit,_grey)
      clp=clp.SelectEvery(3,1)
      return clp
    }
    Quote Quote  
  13. Member
    Join Date
    Feb 2017
    Location
    Victoria
    Search PM
    Very much appreciated, John! I will sit & work slowly through your script - I don't want to just "copy & paste" verbatim. The motion compensation stuff (is that what it's called? The MAnalyse lines?) does a fantastic job at denoising!

    I spent a good few hours getting avisynth installed properly & tracking down all required plugins & scripts etc, it's a royal pita although the wiki pages actually seem reasonably up-to-date these days?

    Anyway a lot of work for me to do... Thanks again, John!

    (I may very well be back!)
    Quote Quote  



Similar Threads