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 November 2020, 15:12   #1  |  Link
MIGLIO74
Registered User
 
Join Date: Nov 2018
Posts: 14
Best Script for Restoring Super 8

Hello, everyone,
I'm looking for the best script in your opinion to restore Super 8 movies.
Now I'm using Freddy's but I'm looking for something better...can someone help me?
thanks
MIGLIO74 is offline   Reply With Quote
Old 9th November 2020, 17:10   #2  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
Better? In what way? His script does over half a dozen different things. What specific thing are you trying to improve compared to what you get with his script? How much work have you done adjusting his settings? Have you tried my version of his script? Have you read through all three of Fred's threads here in this forum?

You can get a massively different result with his script depending on what settings you use.
johnmeyer is offline   Reply With Quote
Old 10th November 2020, 15:40   #3  |  Link
MIGLIO74
Registered User
 
Join Date: Nov 2018
Posts: 14
thanks for your answer, yes I made some small adjustments to Freddy's script, but what I'm looking for is a good colouring.
I tried to use your script but I get several errors the first one is "There is no funcion named addautoloaddir" if I delete the line I get the following "There is no funcion named MT_binarize" and then There is no funcion named FredAverage".

but I understand that you can't keep up with everyone's requests, I'd like to understand better what I'm doing wrong and what I can improve but in the various threads I get lost

Thanks anyway any help is welcome
MIGLIO74 is offline   Reply With Quote
Old 10th November 2020, 16:03   #4  |  Link
videoFred
Registered User
 
videoFred's Avatar
 
Join Date: Dec 2004
Location: Terneuzen, Zeeland, the Netherlands, Europe, Earth, Milky Way,Universe
Posts: 689
Quote:
Originally Posted by MIGLIO74 View Post
I tried to use your script but I get several errors the first one is "There is no funcion named addautoloaddir" if I delete the line I get the following "There is no funcion named MT_binarize" and then There is no funcion named FredAverage".
This means you do not have the required plugins installed. But I do not understand the error message 'addautoloaddir' . What have you changed in the script?

many greetings,
Frede.
__________________
About 8mm film:
http://www.super-8.be
Film Transfer Tutorial and example clips:
https://www.youtube.com/watch?v=W4QBsWXKuV8
More Example clips:
http://www.vimeo.com/user678523/videos/sort:newest
videoFred is offline   Reply With Quote
Old 10th November 2020, 16:16   #5  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
Color grading is one of the toughest things to get right when restoring old film, and I don't think there has ever been an automatic function that can get it right for most scenes. I do 90% of my color work in my NLE, before exporting to the script for dirt removal, stabilization, sharpening, grain reduction, etc.

That function you are having trouble getting to work (GamMac, which is what requires "FredAverage") can sometimes provide decent gamma and color correction, but only sometimes (about 1/3 of the time in my work). The functions it replaced worked even few times than that.

The problem, of course, is that the color dye layers in the film each fade, but at a different rate for each color. This is what leads to film with a reddish cast (most common) or sometimes blue or yellow.

Color is an art, even with brand new film. When commercial movies were still being shot on film, one of the jobs you'd see in the credits was "color timing." That person's job was to make sure the clips from different reels of negative film would match each other when spliced together. Even when all the film was new, and used the same stock, the differences in lighting, times of day, and development would all contribute to slight shifts in color.
johnmeyer is offline   Reply With Quote
Old 10th November 2020, 17:37   #6  |  Link
MIGLIO74
Registered User
 
Join Date: Nov 2018
Posts: 14
Quote:
Originally Posted by videoFred View Post
This means you do not have the required plugins installed. But I do not understand the error message 'addautoloaddir' . What have you changed in the script?

many greetings,
Frede.
Hi Frede, thank you for your reply!

I've tried the John Mayer script find here

http://forum.doom9.net/showthread.ph...34#post1861734
MIGLIO74 is offline   Reply With Quote
Old 10th November 2020, 17:39   #7  |  Link
MIGLIO74
Registered User
 
Join Date: Nov 2018
Posts: 14
Quote:
Originally Posted by johnmeyer View Post
Color grading is one of the toughest things to get right when restoring old film, and I don't think there has ever been an automatic function that can get it right for most scenes. I do 90% of my color work in my NLE, before exporting to the script for dirt removal, stabilization, sharpening, grain reduction, etc.

That function you are having trouble getting to work (GamMac, which is what requires "FredAverage") can sometimes provide decent gamma and color correction, but only sometimes (about 1/3 of the time in my work). The functions it replaced worked even few times than that.

