Log in

View Full Version : The power of Avisynth: restoring old 8mm films.


Pages : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 [15] 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Jenyok
20th March 2013, 06:36
There are some questions to you.
.
There is a function RemoveGrain(mode=17) .
.
Could I use function FFT3dFilter(...) instead of function RemoveGrain(mode=17) to achive equal result of function RemoveGrain(mode=17) (result FF3dFilter(...) = result RemoveGrain(mode=17)) ?
Which parameters and values of those parameters could I use in function FFT3dFilter(...) to achive this result ?
.
.
There are another similar questions.
.
There is a function RemoveGrain(mode=1) .
There is a function RemoveGrain(mode=2) .
There is a function RemoveGrain(mode=3) .
There is a function RemoveGrain(mode=5) .
.
result FF3dFilter( ??? ) = result RemoveGrain(mode=1) ?
Parameters and values of those parameters to function FFT3dFiler() in this case ?
.
result FF3dFilter( ??? ) = result RemoveGrain(mode=2) ?
Parameters and values of those parameters to function FFT3dFiler() in this case ?
.
result FF3dFilter( ??? ) = result RemoveGrain(mode=3) ?
Parameters and values of those parameters to function FFT3dFiler() in this case ?
.
result FF3dFilter( ??? ) = result RemoveGrain(mode=5) ?
Parameters and values of those parameters to function FFT3dFiler() in this case ?
.
FFT3dFilter( ??? ) similar to and another "mode=" of RemoveGrain() function ?
mode=7
mode=9
mode=11
mode=19
.
Thanks.
.

egekhter
21st March 2013, 20:00
Does anybody know how to preserve 4:2:2 color space through a modification of the script? I capture film in 4:2:2 and the script's functions have to convert the video file to 4:2:0 in order to work with the plugins, so just wondering what would be involved in getting updated plugins that work with 4:2:2 (or 4:4:4).

johnmeyer
22nd March 2013, 00:06
Does anybody know how to preserve 4:2:2 color space through a modification of the script? I capture film in 4:2:2 and the script's functions have to convert the video file to 4:2:0 in order to work with the plugins, so just wondering what would be involved in getting updated plugins that work with 4:2:2 (or 4:4:4).I sent over half a dozen private emails to you on this subject. As I said in those emails, you can replace the YV12 with YUY2 conversions. After I sent my script, which I tested, you then had problems making it work with plugins on your system. It worked fine on my computer with the plugins I use, so I think you can get it working. I provided the exact version of those plugins in my version of the film restoration script that I posted here:

