VideoHelp Forum
+ Reply to Thread
Results 1 to 1 of 1
Thread
  1. I am using this script by John Meyer to restore old 8mm movies and convert to video, but I am getting a Virtualdub crash on exit with " out-of-bounds memory access (access violation) occurred in module 'ntdll'". If I use an old mvtool2.dll version from Video Fred's film restoring script plugin folder, version 2.4.2.0, instead of the latest 2.5.11.3 then all is OK. It was suggested on Doom9 forum that I should change MFlow in RemoveDirtMC to MCompensate which does indeed seem to cure the problem, but I am wondering what this does to the quality of the video. Curious to know if anyone else has this problem and why using the latest MVtools2.dll has this effect. Also I cannot use the SVP version of the plugin 2.5.11.9 as suggested in this script for interpolation as I get the same problem.

    #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; valid results are "result1" through "result4" and "resultS1" through "resultS4" for before/after

    play_speed=16 #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=16 CTop=16 CRight=16 CBottom=16 #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=05 #maximum values for the stabiliser (in pixels) 20 is a good start value
    maxstabV=20
    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
    #----------------------------------------------------------------------------------------------------------------------------
    #Fastest parameters
    #denoising_strength=600 #denoising level of first denoiser: MVDegrain()
    #denoising_strength=300 #denoising level of first denoiser: MVDegrain()
    #block_size= 16 #block size of MVDegrain
    #block_size_v= 16
    #block_over= 8 #block overlapping of MVDegrainMulti()

    #Best compromise between speed and quality
    denoising_strength= 600 #denoising level of first denoiser: MDegrain()
    block_size= 8 #block size of MVDegrain
    block_size_v= 8
    block_over= 4 #block overlapping of MVDegrainMulti()

    dirt_strength=23 #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
    Sharp_Strength= 0.1


    #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=5


    # END VARIABLES, BEGIN SCRIPT
    #================================================= ================================================== ==============================

    # Using AVISynth version 2.60, build August 28, 2012 (Ben-Rudiak-Gould, etc.)
    # Using VirtualDub 1.8.6

    #Change the following (lower or higher) if you have stability problems with multi-threading
    SetMemoryMax(800)

    #Load plugins explicitly
    LoadPlugin ("plugins/mvtools2.dll") #Version 2.5.11.9 2/24/2012
    LoadPlugin("plugins/autolevels_06.dll") #Version 0.6.0.0 1/09/2011
    LoadPlugin("plugins/Deflicker.dll") #Version 0.4.0.0 8/16/2004
    Loadplugin("plugins/Depan.dll") #Version 1.10.0.0 4/09/2007
    LoadPlugin("plugins/DepanEstimate.dll") #Version 1.9.2.0 3/25/2007
    Loadplugin("plugins/mt_masktools.dll") #Version 2.0.23.0 3/14/2008
    loadplugin("plugins/RemoveDirtSSE2.dll") #Version 0.9 5/05/2005
    Loadplugin("plugins/RemoveGrainSSE2.dll") #Version 0.9 5/01/2005
    Loadplugin("plugins/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

    #Open and crop the video
    #Remove all setmtmode statements (there are four in this script) if not using multi-threaded (MT) AVISynth
    setmtmode(5,threads)
    source1= Avisource(film).killaudio().assumefps(play_speed). converttoYV12() #killaudio() improves stability (in my experience -- others disagree)
    cropped_source=source1.crop(in_bord_left,in_bord_t op,-in_bord_right,-in_bord_bot) #temporarily remove any black borders on input video
    setmtmode(2)

    #cropped_source=filldrops(cropped_source) #Use this when removing bad frames that have been removed by duplicating previous frame
    #(see notes in function at end of script)

    #STABILIZING
    #................................................. .................................................. .................................................. ...............
    stab_reference= cropped_source.crop(est_left,est_top,-est_right,-est_bottom).tweak(cont=est_cont).MT_binarize(thres hold=80).greyscale().invert()
    mdata=DePanEstimate(stab_reference,trust=1.0,dxmax =maxstabH,dymax=maxstabV)
    stab=DePanStabilize(cropped_source,data=mdata,cuto ff=0.5,dxmax=maxstabH,dymax=maxstabV,method=1,mirr or=15)

    #Alternative line that includes deflicker. I find that this usually is not needed.
    #stab=DePanStabilize(cropped_source,data=mdata,cut off=0.5,dxmax=maxstabH,dymax=maxstabV,method=1,mir ror=15).deflicker()


    #DENOISING
    #................................................. .................................................. .................................................. ..............

    #Remove dirt
    input_to_removedirt=stab.crop(CLeft,CTop,-CRight,-CBottom)
    stabcrop=RemoveDirtMC(input_to_removedirt,dirt_str ength,false)

    #Reduce grain
    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)

    denoised=stabcrop.MDegrain2(super, bvec1,fvec1,bvec2,fvec2,thSAD=denoising_strength). levels(0,gamma,255,0,255).tweak(sat=saturation).un sharpmask(PRE_sharp_ness,PRE_radi_us,0)


    #SHARPENING
    #................................................. .................................................. .................................................. ..............
    sharp1=denoised.sharpen(Sharp_Strength)
    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)
    #................................................. .................................................. .................................................. ..............

    #Interpolate frames
    #Use this for progressive output -- example shows 29.97 progressive
    #PreBorderFrame=InterFrame(NewNum=30000,NewDen=100 1,PreBorderFrame,GPU=true,Cores=threads)

    #Use this for interlaced output -- example shows 29.97 interlaced
    #PreBorderFrame=InterFrame(NewNum=60000,NewDen=100 1,PreBorderFrame,GPU=true,Cores=threads).SeparateF ields().SelectEvery(4, 0, 3).Weave()


    #RESULT1: AUTOLEVELS,AUTOWHITE
    #................................................. .................................................. .................................................. .................
    SetMTMode(5) #Turn off SetMTMode for Autolevels
    result1= PreBorderFrame.coloryuv(autowhite=true).addborders (X,0,0,0,$FFFFFF).addborders(0,0,X2,0,$000000).aut olevels(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).addb orders(X,0,0,0,$FFFFFF).addborders(0,0,X2,0,$00000 0).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) #Re-enable SetMTMode after Autolevels

    #RESULT2: MANUAL LEVELS, AUTOWHITE
    #................................................. .................................................. .................................................. .................
    result2= PreBorderFrame.levels(black_level,gamma,white_leve l,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).leve ls(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=2 8,align=2),subtitle(result1,"autolevels, autowhite",size=28,align=2))
    resultS2= stackhorizontal(subtitle(source4,"original",size=2 8,align=2),subtitle(result2,"autowhite, manual levels correction",size=28,align=2))
    resultS3= stackhorizontal(subtitle(source4,"original",size=2 8,align=2),subtitle(result3,"autolevels, manual color correction",size=28,align=2))
    resultS4= stackhorizontal(subtitle(source4,"original",size=2 8,align=2),subtitle(result4,"manual colors and levels correction",size=28,align=2))

    #Finish and go home
    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=6,cthreshold=8, gmthreshold=40,dist=3,dmode=2,debug=false,noise=li mit,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=li mit,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)
    }

    #This function provides motion compensation for the remove dirt function, thus improving quality.
    function RemoveDirtMC(clip,int limit, bool "_grey")
    {
    _grey=default(_grey, false)
    limit = default(limit,6)

    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)

    bvec_re = Mrecalculate(super,bvec,blksize=8, overlap=0,thSAD=100)
    fvec_re = Mrecalculate(super,fvec,blksize=8, overlap=0,thSAD=100)

    backw = MFlow(clip,super,bvec_re)
    forw = MFlow(clip,super,fvec_re)

    clp=interleave(backw,clip,forw)
    clp=clp.RemoveDirt(limit,_grey)
    clp=clp.SelectEvery(3,1)
    return clp
    }
    Last edited by boffee; 16th Jan 2014 at 03:48. Reason: spelling
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!