The problem, of course, is that the color dye layers in the film each fade, but at a different rate for each color. This is what leads to film with a reddish cast (most common) or sometimes blue or yellow.

Color is an art, even with brand new film. When commercial movies were still being shot on film, one of the jobs you'd see in the credits was "color timing." That person's job was to make sure the clips from different reels of negative film would match each other when spliced together. Even when all the film was new, and used the same stock, the differences in lighting, times of day, and development would all contribute to slight shifts in color.

Thanks John,
I try to do some tests
MIGLIO74 is offline   Reply With Quote
Old 10th November 2020, 18:13   #8  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
Quote:
Originally Posted by MIGLIO74 View Post
Thanks John,
I try to do some tests
I've posted this clip many times, so I apologize to others for posting it again, but this shows some "before/after" that I achieved with my version of Fred's script. The first clip that has color issues is at the 0:51 mark. The clip at the 2:17 mark has the strongest correction of any clip, but the colors are still pretty muted and not quite right. However, they are MUCH closer to the original scene.

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

Last edited by johnmeyer; 10th November 2020 at 18:14. Reason: forgot the link
johnmeyer is offline   Reply With Quote
Old 11th November 2020, 13:11   #9  |  Link
MIGLIO74
Registered User
 
Join Date: Nov 2018
Posts: 14
Quote:
Originally Posted by johnmeyer View Post
I've posted this clip many times, so I apologize to others for posting it again, but this shows some "before/after" that I achieved with my version of Fred's script. The first clip that has color issues is at the 0:51 mark. The clip at the 2:17 mark has the strongest correction of any clip, but the colors are still pretty muted and not quite right. However, they are MUCH closer to the original scene.

https://www.youtube.com/watch?v=tBAHzO7rJS0
Hi John, nice works!

now i'm testing Your script "
Changes made on September 13, 2017

1. Replaced old useless color correction with GamMac.
2. Removed never-used manual controls.
3. Moved deflicker to end of chain because GamMac introduces flicker.
4. Moved RemoveDirtMC to happen AFTER denoising."

because I can't use the 2019 one, it gives me error with mvtools.dll even if I use the dll for x64.
I like the result very much, thanks, just that the rendering is very long...if I didn't misunderstand reading in the forum with avisisinth+ 64bit module you can use the multithread I have an intel i7 8700k precessor and maybe I would solve the rendering problem.

Thanks in advance
MIGLIO74 is offline   Reply With Quote
Old 11th November 2020, 16:03   #10  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
One of the two main reasons I created my branch of Fred's script is to make it run faster. In my initial tests it was at least 4x faster. My subsequent releases are even faster than that. However, you do have to enable multi-threading to pick up most of that performance improvement.

Also, all my work is on 32-bit. I have never been clear whether 64-bit anything (i.e., any program) actually runs faster, unless the ability to directly address lots of memory can lead to more speed. I've stayed with 32-bit because it gives me access to the entire range of AVISynth filters. Even after all these years, not everything has been ported to 64-bit.
johnmeyer is offline   Reply With Quote
Old 11th November 2020, 17:23   #11  |  Link
MIGLIO74
Registered User
 
Join Date: Nov 2018
Posts: 14
Quote:
Originally Posted by johnmeyer View Post
One of the two main reasons I created my branch of Fred's script is to make it run faster. In my initial tests it was at least 4x faster. My subsequent releases are even faster than that. However, you do have to enable multi-threading to pick up most of that performance improvement.

Also, all my work is on 32-bit. I have never been clear whether 64-bit anything (i.e., any program) actually runs faster, unless the ability to directly address lots of memory can lead to more speed. I've stayed with 32-bit because it gives me access to the entire range of AVISynth filters. Even after all these years, not everything has been ported to 64-bit.
Thanks John.

I think he needs help, how do I get to enable multi-threading? Can I find some tutorial ore read some thread?

Thanks
MIGLIO74 is offline   Reply With Quote
Old 11th November 2020, 17:55   #12  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
There are dozens of posts on multi-threading. I'll leave it up to you to find those.

In my script, if you use a later version of AVISynth (the "+" versions) you use the Prefectch command. I think the script I posted already has it enabled (i.e., it is not commented out).

If you are using an earlier version of my script you use the SetMTMode() statement. Both versions of my script have comments that alert you to each of these things.

Last edited by johnmeyer; 12th November 2020 at 00:48. Reason: missing word
johnmeyer is offline   Reply With Quote
Old 11th November 2020, 20:34   #13  |  Link
MIGLIO74
Registered User
 