Capturing and restoring old 8mm films (http://forum.doom9.org/showthread.php?p=1595608#post1595608)

So, I have provided the answer, and if you use my version of the script, I'm pretty sure you can get it to work.

I also should mention that your film capture setup will have to be extraordinarily good in order to tell the difference. This is because there are so many other, much more diabolical, color issues when transferring from various film emulsions into video. You almost always have to do extensive gamma and color correction, and the issues surrounding those conversions will swamp whatever slight color fidelity increase you get from maintaining 4:2:2 throughout.

Jenyok
22nd March 2013, 04:56
Thera are some ConvertFPS() functions...
Begin...
.

#
# File: ConvertFPS.avsi
#
# various functions to convert FPS
#
#
# Last editing date: 20.03.2013 year
#
#
#
# function ConvertMFlowFPSOriginal(clip clp, int "numerator", int "denominator")
# function ConvertMFlowFPS(clip clp, int "numerator", int "denominator")
# function ConvertMFlowFPS2(clip clp, int "numerator", int "denominator")
# function ConvertMFlowFPS3(clip clp, int "numerator", int "denominator")
# function ConvertSmoothFPS2(clip clp, int "numerator", int "denominator")
# function pelclipfix(Clip clp)
#
#




LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\MVTOOLS-V2_5_11_3\mvtools2.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\REMOVEGRAIN-1_0\removegrain.dll")
#LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\EEDI3\eedi3.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\NNEDI3\nnedi3.dll")





#
# ConvertMFlowFPSOriginal() Original function ...
#
function ConvertMFlowFPSOriginal(clip clp, int "numerator", int "denominator")
{
# Defaults
#
numerator = Default(numerator, 2)
denominator = Default(denominator, 1)

# Here is code of function...
#
last = clp

fps_super = MSuper(last, hpad=8, vpad=8, rfilter=4)
fps_backward = MAnalyse(fps_super, isb=true, blksize=16, overlap=4, search=5, searchparam=3, dct=5)
fps_forward = MAnalyse(fps_super, isb=false, blksize=16, overlap=4, search=5, searchparam=3, dct=5)
fps_backward1 = MRecalculate(fps_super, fps_backward, blksize=8, overlap=2, search=3, searchparam=1, dct=5)
fps_forward1 = MRecalculate(fps_super, fps_forward, blksize=8, overlap=2, search=3, searchparam=1, dct=5)

return (MFlowFps(fps_super, fps_backward1, fps_forward1, \
num=FramerateNumerator(last) * numerator, \
den=FramerateDenominator(last) * denominator, \
mask=2, ml=10000))
}



#
# ConvertMFlowFps() function...
#
function ConvertMFlowFPS(clip clp, int "numerator", int "denominator")
{
# Constants
# Change those constants to tune for the best result of interpolation

# Constant
# MSuper()
#
hpad = 8 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
vpad = 8 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
pel = 2 # default=2 !changed 4 -> 2
sharp = 2 # default=2 !!!
rfilter = 4 # default=2

# Constant
# MAnalyse()
#
blkh = 16 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
blkv = 8 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
overlap = 4 # Maybe 2, 4, 8, 16, !!! maybe blkh/2 or litle !!! Change this constant for best tuning !!!
overlapV = 2 # Maybe 2, 4, 8, 16, !!! maybe blkv/2 or litle !!! Change this constant for best tuning !!!
search = 5 # default=4
searchparam = 3 # default=2
dct = 5 # default=0
plevel = 2 # default=0
truemotion = false # default=true
badrange = (-24) # default=24
lambda = 100 * blkh * blkv / 64
lsad = 400 * blkh * blkv / 64

# Constant
# MRecalculate()
#
blkhR = 8 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
blkvR = 8 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
overlapR = 2 # Maybe 2, 4, 8, 16, !!! maybe blkhR/2 or litle !!! Change this constant for best tuning !!!
overlapVR = 2 # Maybe 2, 4, 8, 16, !!! maybe blkvR/2 or litle !!! Change this constant for best tuning !!!
searchR = 3 # default=4
searchparamR = 1 # default=2
lambdaR = 100 * blkhR * blkvR / 64

# Constant
# MFlowFps()
#
isse = true
thSCD1 = 320 # 300, 1500, 100, default=400
thSCD2 = 128 # 128, 130, 130, default=130

# Contour artifacts suppression / Подавление контурных артефактов
# Simple masking / Простое маскирование (mask = 0)
# Simple masking + Static vectors / Простое + Статические вектора (mask = 1)
# Simple masking + Vectors of related frames / Простое + Вектора смежных кадров (mask = 2)
#
mask = 2

# Artifact suppression level / Степень подавления артефактов
# Light / Легкая (ml = 100)
# Medium / Средняя (ml = 500)
# High / Высокая (ml = 2500)
# Huge / Нереальная (ml = 10000)
#
ml = 10000


# Defaults
#
numerator = Default(numerator, 2)
denominator = Default(denominator, 1)


# Here is code of function...
#
last = clp

pelclip = pelclipfix(last)
fps_super = MSuper(last, hpad=hpad, vpad=vpad, rfilter=rfilter, pel=pel, sharp=sharp, pelclip=pelclip)
fps_backward = MAnalyse(fps_super, isb=true, blksize=blkh, blksizeV=blkv, overlap=overlap, overlapV=overlapV, \
search=search, searchparam=searchparam, dct=dct, truemotion=truemotion, \
lambda=lambda, lsad=lsad, plevel=plevel, badrange=badrange)
fps_forward = MAnalyse(fps_super, isb=false, blksize=blkh, blksizeV=blkv, overlap=overlap, overlapV=overlapV, \
search=search, searchparam=searchparam, dct=dct, truemotion=truemotion, \
lambda=lambda, lsad=lsad, plevel=plevel, badrange=badrange)

fps_backward1 = MRecalculate(fps_super, fps_backward, blksize=blkhR, blksizeV=blkvR, overlap=overlapR, overlapV=overlapVR, \
search=searchR, searchparam=searchparamR, dct=dct, truemotion=truemotion, lambda=lambdaR)
fps_forward1 = MRecalculate(fps_super, fps_forward, blksize=blkhR, blksizeV=blkvR, overlap=overlapR, overlapV=overlapVR, \
search=searchR, searchparam=searchparamR, dct=dct, truemotion=truemotion, lambda=lambdaR)

# function MFlowFPS(clip source, clip super, clip mvbw, clip mvfw, int "num", int "den", int "mask", \
# float "ml", bool "blend", int "thSCD1", int "thSCD2", bool "isse", bool "planar")
#
return (MFlowFps(fps_super, \
fps_backward1, \
fps_forward1, \
num = FramerateNumerator(last) * numerator, \
den = FramerateDenominator(last) * denominator, \
mask = mask, \
ml = ml, \
blend = true, \
thSCD1 = thSCD1, \
thSCD2 = thSCD2, \
isse = isse, \
planar = false))
}



#
# ConvertMFlowFps2() function...
# There are Four (4) MRecalculate function.
#
function ConvertMFlowFPS2(clip clp, int "numerator", int "denominator")
{
# Constants
# Change those constants to tune for the best result of interpolation

# Constant
# MSuper()
#
hpad = 8 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
vpad = 8 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
pel = 2 # default=2, !changed 4 -> 2
sharp = 2 # default=2 !!!
rfilter = 4 # default=2

# Constant
# MAnalyse()
#
blkh = 16 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
blkv = 16 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
overlap = 8 # Maybe 2, 4, 8, 16, !!! maybe blkh/2 or litle !!! Change this constant for best tuning !!!
overlapV = 8 # Maybe 2, 4, 8, 16, !!! maybe blkv/2 or litle !!! Change this constant for best tuning !!!
search = 3 # default=4
searchparam = 3 # default=2
dct = 10 # default=0
plevel = 0 # default=0
truemotion = true # default=true
badrange = (-24) # default=24
lambda = 100 * blkh * blkv / 64
lsad = 400 * blkh * blkv / 64

# Constant
# MRecalculate()
#
blkhR = 8 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
blkvR = 8 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
blkhR2 = 4 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
blkvR2 = 4 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
overlapR = 4 # Maybe 2, 4, 8, 16, !!! maybe blkhR/2 or litle !!! Change this constant for best tuning !!!
overlapVR = 4 # Maybe 2, 4, 8, 16, !!! maybe blkvR/2 or litle !!! Change this constant for best tuning !!!
overlapR2 = 2 # Maybe 2, 4, 8, 16, !!! maybe blkhR/2 or litle !!! Change this constant for best tuning !!!
overlapVR2 = 2 # Maybe 2, 4, 8, 16, !!! maybe blkvR/2 or litle !!! Change this constant for best tuning !!!
searchR = 3 # default=4
searchparamR = 1 # default=2
dctR = 0 # default=0
lambdaR = 100 * blkhR * blkvR / 64

# Constant
# MFlowFps()
#
isse = true
thSCD1 = 320 # 300, 1500, 100, default=400
thSCD2 = 128 # 128, 130, 130, default=130

# Contour artifacts suppression / Подавление контурных артефактов
# Simple masking / Простое маскирование (mask = 0)
# Simple masking + Static vectors / Простое + Статические вектора (mask = 1)
# Simple masking + Vectors of related frames / Простое + Вектора смежных кадров (mask = 2)
#
mask = 2

# Artifact suppression level / Степень подавления артефактов
# Light / Легкая (ml = 100)
# Medium / Средняя (ml = 500)
# High / Высокая (ml = 2500)
# Huge / Нереальная (ml = 10000)
#
ml = 10000


# Defaults
#
numerator = Default(numerator, 2)
denominator = Default(denominator, 1)


# Here is code of function...
#
last = clp

# filt = RemoveGrain(mode=3)
filt = RemoveGrain(mode=17)
pelclip = pelclipfix(last)
fps_super = MSuper(last, hpad=hpad, vpad=vpad, rfilter=rfilter, pel=pel, sharp=sharp)
fps_super_f = MSuper(filt, hpad=hpad, vpad=vpad, rfilter=rfilter, pel=pel, sharp=sharp, pelclip=pelclip)
fps_backward = MAnalyse(fps_super_f, isb=true, blksize=blkh, blksizeV=blkv, overlap=overlap, overlapV=overlapV, \
search=search, searchparam=searchparam, dct=dct, truemotion=truemotion, \
lambda=lambda, lsad=lsad, plevel=plevel, badrange=badrange)
fps_forward = MAnalyse(fps_super_f, isb=false, blksize=blkh, blksizeV=blkv, overlap=overlap, overlapV=overlapV, \
search=search, searchparam=searchparam, dct=dct, truemotion=truemotion, \
lambda=lambda, lsad=lsad, plevel=plevel, badrange=badrange)

fps_backward1 = MRecalculate(fps_super, fps_backward, blksize=blkhR, blksizeV=blkvR, overlap=overlapR, overlapV=overlapVR, \
search=searchR, searchparam=searchparamR, dct=dctR, truemotion=truemotion, lambda=lambdaR)
fps_forward1 = MRecalculate(fps_super, fps_forward, blksize=blkhR, blksizeV=blkvR, overlap=overlapR, overlapV=overlapVR, \
search=searchR, searchparam=searchparamR, dct=dctR, truemotion=truemotion, lambda=lambdaR)

fps_backward2 = MRecalculate(fps_super, fps_backward1, blksize=blkhR2, blksizeV=blkvR2, overlap=overlapR2, overlapV=overlapVR2, \
search=searchR, searchparam=searchparamR, dct=dctR, truemotion=truemotion, lambda=lambdaR)
fps_forward2 = MRecalculate(fps_super, fps_forward1, blksize=blkhR2, blksizeV=blkvR2, overlap=overlapR2, overlapV=overlapVR2, \
search=searchR, searchparam=searchparamR, dct=dctR, truemotion=truemotion, lambda=lambdaR)

# function MFlowFPS(clip source, clip super, clip mvbw, clip mvfw, int "num", int "den", int "mask", \
# float "ml", bool "blend", int "thSCD1", int "thSCD2", bool "isse", bool "planar")
#
return (MFlowFps(fps_super, \
fps_backward2, \
fps_forward2, \
num = FramerateNumerator(last) * numerator, \
den = FramerateDenominator(last) * denominator, \
mask = mask, \
ml = ml, \
blend = false, \
thSCD1 = thSCD1, \
thSCD2 = thSCD2, \
isse = isse, \
planar = false))
}

Jenyok
22nd March 2013, 04:57
Thera are some ConvertFPS() functions...
End...
.

#
# ConvertMFlowFps3() easy function ...
# There are no MRecalculate functions.
#
function ConvertMFlowFPS3(clip clp, int "numerator", int "denominator")
{
# Constants
# MSuper()
#
hpad = 16 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
vpad = 8 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
pel = 2 # default=2

# Constants
# MSuper()
#
blkh = 16 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
blkv = 8 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
overlap = 4 # Maybe 2, 4, 8, 16, !!! maybe blkh/2 or litle !!! Change this constant for best tuning !!!
overlapV = 2 # Maybe 2, 4, 8, 16, !!! maybe blkv/2 or litle !!! Change this constant for best tuning !!!
searchparam = 1 # default=2
plevel = 2 # default=0

# Constants
# MFlowFps()
#
# Contour artifacts suppression / Подавление контурных артефактов
# Simple masking / Простое маскирование (mask = 0)
# Simple masking + Static vectors / Простое + Статические вектора (mask = 1)
# Simple masking + Vectors of related frames / Простое + Вектора смежных кадров (mask = 2)
#
mask = 2

# Artifact suppression level / Степень подавления артефактов
# Light / Легкая (ml = 100)
# Medium / Средняя (ml = 500)
# High / Высокая (ml = 2500)
# Huge / Нереальная (ml = 10000)
#
ml = 10000


# Defaults
#
numerator = Default(numerator, 2)
denominator = Default(denominator, 1)


# Here is code of function...
#
last = clp

pelclip = pelclipfix(last)
super = MSuper(last, pel=pel, hpad=hpad, vpad=vpad, pelclip=pelclip)
backward1 = MAnalyse(super, isb=true, blksize=blkh, blksizeV=blkv, overlap=overlap, overlapV=overlapV, \
searchparam=searchparam, plevel=plevel)
forward1 = MAnalyse(super, isb=false, blksize=blkh, blksizeV=blkv, overlap=overlap, overlapV=overlapV, \
searchparam=searchparam, plevel=plevel)

return (MFlowFps(super, backward1, forward1, \
num=FramerateNumerator(last) * numerator, \
den=FramerateDenominator(last) * denominator, \
mask=mask, ml=ml))
}



#
# ConvertSmoothFPS2() function...
# Using MBlockFps function.
#
function ConvertSmoothFPS2(clip clp, int "numerator", int "denominator")
{
# Constants
# MSuper()
#
hpad = 0 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
vpad = 0 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
pel = 2 # default=2
rfilter = 4 # default=2

# Constant
# MAnalyse()
#
blkh = 16 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
search = 3 # default=4
searchparam = 3 # default=2
dct = 5 # default=0
plevel = 0 # default=0
badrange = (-24) # default=24
chroma = false # default=true

# Constant
# MRecalculate()
#
blkhR = 8 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
blkhR2 = 4 # Maybe 4, 8, 16, 32, !!! Change this constant for best tuning !!!
searchR = 3 # default=4
searchparamR = 1 # default=2
searchparamR2 = 0 # default=2
dctR = 5 # default=0



# Defaults
#
numerator = Default(numerator, 2)
denominator = Default(denominator, 1)


# Here is code of function...
#
last = clp

pelclip = pelclipfix(last)
super = MSuper(last, pel=pel, hpad=hpad, vpad=vpad, rfilter=rfilter, pelclip=pelclip)
backward1 = MAnalyse(super, chroma=chroma, isb=true, blksize=blkh, searchparam=searchparam, plevel=plevel, \
search=search, badrange=badrange, dct=dct)
forward1 = MAnalyse(super, chroma=chroma, isb=false, blksize=blkh, searchparam=searchparam, plevel=plevel, \
search=search, badrange=badrange, dct=dct)

backward2 = MRecalculate(super, chroma=chroma, backward1, blksize=blkhR, searchparam=searchparamR, search=searchR, dct=dctR)
forward2 = MRecalculate(super, chroma=chroma, forward1, blksize=blkhR, searchparam=searchparamR, search=searchR, dct=dctR)
backward3 = MRecalculate(super, chroma=chroma, backward2, blksize=blkhR2, searchparam=searchparamR2, search=searchR, dct=dctR)
forward3 = MRecalculate(super, chroma=chroma, forward2, blksize=blkhR2, searchparam=searchparamR2, search=searchR, dct=dctR)

return (MBlockFps(last, super, backward3, forward3, \
num=FramerateNumerator(last) * numerator, \
den=FramerateDenominator(last) * denominator, \
mode=0))
}



#
# pelclipfix() function...
#
function pelclipfix(Clip clp)
{
# Original
#
# luma = EEDI3(clp, field=1).Spline64Resize(2 * width(clp), 2 * height(clp), src_left=0.25)
# chroma = EEDI3(clp, field=1).Spline64Resize(2 * width(clp), 2 * height(clp), src_left=0.50, src_top=0.50)

# Modified
#
luma = NNEDI3(clp, 1, true, nsize=0, nns=0).Spline64Resize(2 * width(clp), 2 * height(clp), src_left=0.25)
chroma = NNEDI3(clp, 1, true, nsize=0, nns=0).Spline64Resize(2 * width(clp), 2 * height(clp), src_left=0.50, src_top=0.50)

return (MergeChroma(luma, chroma, 1))
}

Jenyok
22nd March 2013, 05:13
!!! And one more time !!!
.
.
There are some questions to you.
.
There is a function RemoveGrain(mode=17) .
.
Could I use function FFT3dFilter(...) instead of function RemoveGrain(mode=17) to achive equal result of function RemoveGrain(mode=17) (result FF3dFilter(...) = result RemoveGrain(mode=17)) ?
Which parameters and values of those parameters could I use in function FFT3dFilter(...) to achive this result ?
.
.
There are another similar questions.
.
There is a function RemoveGrain(mode=1) .
There is a function RemoveGrain(mode=2) .
There is a function RemoveGrain(mode=3) .
There is a function RemoveGrain(mode=5) .
.
result FF3dFilter( ??? ) = result RemoveGrain(mode=1) ?
Parameters and values of those parameters to function FFT3dFiler() in this case ?
.
result FF3dFilter( ??? ) = result RemoveGrain(mode=2) ?
Parameters and values of those parameters to function FFT3dFiler() in this case ?
.
result FF3dFilter( ??? ) = result RemoveGrain(mode=3) ?
Parameters and values of those parameters to function FFT3dFiler() in this case ?
.
result FF3dFilter( ??? ) = result RemoveGrain(mode=5) ?
Parameters and values of those parameters to function FFT3dFiler() in this case ?
.
FFT3dFilter( ??? ) similar to and another "mode=" of RemoveGrain() function ?
mode=7
mode=9
mode=11
mode=19
.
Thanks.

egekhter
22nd March 2013, 21:43
I sent over half a dozen private emails to you on this subject. As I said in those emails, you can replace the YV12 with YUY2 conversions. After I sent my script, which I tested, you then had problems making it work with plugins on your system. It worked fine on my computer with the plugins I use, so I think you can get it working. I provided the exact version of those plugins in my version of the film restoration script that I posted here:

Capturing and restoring old 8mm films (http://forum.doom9.org/showthread.php?p=1595608#post1595608)

So, I have provided the answer, and if you use my version of the script, I'm pretty sure you can get it to work.

I also should mention that your film capture setup will have to be extraordinarily good in order to tell the difference. This is because there are so many other, much more diabolical, color issues when transferring from various film emulsions into video. You almost always have to do extensive gamma and color correction, and the issues surrounding those conversions will swamp whatever slight color fidelity increase you get from maintaining 4:2:2 throughout.

I'm having Virtual Dub crash with an out-of-bounds memory access violation when I try to load your script. I've commented out all the SetMT modes and for the time being have not changed the script to converttoYUY2 and am using the default YV12.

Have you tested your script with resolutions of higher than SD?

BTW, we are scanning all footage on a FlashScan HD and capturing at 10 bit 4:2:2.

- Eugene G.

egekhter
23rd March 2013, 00:11
So apparently installing Windows XP 32 bit solved the problem.
Will report back with results! Thanks John!

johnmeyer
23rd March 2013, 02:00
So apparently installing Windows XP 32 bit solved the problem.Ah yes, some plugins don't like 64-bit.


Have you tested your script with resolutions of higher than SD?

Yes I have, and there can be some problems. Someone contacted me last spring. He had captured film in HD, but the scripts were not working. With the help of people in this forum, I tracked it down to a deficiency in MFlowFPS. You can read about it here:

MVTools2 artifacts, but only at high resolution (http://forum.doom9.org/showthread.php?p=1576719#post1576719)

If you read both pages of that thread, you'll see that various people helped me come up with a workaround to the problem.

tonydokter
24th March 2013, 18:31
how do i get rid of the green on right side thanks guys

tonydokter
24th March 2013, 18:39
Sorry love the script works great thanks Fred added pic to show what I mean

johnmeyer
24th March 2013, 21:29
I'm not sure what is causing that, but perhaps it is from the Depan motion stabilization. You could try reducing the maxstabH and maxstabV stabilization parameters to 1/4 of their value, and also cut in half the crop/zoom factors used after motion stabilization (the defaults are: CLeft=32 CTop=32 CRight=32 CBottom=32). I don't know if this will actually fix the problem, but if the nature of the border changes or disappears, then you are on the right track.

If the above changes things, try turning off "mirror" in the Depanstabilize call by setting it to 0 instead of 15.

tonydokter
24th March 2013, 23:33
If I use the script with out remove dirt I do not get the green any ideas thanks John

Guest
24th March 2013, 23:48
My simplistic solution would be to not use RemoveDirt().

johnmeyer
25th March 2013, 02:05
I think there is a joke about a patient telling a doctor that it hurts when he breathes, and the doctor suggests that he simply stop breathing ...

RemoveDirt is pretty critical to the success of the script, although I'm still looking for a more modern solution, and one that would make it easier to understand the relationship between the settings and the results. So far, my various attempts with Despot and a few other plugins have not produced anything close to the remarkable results you get with RemoveDirt. Unfortunately, RemoveDirt can be unstable, and it also can cause things like a football (American football) to disappear when thrown (baseballs also disappear). I can't figure out settings to restrict object size.

Anyway, while I don't have a specific solution to your problem, you might try the newer version of the motion compensation part of the remove dirt chain ("RemoveDirtMC") that I posted several months ago. Here it is again:

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(forw,clip,backw)
clp=clp.RemoveDirt(limit,_grey)
clp=clp.SelectEvery(3,1)
return clp
}

I made these changes to both improve performance, and also to slightly improve the dirt removal quality, but perhaps it will help your situation.

You should be able to simply drop this into the script and see if it works any better. Let us know what happens.

One last thought: I have observed problems like your green flash when the scene detection parameters in the motion estimation are set so that scene detection kicks in too often (i.e., in the middle of a scene). You may need to add a thSCD1 parameter to the MFlow statements and change the scene threshold.

The following should produce identical results to what I posted above (because thSCD1=400 is the default). Make sure this is so, and then try numbers like 100, 200, 600, & 800 to see if this makes any difference. I think there is a more scientific way of determining what value to use, and perhaps someone can tell us how to determine a good threshold value for a particular video clip.

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

Jenyok
25th March 2013, 05:57
There are some functions to convert FPS, gathered togather, lol :) .
Functions are described in code section, see below.
See attached RAR file.
.

#
# File: ConvertFPS.avsi
#
# various functions to convert FPS
#
#
# Last editing date: 25.03.2013 year
#
#
#
# function ConvertMFlowFPSOriginal(clip clp, int "numerator", int "denominator") Using MFlowFps, MRecalculate
# function ConvertMFlowFPS(clip clp, int "numerator", int "denominator") Using MFlowFps, MRecalculate
# function ConvertMFlowFPS2(clip clp, int "numerator", int "denominator") Using MFlowFps, MRecalculate two times (twice)
# function ConvertMFlowFPS3(clip clp, int "numerator", int "denominator") Using MFlowFps, MAnalyse only
# function ConvertSmoothFPS2(clip clp, int "numerator", int "denominator") Using MBlockFps, MRecalculate two times (twice)
#
#
# function pelclipfix(Clip clp) Additional function, create "pelclip"
#
#

Jenyok
25th March 2013, 07:07
Changes in function ConvertMFlowFPS2(...) .
.
Use for YUY2, YV12 color spaces
.
filt = FFT3DFilter(bt=1, sigma=2) # bt=1 2D filter
.
instead of (color space YV12 only)
.
# filt = RemoveGrain(mode=17)
.

videoFred
8th April 2013, 07:20
Sorry love the script works great thanks Fred added pic to show what I mean

Both width and height must be devisible by 16. Please check your source and the crop and resize parameters. The source and all other steps in the script must be checked.

Fred.

tonydokter
30th April 2013, 18:27
Thanks Fred just Got back was away will check that out and see if that gets rid of it a will let u know

stephen22
20th May 2013, 15:58
Any possibility of a version of the script with no trimming cropping stabilising or interpolation? I was very impressed by the improvement in picture quality, but I have some scanned 8mm film which is already expanded to 24fps and stabilised.

With all your interlinked variables I found it quite hard to separate out the unwanted bits. If you've already done this I would very much like a copy.

best wishes
Stephen

thomasmagnum
27th May 2013, 07:21
Hello,

at the moment I working on my old 8mm films. I got the films as picture sequence (every film frame as a jpg). My work flow starts with a small tool called PhotoLapse to create a avi File (msu lossless codec), for the second step I use the scripts from videoFred. This generates amazing results, so I only can say thanks for the scripts. The Problem is that some scenes are longer and I have to handle the 2GB avi Limit, so I had the idea to combine the two steps.

My question is: Can I combine these two steps, so that AviSynth open the jpg's and run videoFreds script in one single step? I am an absolutely AviSynth newbie, so I have not enough background to modify the scripts. May anybody can help me in these question.

Thanks for any hint in advance.

Thomas

videoFred
27th May 2013, 12:24
Hi Thomas,

What you need is ImageSource() . You can replace AviSource() in my script with ImageSource(). Please have a look at the documents for more information about ImageSource().

Fred.

videoFred
27th May 2013, 12:31
Any possibility of a version of the script with no trimming cropping stabilising or interpolation? I was very impressed by the improvement in picture quality, but I have some scanned 8mm film which is already expanded to 24fps and stabilised.

My script will not work properly if there are duplicate frames! If you do not want all the options then you better make a new script with cleaning and denoising only. But, again, both cleaning and denoising will not work if there are duplicate frames.

Fred.

anegroo
9th June 2013, 21:58
Hi,
I have found recently this topic in which I can see amazing results restoring old films. I have problem with a Super 8 material which I want to restore to its original framerate - I don`t know what is... I think it could be 18fps. The only sure is that it was shot in super 8. Now is NTSC encoded as DV and your script doesn`t work for me. Here is a sample video in mp4 (http://www.aspekt.ro/15/media/Super_8.mp4). Somebody can help me please?

fpp
9th June 2013, 22:22
I had a similar problem with Super8 already (badly) transferred to DVD, with a projector running at an unknown speed.

I described a solution that worked for me, in the thread I created about that experience, specifically in post #11:
http://forum.doom9.org/showthread.php?p=1505188#post1505188

HTH,
fp

anegroo
9th June 2013, 23:49
Thanks for the quick reply. I tried this script:
Bob(-.2,.6)
SRestore(frate=18)
I tried different values for Srestore. The result is not bad, but still remains a lot of blended frames. It`s interesting that the source has no duplicate frames, but every 4-5 frame is blended. I have no idea how to change the script for this particular source....

manono
10th June 2013, 02:13
The result is not bad, but still remains a lot of blended frames..
Maybe if you provided a better sample you'd get better suggestions. A man walking so far away that we can't see it clearly doesn't help a whole lot. Please provide a sample with steady movement, one where we can actually make out what goes on frame-by-frame, field-by-field.

Also, this thing went from Super 8 to VHS tape to DV to MP4? If so, why?

anegroo
10th June 2013, 10:58
Thanks for your response. The whole original shot is bad quality. Here (http://www.aspekt.ro/15/media/Super_8B.mp4) is another sample.The video is on a Hi8 cassette from which I captured through firewire to DV avi, and I transcoded for uploading to mp4 for a smaller filesize. I can upload a sample in DV avi if it helps.

manono
10th June 2013, 12:17
Please provide a sample with steady movement...
Another lousy sample. A man just standing there isn't 'steady movement'.

Maybe someone else will try and help. Good luck.

anegroo
10th June 2013, 13:49
Unfortunately there are no better parts in video, mostly the camera is moving. However the blended frames are quite a bit visible.

Because of missing the dulplicate frames I think the original Super 8 film was captured at higher speed (ex. 24fps) and after that was transformed to NTSC through blending every 4-5th frames. What do you think?

anegroo
12th June 2013, 02:24
Finally solved restoring the framerate with Yadif bob and SRestore (23.976) combined with image quality improvement with Film restoring script by videoFred. Thanks for all!

KinoLab
31st July 2013, 17:33
Hi, at the moment I'm working with a transfer that give me a 1624X1234, so now I've two questions:

1 - Can i use the script on WINDOWS 7 64bit ?? Or wich version of WIn is better to install?

2 - Did someone have use so bigframe size with Avisynth ?

Thanks

KinoLab

foxyshadis
31st July 2013, 22:48
Hi, at the moment I'm working with a transfer that give me a 1624X1234, so now I've two questions:

1 - Can i use the script on WINDOWS 7 64bit ?? Or wich version of WIn is better to install?

2 - Did someone have use so bigframe size with Avisynth ?

Thanks

KinoLab

That will be fine. Any Windows from XP to 8 will work. It'll run under a 32-bit environment only, not 64-bit, but that frame size is small enough that it hardly matters. x64 does give you better usage if you have 4GB+ of system memory, but as long as you have at least 2GB of extra memory it'll run fine.

KinoLab
1st August 2013, 20:49
Thanks for your fast answer...
I've installed WIN 7 Ultimate and it working... now I've some problem to open the script becau8se everytime there are some .dll that are missing...
I'm working on.
when IŽll have my first test IŽll post some frames...

Best

EM

KinoLab
3rd August 2013, 02:10
Now I've two questions>
1 did someone had problem with warpsharp.dll ? It's impossible for me to load this plugin..

2 did someone know where i can found a decompressor for fourcc v210?

thanks

KinoLab
3rd August 2013, 15:51
Ok... now I found a solution for both questions...

For the 1ș I've installaed a copi of .dll in system32...

For the second one, you can download all the driver in the www.Aja.com/support in the Kona3 list of driver for WIN...

Now, there is something strange that happen. I'm using a .AVI generated in VirtualDub with Uncompressed RGB. When I open it with the script and I leave resize 720 X 576 everything is ok... but If I change the resize to the original size of the AVI : 1624 X 1234 it crash and said that is impossible to found the decompressor.
And if i open the single .AVI in VirtualDub without the script, it open...

Any idea ???

KinoLab
3rd August 2013, 17:50
Things goes on.... Now I-ve discover that with final crop size I can go up to 1150 for High, and it accept 1624 for Width.
If i put 1151, VD crash....

Any idea??

KinoLab

johnmeyer
3rd August 2013, 21:07
Things goes on.... Now I-ve discover that with final crop size I can go up to 1150 for High, and it accept 1624 for Width.
If i put 1151, VD crash....There are several plugins used in this script that require mod 4 (divisible by 4) numbers for height and width. 1151 is obviously not mod 4.

BTW, this is true of lots of AVISynth plugins so, speaking for myself, I've just gotten into the habit of always using mod 4 heights and widths.

hasso
4th August 2013, 23:35
Thanks for a wonderful script and the results are great for colour 8mm film. I've also got some black and white 8mm films as well. Haven't started on them as yet, but wondering if there are any special considerations when using the script for black and white films.

johnmeyer
5th August 2013, 01:00
Thanks for a wonderful script and the results are great for colour 8mm film. I've also got some black and white 8mm films as well. Haven't started on them as yet, but wondering if there are any special considerations when using the script for black and white films.My work is 50/50 between B&W & color. B&W is sure a lot easier to grade. I do all color and levels grading in my editing program (Vegas) prior to using the script. I generally don't use any of the script's color or level auto adjustments (i.e., I use the "4" option rather than 1, 2, or 3).

Even if you use one of the script's options for automatic grading, you certainly won't need to use the two that provide auto-white balance. Other than that, I can't think of any other tweaks or changes that is specific to B&W.

Here's a link to a five-second clip showing the before/after comparison on a B&W film I'm working on today.

1969 Football B&W Before/After (https://dl.dropboxusercontent.com/u/1561578/Before-After.mp4)

egekhter
20th September 2013, 06:04
Hope this isn't too off-topic.

We are using Canopus HQX as our intermediate codec before and after restoration using Fred's Film Restoration Script.

The codec holds up very well and is a great delivery format too for cross-platform compatibility with PC's and Mac's.

The only problem? There's no decoder for ffmpeg.
To avoid an extra step in the workflow, like writing out to UT Video which is decodable by FFMPeg, we are looking for a new codec that will serve us as well in the chain as Canopus HQX.
What's wrong with some alternatives like UT Video? Nothing - it's a great looking codec - however it's 6x the size of HQX (takes 6x the amount of time to copy to client's hard drive) AND, most importantly, is not trivial to install on a Mac.

So we are looking to go back to the drawing board:
Here are the requirements:
1. Fast Compression/Decompression
2. Reasonable file size (~60GB/hr - granted this doesn't say much, but this is about where HQX and Pro-res HQ lie)
3. 10 bit
4. 4:2:2
5. Intraframe
6. Can be decoded in Video Fred's AVISynth script
7. Can be encoded to in VirtualDub
8. Is decodable in ffmpeg
9. Is cross-platform compatible and is easy to install codec for average client on PC or Mac.
10. (This is on the bucket list) - No codec pack necessary to install for HD footage on client side to playback on PC or Mac.

Is there a single codec that fits the bill for all 9 of the above?

Maybe I'm asking for world peace here, who knows.

Thanks in advance,
Eugene

poisondeathray
20th September 2013, 16:01
egekhter - you're probably looking at prores or dnxhd

egekhter
20th September 2013, 16:17
egekhter - you're probably looking at prores or dnxhd

We actually start with a pro-res file.
I don't think we've been able to import the pro-res file directly into Fred's script (or any AVISynth script for that matter) - we usually transcode it to HQX. And then on the other end, since we're using VirtualDub for batch processing all the scripts, we can only output to an AVI file obviously.

Re: DNxHD...very compute heavy from my experience, and would have same problems as above I imagine.

Thanks for the suggestion.

poisondeathray
20th September 2013, 16:18
We actually start with a pro-res file.
I don't think we've been able to import the pro-res file directly into Fred's script (or any AVISynth script for that matter) - we usually transcode it to HQX. And then on the other end, since we're using VirtualDub for batch processing all the scripts, we can only output to an AVI file obviously.

Re: DNxHD...very compute heavy from my experience, and would have same problems as above I imagine.

Thanks for the suggestion.



You can import prores into avisynth using ffms2 or qtinput

You can use vdub with external encoder feature (you can link to ffmpeg for example, and export prores from vdub - basically anything ffmpeg can do) . There is a guide on the vdub forum

egekhter
20th September 2013, 18:29
You can import prores into avisynth using ffms2 or qtinput

You can use vdub with external encoder feature (you can link to ffmpeg for example, and export prores from vdub - basically anything ffmpeg can do) . There is a guide on the vdub forum

I will check it out for quality and speed.

Thanks for the suggestion!

egekhter
20th September 2013, 21:31
You can import prores into avisynth using ffms2 or qtinput

You can use vdub with external encoder feature (you can link to ffmpeg for example, and export prores from vdub - basically anything ffmpeg can do) . There is a guide on the vdub forum

qtinput does in fact work, but the audio stream is not being recognized. Any suggestions?

Turns out it does work!

source= qtinput(film, audio=1)

Now onto a different problem :-)

egekhter
20th September 2013, 22:26
qtinput does in fact work, but the audio stream is not being recognized. Any suggestions?

Turns out it does work!

source= qtinput(film, audio=1)

Now onto a different problem :-)

Here's my problem if anybody can figure out what in Fred's script is causing this to happen:

Good black:
http://s9.postimg.org/y67wlrzsf/good_black0.jpg


film= "X:\FlashScan HD\Capture\FTC_14799_Hack\14799_Hack-S8mm_3-7-01.mov" # source clip, you must specify the full path here


ffvideosource(film)


Bad black:
http://s9.postimg.org/ni45mxptb/bad_black0.jpg

# 8mm film restoration script by videoFred.
# www.super-8.be
# info@super-8.be
# version 01.A with frame interpolation
# 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= "X:\FlashScan HD\Capture\FTC_14799_Hack\14799_Hack-S8mm_3-7-01.mov" # source clip, you must specify the full path here

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

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

numerator= 30 #numerator for the interpolator (final frame rate)
denumerator= 1 #denumerator example: 60000/1001= 59.94fps

#COLOR AND LEVELS

PARAMATERS#----------------------------------------------------------------------------------------------------------------------------
saturation=1 #for all outputs

gamma= 1 # 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= 0 # limit of autolevels low output
autolev_high= 255 # limit of autolevels high output

#SIZE, CROP AND BORDERS

PARAMETERS#----------------------------------------------------------------------------------------------------------------------------
CLeft=32 CTop=24 CRight=32 CBottom=24 #crop values after Depan and before final resizing

W=1280 H=720 #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=20 est_top=60 est_right=60 est_bottom=60 #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=40 # set this lower for clean films.

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

denoising_strenght= 600 #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()

# SHARPENING PARAMETERS
#--------------------------------------------------------------------------------------------------------------------------------

USM_sharp_ness= 23 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.15 #final sharpening step after interpolation

last_blur= 0.12 #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")
Import("plugins/03_RemoveDirtMC.avs")


source= ffvideosource(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= noise_baseclip.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)

#CHANGING FRAME RATE WITH

INTERPOLATION/FINALSHARPENING#.....................................................................................................................

.......................................

super= denoised.MSuper()
backward_vec= MAnalyse(super, blksize=block_size, blksizev= block_size_v, overlap=block_over, isb=true)
forward_vec= MAnalyse(super,blksize=block_size, blksizev= block_size_v, overlap=block_over, isb= false)

interpolated= denoised.MFlowFps(super, backward_vec, forward_vec, num=numerator, den= denumerator, ml=100).sharpen(last_sharp,mmx=false).sharpen

(last_sharp,mmx=false).blur(last_blur,mmx=false)

#RESULT1:

AUTOLEVELS,AUTOWHITE#..............................................................................................................................

........................................

result1= interpolated.autolevels(output_low= autolev_low, output_high= autolev_high).coloryuv(autowhite=true).addborders(bord_left, bord_top,

bord_right, bord_bot)

#RESULT2: MANUAL LEVELS, AUTOWHITE
#..................................................................................................................................................

....................
result2= interpolated.levels(black_level,1.0,white_level,0,255).coloryuv(autowhite=true)\
.addborders(bord_left, bord_top, bord_right, bord_bot)

#RESULT3: AUTOLEVELS, MANUAL COLOR CORRECTIONS
#..................................................................................................................................................

...................
result3= interpolated.coloryuv(off_U=blue,off_V=red).autolevels(output_low= autolev_low, output_high= autolev_high).addborders(bord_left, bord_top,

bord_right, bord_bot)

#RESULT4: MANUAL LEVELS, MANUAL COLOR CORRECTIONS
#..................................................................................................................................................

...................
result4= interpolated.coloryuv(off_U=blue,off_V=red).levels(black_level,1.0,white_level,0,255).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

final_framerate= numerator/denumerator
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))

Eval(result)

egekhter
21st September 2013, 00:00
Here's my problem if anybody can figure out what in Fred's script is causing this to happen:

Good black:
http://s9.postimg.org/y67wlrzsf/good_black0.jpg


film= "X:\FlashScan HD\Capture\FTC_14799_Hack\14799_Hack-S8mm_3-7-01.mov" # source clip, you must specify the full path here


ffvideosource(film)


Bad black:
http://s9.postimg.org/ni45mxptb/bad_black0.jpg

# 8mm film restoration script by videoFred.
# www.super-8.be
# info@super-8.be
# version 01.A with frame interpolation
# 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= "X:\FlashScan HD\Capture\FTC_14799_Hack\14799_Hack-S8mm_3-7-01.mov" # source clip, you must specify the full path here

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

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

numerator= 30 #numerator for the interpolator (final frame rate)
denumerator= 1 #denumerator example: 60000/1001= 59.94fps

#COLOR AND LEVELS

PARAMATERS#----------------------------------------------------------------------------------------------------------------------------
saturation=1 #for all outputs

gamma= 1 # 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= 0 # limit of autolevels low output
autolev_high= 255 # limit of autolevels high output

#SIZE, CROP AND BORDERS

PARAMETERS#----------------------------------------------------------------------------------------------------------------------------
CLeft=32 CTop=24 CRight=32 CBottom=24 #crop values after Depan and before final resizing

W=1280 H=720 #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=20 est_top=60 est_right=60 est_bottom=60 #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=40 # set this lower for clean films.

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

denoising_strenght= 600 #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()

# SHARPENING PARAMETERS
#--------------------------------------------------------------------------------------------------------------------------------

USM_sharp_ness= 23 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.15 #final sharpening step after interpolation

last_blur= 0.12 #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")
Import("plugins/03_RemoveDirtMC.avs")


source= ffvideosource(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= noise_baseclip.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)

#CHANGING FRAME RATE WITH

INTERPOLATION/FINALSHARPENING#.....................................................................................................................

.......................................

super= denoised.MSuper()
backward_vec= MAnalyse(super, blksize=block_size, blksizev= block_size_v, overlap=block_over, isb=true)
forward_vec= MAnalyse(super,blksize=block_size, blksizev= block_size_v, overlap=block_over, isb= false)

interpolated= denoised.MFlowFps(super, backward_vec, forward_vec, num=numerator, den= denumerator, ml=100).sharpen(last_sharp,mmx=false).sharpen

(last_sharp,mmx=false).blur(last_blur,mmx=false)

#RESULT1:

AUTOLEVELS,AUTOWHITE#..............................................................................................................................

........................................

result1= interpolated.autolevels(output_low= autolev_low, output_high= autolev_high).coloryuv(autowhite=true).addborders(bord_left, bord_top,

bord_right, bord_bot)

#RESULT2: MANUAL LEVELS, AUTOWHITE
#..................................................................................................................................................

....................
result2= interpolated.levels(black_level,1.0,white_level,0,255).coloryuv(autowhite=true)\
.addborders(bord_left, bord_top, bord_right, bord_bot)

#RESULT3: AUTOLEVELS, MANUAL COLOR CORRECTIONS
#..................................................................................................................................................

...................
result3= interpolated.coloryuv(off_U=blue,off_V=red).autolevels(output_low= autolev_low, output_high= autolev_high).addborders(bord_left, bord_top,

bord_right, bord_bot)

#RESULT4: MANUAL LEVELS, MANUAL COLOR CORRECTIONS
#..................................................................................................................................................

...................
result4= interpolated.coloryuv(off_U=blue,off_V=red).levels(black_level,1.0,white_level,0,255).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

final_framerate= numerator/denumerator
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))

Eval(result)

Found the culprit!!!!!!

It was deflicker that was causing flickering between grey and black!!!!!

Hope this helps anyone that has noticed the same problem.

egekhter
22nd September 2013, 16:53
Ran into another snafu with the script.
After switching from HQX to Prores as the input file,
changed AVISource to qtinput or FFMPEGSource2 w/ audio...
Now when I save out to a new file in vdub the script hangs at 101 frames. If I do not include the audio as a parameter in the input source with the prores file, the script does not hang. But, going back to my old workflow, AVISource never gave me problems with including synced audio during restoration, so I feel like I am back to square one.

Some ideas I had:
1. run the qtinput/ffms2 script w/out audio and re-insert the audio from the original file in a separate step
2. Keep using old workflow -> creating an intermediate HQX file to feed into AVISource.

None of the above is ideal, ideas anyone?

johnmeyer
22nd September 2013, 18:53
I almost always use the killaudio() command in my scripts, specifically to avoid crashes. Many old hands in this forum have advised me that this isn't necessary, but that has not been my experience. With my particular editing workflow, I find that it takes absolutely zero effort (in my editing program, Vegas) to put the audio from the original source on the timeline below the video that results from the AVISynth script.

I know that's not the answer you were looking for, but I also wanted to let you know that you may find that you can't get stability with certain functions if you include the audio.