Join Date: Nov 2018
Posts: 14
Quote:
Originally Posted by johnmeyer View Post
There are dozens of posts on multi-threading. I'll it up to you to find those.

In my script, if you use a later version of AVISynth (the "+" versions) you use the Prefectch command. I think the script I posted already has it enabled (i.e., it is not commented out).

If you are using an earlier version of my script you use the SetMTMode() statement. Both versions of my script have comments that alert you to each of these things.
Thank you very kind
MIGLIO74 is offline   Reply With Quote
Old 15th November 2020, 18:49   #14  |  Link
MIGLIO74
Registered User
 
Join Date: Nov 2018
Posts: 14
finally I was able to use John's script. my workflow is this, I scan with Reflecta Super8+ and get an avi file 1920x1080, with Fred's script I import it on premiere pro and export it always in avi codec intel IYUV removing the black bars that is 1440x1080 Is it right?, then Avisynth (W=1470 H=1080 #final size after cropping to have aspect ratio 1.0 if I leave 1440x1080 I have 1.33) and VirtualDub to save it, for a 3 minute movie about 18 minutes of rendering with VD.

this the result, place a frame https://imgur.com/9nZ1So7

this is the code

Code:
# 8mm film restoration script by videoFred.
# www.super-8.be
# info@super-8.be

# version 01.B with frame blending
# release date: june 20, 2012
#============================================================================================

# august 2010: added removerdirtMC() as suggested by John Meyer
# october 2010: auto sharpening parameters

# march 2011: new autolevels.dll by Jim Battle
# www.thebattles.net/video/autolevels.html

# june 2012: improved stabilisation

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

# cleaning, degraining, resizing, stabilizing, sharpening, auto-levels and auto-white balance.
#=============================================================================================


film= "E:\.....B.avi" # source clip, you must specify the full path here








#PARAMETERS
#----------------------------------------------------------------------------------------------------------------------------
result="result1" # specify the wanted output here 

trim_begin=2  trim_end=16 play_speed= 18.75  #trim frames and play speed (PAL: 16.6666 or 18.75)

final_framerate = 25  # final frame rate

frame_blend= 0.4 # set this lover for less blending


#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 or result4. Values can be positive or negative


black_level=0  white_level=255 output_black=0  output_white=255 # manual levels, when returning result4



#AUTO LEVELS PARAMETERS
#--------------------------------------------------------------------------------------------------------------------------------

autolev_low= 6     # limit of autolevels low output
autolev_high= 235  # limit of autolevels high output


 

#SIZE, CROP AND BORDERS PARAMETERS
#----------------------------------------------------------------------------------------------------------------------------
CLeft=20  CTop=20  CRight=20  CBottom=20  #crop values after Depan and before final resizing 

W=1470 H=1080  #final size after cropping 

bord_left=0  bord_top=0  bord_right=0  bord_bot=0 #720p= borders 150


#STABILISING PARAMETERS, YOU REALY MUST USE RESULTS7 TO CHECK STABILISATION!
#----------------------------------------------------------------------------------------------------------------------------
maxstabH=20 
maxstabV=20 #maximum values for the stabiliser (in pixels) 20 is a good start value

est_left=40   est_top=40  est_right=40  est_bottom=40  #crop values for special Estimate clip

trust_value= 1.0     # scene change detection, higher= more sensitive
cutoff_value= 0.5   # no need to change this, but you can play with it and see what you get



#CLEANING PARAMETERS
#--------------------------------------------------------------------------------------------------------------
dirt_strenght=20  # set this lower for clean films.


#DENOISING PARAMETERS
#----------------------------------------------------------------------------------------------------------------------------


denoising_strenght= 300  #denoising level of second denoiser: MVDegrainMulti() 
denoising_frames= 3  #number of frames for averaging (forwards and backwards) 3 is a good start value
block_size= 16  #block size of MVDegrainMulti()
block_size_v= 16
block_over= 8  #block overlapping of MVDegrainMulti()




# FOUR STEP SHARPENING PARAMETERS
#--------------------------------------------------------------------------------------------------------------------------------

USM_sharp_ness= 40   USM_radi_us= 3  #this is the start value for the unsharpmask sharpening
                                     #do not set radius less then 3 
                                     #the script will automatically add two other steps with lower radius 




last_sharp= 0.1 #final sharpening step after degraining and before blending

 last_blur= 0.2 #this smooths out the heavy sharpening effects






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


SetMemoryMax(800)  #set this to 1/3 of the available memory





LoadPlugin("plugins/Deflicker.dll")
Loadplugin("plugins/Depan.dll")
LoadPlugin("plugins/DepanEstimate.dll")
Loadplugin("plugins/removegrain.dll")
LoadPlugin("plugins/removedirt.dll")
LoadPlugin("plugins/MVTools.dll")
LoadPlugin("plugins/MVTools2.dll")
Loadplugin("plugins/warpsharp.dll")
loadplugin("plugins/autolevels_06.dll")
LoadPlugin("plugins/Motion_06Dec05B.dll")
Import("plugins/03_RemoveDirtMC.avs")




source= AviSource(film).assumefps(play_speed).trim(trim_begin,0).converttoYV12()
trimming= framecount(source)-trim_end
source1= trim(source,0,trimming)




#STABILIZING/CROPPING
#..........................................................................................................................................

stab_reference= source1.crop(20,20,-20,-20).colorYUV(autogain=true).crop(est_left,est_top,-est_right,-est_bottom)

mdata=DePanEstimate(stab_reference,trust=trust_value,dxmax=maxstabH,dymax=maxstabV)
stab=DePanStabilize(source1,data=mdata,cutoff=cutoff_value,dxmax=maxstabH,dymax=maxstabV,method=0,mirror=15).deflicker()
stab2= stab.crop(CLeft,CTop,-CRight,-CBottom)
stab3=DePanStabilize(source1,data=mdata,cutoff=cutoff_value,dxmax=maxstabH,dymax=maxstabV,method=0,info=true)


WS= width(stab)
HS= height(stab)
stab4= stab3.addborders(10,10,10,10,$B1B1B1).Lanczos4Resize(WS,HS)
stab5= Lanczos4Resize(stab2,W,H).sharpen(0.5)


#UNSHARPMASK AUTO_PARAMETERS
#-------------------------------------------------------------------------------------------------------------------------------------------

USM_sharp_ness1 = USM_sharp_ness
USM_sharp_ness2 = USM_sharp_ness+(USM_sharp_ness/2)
USM_sharp_ness3 = USM_sharp_ness*2

USM_radi_us1 = USM_radi_us
USM_radi_us2 = USM_radi_us-1
USM_radi_us3 = USM_radi_us2-1


#CLEANING/PRESHARPENING/RESIZING
#...........................................................................................................................................


noise_baseclip= stab2.levels(0,gamma,255,0,255).tweak(sat=saturation)




cleaned= RemoveDirtMC(noise_baseclip,dirt_strenght).unsharpmask(USM_sharp_ness1,USM_radi_us1,0).unsharpmask(USM_sharp_ness2,USM_radi_us2,0).Lanczos4Resize(W,H)





#DEGRAINING/SHARPENING
#.................................................................................................................................................



vectors= cleaned.MVAnalyseMulti(refframes=denoising_frames, pel=2, blksize=block_size, blksizev= block_size_v, overlap=block_over, idx=1)
denoised= cleaned.MVDegrainMulti(vectors, thSAD=denoising_strenght, SadMode=1, idx=2).unsharpmask(USM_sharp_ness3,USM_radi_us3,0).sharpen(last_sharp)





#RESULT1: AUTOLEVELS,AUTOWHITE
#.................................................................................................................................................
result1= denoised.coloryuv(autowhite=true).converttoRGB24().autolevels(output_low= autolev_low, output_high= autolev_high).converttoYV12().BlendFPS(final_framerate, frame_blend).blur(last_blur).addborders(bord_left, bord_top, bord_right, bord_bot)

#RESULT2: MANUAL LEVELS, AUTOWHITE
#.................................................................................................................................................
result2= denoised.levels(black_level,1.0,white_level,0,255).coloryuv(autowhite=true).BlendFPS(final_framerate, frame_blend).blur(last_blur).addborders(bord_left, bord_top, bord_right, bord_bot)


#RESULT3: AUTOLEVELS, MANUAL COLOR CORRECTIONS
#.................................................................................................................................................
result3= denoised.coloryuv(off_U=blue,off_V=red).converttoRGB24().autolevels(output_low= autolev_low, output_high= autolev_high).converttoYV12().BlendFPS(final_framerate, frame_blend).blur(last_blur).addborders(bord_left, bord_top, bord_right, bord_bot)

#RESULT4: MANUAL LEVELS, MANUAL COLOR CORRECTIONS
#..................................................................................................................................................
result4= denoised.coloryuv(off_U=blue,off_V=red).levels(black_level,1.0,white_level,0,255).BlendFPS(final_framerate, frame_blend).blur(last_blur).addborders(bord_left, bord_top, bord_right, bord_bot)

#RESULT5: SPECIAL SERVICE CLIP FOR RESULT S5
#..................................................................................................................................................
result5= overlay(source1,greyscale(stab_reference),x=est_left,y=est_top).addborders(2,2,2,2,$FFFFFF).Lanczos4Resize(WS,HS)




#PARAMETERS FOR THE COMPARISONS
#..................................................................................................................................................
W2= W+bord_left+bord_right
H2= H+bord_top+bord_bot





source4=Lanczos4Resize(source1,W2,H2).changeFPS(final_framerate)



#COMPARISONS: ORIGINAL VS RESULTS
#......................................................................................................................................................................
resultS1= stackhorizontal(subtitle(source4,"original",size=28,align=2),subtitle(result1,"result1: autolevels, autowhite",size=28,align=2))
resultS2= stackhorizontal(subtitle(source4,"original",size=28,align=2),subtitle(result2,"result2: autowhite, manual levels correction",size=28,align=2))
resultS3= stackhorizontal(subtitle(source4,"original",size=28,align=2),subtitle(result3,"result3: autolevels, manual color correction",size=28,align=2))
resultS4= stackhorizontal(subtitle(source4,"original",size=28,align=2),subtitle(result4,"result4: manual colors and levels correction",size=28,align=2))
resultS5= stackhorizontal(subtitle(result3,"result3: auto levels, manual color correction",size=28,align=2),subtitle(result4,"result4: manual colors and levels correction",size=28,align=2))
resultS6= stackhorizontal(subtitle(result1,"result1: autolevels, autowhite",size=28,align=2),subtitle(result2,"result2: manual levels, autowhite",size=28,align=2))

#SPECIAL COMPARISON CLIP FOR TESTING THE STABILIZER
#.........................................................................................................................................................................
resultS7= stackhorizontal(subtitle(result5,"baseclip for stabiliser -only the B/W clip is used",size=32,align=2),subtitle(stab4,"test stabiliser: dx=horizontal, dy=vertical",size=32,align=5)).converttoYUY2()



Eval(result)
while if I use John's script the export time is around the hour, is it normal? or am I wrong something?

Thanks for help

Code in the nex post

Last edited by MIGLIO74; 15th November 2020 at 18:53. Reason: wrong link
MIGLIO74 is offline   Reply With Quote
Old 15th November 2020, 18:51   #15  |  Link
MIGLIO74
Registered User
 
Join Date: Nov 2018
Posts: 14
here the John's script

Code:
#VIDEO FILE
#----------------------------------------------------------------------------------------------------------------------------
#Change the following line to point to your video file
film="E:\EXPORT_PREMIERE\SUPER8\xmas okanogan 1975\XMAS 1975 OKANOGAN_xvdb980.avi"


#GENERAL PARAMETERS
#----------------------------------------------------------------------------------------------------------------------------
result="result1"        #specify the wanted output here; valid results are "result1" through "result4" and "resultS1" through "resultS4" for before/after
trim_begin=20 trim_end=10 play_speed=18	 #play speed (8mm=16; Super8=18;)


#COLOR AND LEVELS PARAMATERS
#----------------------------------------------------------------------------------------------------------------------------
saturation = 1.0                                  #for all outputs
gamma      = 1.0                                  #for all outputs 

#GamMac Parameters
LockChan   = 1                                     #(0=red channel)
LockVal    = 128.0                                 #default 128 -- Used when LockChan = -1 (for flicker)
Scale      = 2                                     #Fred recommended 2 instead of 1
RedMul     = 1.0
GrnMul     = 1.0
BluMul     = 1.0
Th         = 0.1
GMx        = 0
GMy        = 0
GMw        = 0
GMh        = 0
LOTH = 0.2
HITH = 0.2
OMIN =   0                                         #limiting the output a little bit makes it a little 'softer' to look at
OMAX = 255
Al2  =  20
autolev_bord1 = 50
borderV=10 borderH=10    

#SIZE, CROP AND BORDERS PARAMETERS
#----------------------------------------------------------------------------------------------------------------------------
CLeft=8  CTop=8  CRight=8  CBottom=8                             #crop values after Depan and before final resizing 
W=1470  H=1080                                                     #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=10                                                      #maximum values for the stabiliser (in pixels) 20 is a good start value 
maxstabV=10
est_left=40  est_top=40  est_right=40  est_bottom=40             #crop and contast values for special Estimate clip
est_cont=1.1                                                     #Too large a value defeats stabilization


#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()

#Alternate denoising using smaller block size
#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()

#Alternate denoising using smallest block size
denoising_strength= 300                   #denoising level of first denoiser: MDegrain() 
block_size=   4                           #block size of MVDegrain
block_size_v= 4
block_over=   2                           #block overlapping of MVDegrainMulti()

dirt_strength=25                           #sets amount of dirt removal (big spots)


#FOUR STEP SHARPENING PARAMETERS
#--------------------------------------------------------------------------------------------------------------------------------
#120 is pretty aggressive; 85 seems more subtle
#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
PRE_sharp_ness= 105    PRE_radi_us= 3            #presharpening (UnsharpMask) just after first denoising

Sharp_Strength = 0.1                             #0.05 is often better (avoids too much sharpening)


#AUTO LEVELS PARAMETER
#--------------------------------------------------------------------------------------------------------------------------------
X=4   #X  parameter for reducing the autolevels effect on the whites
X2=4  #X2 parameter for reducing the autolevels effect on the blacks 


#NUMBER OF THREADS
#--------------------------------------------------------------------------------------------------------------------------------
threads=4


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

#Memory Settings Sets the maximum memory that AviSynth uses (in MB) to the value of amount. 
SetMemoryMax(1024)

/*In the 2.5 series the default Memory Max value is 25% of the free physical memory, with a minimum of 16MB.
#The default Memory Max is also limited to 512MB.
#Too high values can result in crashes because of 2GB address space limit
*/


#Load plugins explicitly
LoadPlugin("C:\Program Files\AviSynth+\plugins+\ffms2.dll")
LoadPlugin("C:\Program Files\AviSynth+\plugins+\mvtools2.dll")         #Version 2.5.11.9    2/24/2012
LoadPlugin("C:\Program Files\AviSynth+\plugins+\Deflicker.dll")        #Version 0.4.0.0     8/16/2004
Loadplugin("C:\Program Files\AviSynth+\plugins+\DePan.dll")            #Version 1.10.0.0    4/09/2007
LoadPlugin("C:\Program Files\AviSynth+\plugins+\DePanEstimate.dll")    #Version 1.9.2.0     3/25/2007
LoadPlugin("C:\Program Files\AviSynth+\plugins+\fft3dfilter.dll")      #Version 2.1.1.0     2/20/2007
Loadplugin("C:\Program Files\AviSynth+\plugins+\masktools2.dll")     #Version 2.0.23.0    3/14/2008
Loadplugin("C:\Program Files\AviSynth+\plugins+\RemoveDirt.dll")   #Version 0.9         5/05/2005    
Loadplugin("C:\Program Files\AviSynth+\plugins+\RgTools.dll")  #Version 0.9         5/05/2005
Loadplugin("C:\Program Files\AviSynth+\plugins+\warpsharp.dll")        #                    4/05/2010
Loadplugin("C:\Program Files\AviSynth+\plugins+\FredAverage_x86.dll")  #Version 0.3.0.0     01/19/2019
Loadplugin("C:\Program Files\AviSynth+\plugins+\GamMac_x86.dll")  	    #Version 1.10.0.0    06/15/2018


#Use the following to open with FFVideo using ffm2 plugin
#source1= FFVideoSource(film).killaudio().assumefps(play_speed).converttoYV12()

#Use the following to open with Avisource()
#source1= Avisource(film).killaudio().assumefps(play_speed).converttoYV12()


#Open & using the Clip Trim Options
source= FFVideoSource(film).killaudio().assumefps(play_speed).trim(trim_begin,0).converttoYV12()
trimming= framecount(source)-trim_end
source1= trim(source,0,trimming)

cropped_source=source1.crop(in_bord_left,in_bord_top,-in_bord_right,-in_bord_bot)               #remove any black borders on input video

#cropped_source=filldrops(cropped_source)     #Use this when removing bad frames that have been removed by duplicating previous frame


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

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

  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)


#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)
#...................................................................................................................................................................
#Everything in this section is commented out because I usually choose NOT to do frame interpolation because 
#it causes too many unexpected artifacts on certain frames. It also makes the film look like video which
#aesthetically is not always pleasing.

/*
prefiltered = RemoveGrain(PreBorderFrame,2)
super = MSuper(PreBorderFrame,hpad=16, vpad=16, levels=1) # one level is enough for MRecalculate
superfilt = MSuper(prefiltered, hpad=16, vpad=16) # all levels for MAnalyse
backward = MAnalyse(superfilt, isb = true, blksize=16,overlap=8,search=3,dct=0)
forward = MAnalyse(superfilt, isb = false, blksize=16,overlap=8,search=3,dct=0)
forward_re = MRecalculate(super, forward, blksize=8, thSAD=100)
backward_re = MRecalculate(super, backward, blksize=8, thSAD=100)
PreBorderFrame = MFlowFps(PreBorderFrame,super, backward_re, forward_re, num=30000, den=1001,ml=200,mask=2)
*/

#Alternative interpolation
/*
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()
*/

#Yet another way to do interpolation
#The following alternative can provide synthesized frames for hi-def material that causes MSuper to choke
#////// Begin alternative to MFlowFPS ////
#SmoothFPS2(PreBorderFrame,threads)
#////// End alternative to MFlowFPS ////

#A final way to do interpolation, although Interframe is just a front-end to SmoothFPS, so I don't think the results are any different.
#The following is another alternative that can provide synthesized frames for hi-def material that causes MSuper to choke. Probably better than the one above.
#////// Begin alternative to MFlowFPS ////
#PreBorderFrame=InterFrame(NewNum=30000,NewDen=1001,PreBorderFrame,GPU=true,Cores=threads)
#////// End alternative to MFlowFPS ////

#RESULT1: AUTOLEVELS,AUTOWHITE
#......................................................................................................................................................................

Baseclip = PreBorderFrame.crop(borderV,borderH,-borderV,-borderH,align=true).bicubicresize(W,H)
blank_black = Blankclip(baseclip, width=autolev_bord1,height=autolev_bord1)
blank_white=  Blankclip(baseclip, width=autolev_bord1,height=autolev_bord1, color=$FFFFFF)
Average= baseclip.FredAverage().invert()
over1 = overlay(baseclip,blank_black, x=40,y=300) 
over2 = overlay (over1,blank_white, x=160, y=300) \
        .bicubicresize(width(baseclip)-(al2)*2,height(baseclip)-(al2)*2)
Detect = (al2 >1) ? overlay (Average, over2,x=al2,y=al2) \
         .converttoRGB24(matrix="rec709") : over2.converttoRGB24(matrix="rec709")

result1= PreBorderFrame.ConvertToRGB24.GamMac(verbosity=4,DC=Detect,Show=False, \
         LockChan=LockChan, Th=Th, LockVal=LockVal, Scale=Scale, RedMul=RedMul,\
         GrnMul=GrnMul, BluMul=BluMul, loTh=LOTH,hiTh=HITH,oMin=OMIN,oMax=OMAX,\
         x=GMx,y=GMy,w=GMw,h=GMh).converttoYV12().deflicker().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)

#RESULT2: AUTOWHITE
#......................................................................................................................................................................
result2= PreBorderFrame.ConvertToRGB24.GamMac(DC=Detect,Show=False, Dither=TRUE,verbosity=5,LockChan=LockChan, \
         Th=Th, LockVal=LockVal, Scale=Scale, RedMul=RedMul, GrnMul=GrnMul, BluMul=BluMul, \
         loTh=LOTH,hiTh=HITH,oMin=OMIN,oMax=OMAX,x=GMx,y=GMy,w=GMw,h=GMh).converttoYV12() \
         .deflicker().addborders(bord_left+in_bord_left, bord_top+in_bord_top, \
         bord_right+in_bord_right, bord_bot+in_bord_bot)

#RESULT3: AUTOLEVELS
#.....................................................................................................................................................................
result3= PreBorderFrame.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)

#RESULT4: NO CORRECTIONS
#.....................................................................................................................................................................
result4= PreBorderFrame.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)

Last edited by MIGLIO74; 15th November 2020 at 18:53. Reason: wrong code
MIGLIO74 is offline   Reply With Quote
Old 15th November 2020, 18:51   #16  |  Link
MIGLIO74
Registered User
 
Join Date: Nov 2018
Posts: 14
Code:
#COMPARISONS: ORIGINAL VS RESULTS
#......................................................................................................................................................................
resultS1= stackhorizontal(subtitle(source4,"original",size=28,align=2),subtitle(result1,"autolevels, GamMac",size=28,align=2))
resultS2= stackhorizontal(subtitle(source4,"original",size=28,align=2),subtitle(result2,"GamMac",size=28,align=2))
resultS3= stackhorizontal(subtitle(source4,"original",size=28,align=2),subtitle(result3,"autolevels",size=28,align=2))
resultS4= stackhorizontal(subtitle(source4,"original",size=28,align=2),subtitle(result4,"no level or color corrections",size=28,align=2))

Eval(result)
#return Detect
# Enable MT! with #Prefetch(No of threads)

Prefetch(threads)


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

# Alternative way to do pre-filtering.
#  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=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(forw,clip,backw)
  clp=clp.RemoveDirt(limit,_grey)
  clp=clp.SelectEvery(3,1)
  return clp
}
MIGLIO74 is offline   Reply With Quote
Old 15th November 2020, 22:24   #17  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
For Super 8 and 8mm, you don't need to save at such high resolution. To convince yourself, try saving at 656x480 (square pixel) or 720x480 (0.9091 PAR) and compare 15-20 seconds of that with your higher resolution result. Zoom in and see if you can resolve details in one that you cannot resolve in the other. Remember, you are trying to resolve details and therefore should ignore the additional pixelization you will get at a lower resolution.

Fred has posted about this as well, and his recommendation has always been the same: you don't need HD resolutions when scanning 8mm or Super 8.

The lower resolutions will result in 4-10 times faster performance with these scripts. I generally get about 8-14 fps (depending on options enabled) on my 13-year-old Intel i7 computer running Windows XP.
johnmeyer is offline   Reply With Quote
Old 16th November 2020, 12:07   #18  |  Link
MIGLIO74
Registered User
 
Join Date: Nov 2018
Posts: 14
Quote:
Originally Posted by johnmeyer View Post
For Super 8 and 8mm, you don't need to save at such high resolution. To convince yourself, try saving at 656x480 (square pixel) or 720x480 (0.9091 PAR) and compare 15-20 seconds of that with your higher resolution result. Zoom in and see if you can resolve details in one that you cannot resolve in the other. Remember, you are trying to resolve details and therefore should ignore the additional pixelization you will get at a lower resolution.

Fred has posted about this as well, and his recommendation has always been the same: you don't need HD resolutions when scanning 8mm or Super 8.

The lower resolutions will result in 4-10 times faster performance with these scripts. I generally get about 8-14 fps (depending on options enabled) on my 13-year-old Intel i7 computer running Windows XP.
Many thanks John now is perfect!

How can I insert this function of Fred's script into yours?

Code:
final_framerate = 25  # final frame rate

Last edited by MIGLIO74; 16th November 2020 at 12:07. Reason: wrong question
MIGLIO74 is offline   Reply With Quote
Old 16th November 2020, 15:03   #19  |  Link
MIGLIO74
Registered User
 
Join Date: Nov 2018
Posts: 14
I also noticed that after stabilization vertical lines are formed (I enclose image) https://imgur.com/WXbJVoi and in that precise frame the color correction is lost.
Any suggestions?

thanks
MIGLIO74 is offline   Reply With Quote
Old 16th November 2020, 17:44   #20  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
Transfers of 8mm film to SD resolution results in black bars. Transfer of Super 8 film to standard SD resolution should fit almost perfectly, with no bars.

Transfers of any gauge (8mm, Super 8, 16mm) to standard HD resolution (1920x1080 or 1280x720) will always result in black bars on the side.

So, when you have those black bars, you must remove them prior to doing stabilization because otherwise, as the frame gets shifted back and forth (and up and down) to achieve stability, those black border will wander into the final, stabilized frame and you will get vertical lines and bars.

(You never want to have any black borders around the frame when doing video stabilization).

I realized this early on, and one thing I added to Fred's script was this line of new variables:
Code:
in_bord_left=0  in_bord_top=0  in_bord_right=0  in_bord_bot=0
The "right" and "left" variables are the only ones you need to set. This represents the width of the left and right border that must be temporarily removed before you stabilize the video, but then must be added back in to give you the black bars which are needed in order to display correctly at a standard 720x480 (NTSC DVD) resolution. You will see this variable is used in the script twice: first to crop the video prior to stabilization, and then later to "add_borders" to bring the video back to a standard resolution.

The numbers you use must be mod4 (multiple of 4) and because of a bug that I never tracked down, I was never able to get this to work reliably if the left and right borders don't match. That's too bad because with 8mm transfers in my transfer machine, one border is almost always much larger than the other.

I don't know what final_framerate is. My script uses the variable "play_speed" to set the final playback speed.
johnmeyer is offline   Reply With Quote
Reply

Tags
avisynth, film, restoring, scripts, super8

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 22:23.


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