View Full Version : The power of Avisynth: restoring old 8mm films.
mikkop
23rd February 2009, 20:04
Thanks guys,
I give it a go. I'm triing to understand the scripting but it's a not so easy.
Thanks for the script fred i love your films.
Michael
bigdog660
28th February 2009, 11:21
Hey everyone,
I'm getting the following error: "Script error: there is no function named 'MVAnalyseMulti'".
And if I rename MVAnalyseMulti to MVAnalyse, I get this error instead: "MVAnalyse does not have a named argument "refframes".
Anyone have and idea what's wrong? I'm using AviSynth 2.58, and all DLL's are installed.
Thanks,
Ron
videoFred
2nd March 2009, 07:36
Hello Ron,
You need the special 'multi' MVTools version. It can be found here on the forum. But you can replace the denoising lines with the examples from Fizicks help files.
Fred.
bigdog660
3rd March 2009, 15:01
Thanks for your help Fred.
But now another error pops up:
Avisynth open failure:
Script error: there is no fuction named "Spline64Resize"
(C:\Program Files\AviSynth 2.5\Plugins\LimitedSharpenFaster.avs, line 66)
(D:\0534503\VIDEO_TS\test.avs, line 149)
Here is my test.avs script:
film="D:\0534503\VIDEO_TS\VTS_02_1.d2v"
short="L" # L=long clip S=short clip try it!
result="resultS3" # specify the wanted output here
trim_begin=6 trim_end=6 play_speed=16.00 #trim frames and play speed (PAL: 16.6666 or 18.75)
saturation=1.0 #saturation
X=4 gamma=0.7 # X is a special parameter for reducing the autolevels effect
black_level=0 white_level=255 output_black=0 output_white=255 # manual levels, when returning result4
AGC_max_sat=2 AGC_max_gain=1.0 #parameters of HDRAGC filter, improves colors and shadows
blue=-4 red=2 #manual color adjustment, when returning result2. Values can be positive or negative
denoising_strenght=800 #denoising level of first denoiser: MVDegrainMulti()
denoising_frames= 4 #number of frames for averaging (forwards and backwards) 3 is a good start value
block_size= 16 #block size of MVDegrainMulti()
block_over= 4 #block overlapping of MVDegrainMulti()
temp_radius=20 temp_luma=6 temp_chroma=6 #second denoiser: TemporalSoften
grain_luma=10 grain_chroma=10
# this will add some digital grain to the final result, set it to zero if you do not want it.
LSF_sharp_ness=250 LSF_radi_us=3 LSF_sub=1.5 #first sharpening parameters (LimitedSharpenFaster)
sub=subsampling
USM_sharp_ness=40 USM_radi_us=2 USM_thres_hold=0 #second sharpening parameters (UnsharpMask)
USM_sharp_ness2=20 USM_radi_us2=1 USM_thres_hold2=0 #third sharpening parameters (UnsharpMask)
maxstab=20 #maximum values for the stabiliser (in pixels) 20 is a good start value
est_left=20 est_top=20 est_right=20 est_bottom=20 est_cont=0.8 #crop values for special Estimate clip
CLeft=30 CTop=30 CRight=30 CBottom=30 #crop values after Depan and before final resizing (40,30,40,30)
W=704 H=480 #final size from the returned clip
bord_left=0 bord_top=0 bord_right=0 bord_bot=0
SetMemoryMax(1024)
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DePan.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DePanEstimate.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\RemoveGrain.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\HDRAGC.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\mvtools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\mt_masktools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\MaskTools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\WarpSharp.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\LimitedSupport_09Jan06B.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\MT.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\AGC.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\autolevels.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\AddGrainC.dll")
Import("C:\Program Files\AviSynth 2.5\Plugins\LimitedSharpenFaster.avs")
SetMTMode(5)
source1= Mpeg2source(film).assumefps(play_speed).trim(trim_begin,0).converttoYV12()
end= source1.framecount()
end2= end-trim_end
frames=end+trim_begin
skip= end2/5
skip0=skip+3
skipend= 3
skipend1= skip0+3
skip2= skipend1+skip
skipend2= skip2+3
skip3= skipend2+skip
skipend3= skip3+3
skip4= skipend3+skip
skipend4= skip4+3
skip5= end2-3
L= trim(source1,0,end2)
LS= trim(source1,0,end2).scriptclip("""subtitle("frame "+string(trim_begin+current_frame)\
+" from "+string(frames)+" trim_begin-"+string(trim_begin)+" trim_end-"\
+string(trim_end),x=100,y=60,size=32)""")
sourceT1= trim(source1,0,skipend).scriptclip("""subtitle("frame "+string(trim_begin+current_frame)\
+" from "+string(frames)+" trim_begin-"+string(trim_begin)+" trim_end-"+string(trim_end)\
+" steps: "+string(skip),x=100,y=60,size=32)""")
sourceT2= trim(source1,skip0,skipend1).scriptclip("""subtitle("frame "+string
(trim_begin+skip0+current_frame)\
+" from "+string(frames)+" trim_begin-"+string(trim_begin)+" trim_end-"+string(trim_end)+" steps: "\
+string(skip),x=100,y=60,size=32)""")
sourceT3= trim(source1,skip2,skipend2).scriptclip("""subtitle("frame "+string
(trim_begin+skip2+current_frame)\
+" from "+string(frames)+" trim_begin-"+string(trim_begin)+" trim_end-"+string(trim_end)+" steps:\
"+string(skip),x=100,y=60,size=32)""")
sourceT4= trim(source1,skip3,skipend3).scriptclip("""subtitle("frame "+string
(trim_begin+skip3+current_frame)\
+" from "+string(frames)+" trim_begin-"+string(trim_begin)+" trim_end-"+string(trim_end)+\
" steps: "+string(skip),x=100,y=60,size=32)""")
sourceT5= trim(source1,skip4,skipend4).scriptclip("""subtitle("frame "+string
(trim_begin+skip4+current_frame)\
+" from "+string(frames)+" trim_begin-"+string(trim_begin)+" trim_end-"+string(trim_end)+\
" steps: "+string(skip),x=100,y=60,size=32)""")
sourceT6= trim(source1,skip5,end2).scriptclip("""subtitle("frame "+string(trim_begin+skip5+current_frame)\
+" from "+string(frames)+" trim_begin-"+string(trim_begin)+" trim_end-"+string(trim_end)+\
" steps: "+string(skip),x=100,y=60,size=32)""")
SS= sourceT1+sourceT2+sourceT3+sourceT4+sourceT5+sourceT6
sourceT10= trim(source1,0,skipend)
sourceT20= trim(source1,skip0,skipend1)
sourceT30= trim(source1,skip2,skipend2)
sourceT40= trim(source1,skip3,skipend3)
sourceT50= trim(source1,skip4,skipend4)
sourceT60= trim(source1,skip5,end2)
S= sourceT10+sourceT20+sourceT30+sourceT40+sourceT50+sourceT60
stab_reference= eval(short).crop(est_left,est_top,-est_right,-est_bottom)\
.tweak(cont=est_cont).binarize(threshold=80).greyscale().invert()
mdata=DePanEstimate(stab_reference,trust=1.0,dxmax=maxstab,dymax=maxstab)
stab=DePanStabilize(eval(short),data=mdata,cutoff=0.5,dxmax=maxstab,dymax=maxstab,method=1,mirror=15)
stab2= stab.crop(CLeft,CTop,-CRight,-CBottom).tweak(sat=saturation)
stab3=DePanStabilize(eval(short),data=mdata,cutoff=0.5,dxmax=maxstab,dymax=maxstab,method=1,info=true)
WS= width(stab)
HS= height(stab)
stab4= stab3.addborders(10,10,10,10,$B1B1B1).Lanczos4Resize(WS,HS)
vectors= stab2.MVAnalyseMulti(refframes=denoising_frames, pel=2, blksize=block_size, overlap=block_over,
idx=1)
denoised= stab2.MVDegrainMulti(vectors, thSAD=denoising_strenght, SadMode=1, idx=1).tweak(sat=saturation)
leveled= denoised.HDRAGC
(coef_gain=2.0,max_gain=AGC_max_gain,min_gain=0.5,max_sat=AGC_max_sat,shadows=true)
sharp1=limitedSharpenFaster(leveled,smode=1,strength=LSF_sharp_ness,overshoot=50,\
radius=LSF_radi_us, ss_X=LSF_sub, SS_Y=LSF_sub, dest_x=W,dest_y=H)
sharp2= unsharpmask(sharp1,USM_sharp_ness,USM_radi_us,USM_thres_hold)
sharpX= unsharpmask(sharp2,USM_sharp_ness2,USM_radi_us2,USM_thres_hold2)
sharp3= sharpX.TemporalSoften(temp_radius,temp_luma,temp_chroma,15,2).addgrainC
(grain_luma,grain_chroma,0.2,0.2,5)
#backward_vectors = sharp3.MVAnalyse(isb = true,truemotion=true,idx=2)
#forward_vectors = sharp3.MVAnalyse(isb = false,truemotion=true,idx=2)
#frameclip=MVFlowFps(sharp3,backward_vectors, forward_vectors, num=25, den=1, ml=100, idx=2)
result1= sharp3.addborders(X,0,0,0,$FFFFFF).levels(0,gamma,255,0,255).autolevels().coloryuv
(autowhite=true)\
.crop(X,0,-0,-0).addborders(bord_left, bord_top, bord_right, bord_bot)
result2= sharp3.levels(black_level,gamma,white_level,0,255).coloryuv(autowhite=true)\
.addborders(bord_left, bord_top, bord_right, bord_bot)
result3= sharp3.coloryuv(off_U=blue,off_V=red).levels(0,gamma,255,0,255).addborders(X,0,0,0,$FFFFFF)\
.autolevels().crop(X,0,-0,-0).addborders(bord_left, bord_top, bord_right, bord_bot)
result4= sharp3.coloryuv(off_U=blue,off_V=red).levels(black_level,gamma,white_level,0,255)\
.addborders(bord_left, bord_top, bord_right, bord_bot)
result5= overlay(eval(short),stab_reference,x=est_left,y=est_top).addborders
(2,2,2,2,$FFFFFF).Lanczos4Resize(WS,HS)
W2= W+bord_left+bord_right
H2= H+bord_top+bord_bot
short2=short+"S"
source2=Lanczos4Resize(eval(short2),W2,H2)
source3=Lanczos4Resize(eval(short2),W,H)
resultS1= stackhorizontal(subtitle(source2,"original",size=32,align=2)\
,subtitle(result1,"autolevels, autowhite",size=28,align=2))
resultS2= stackhorizontal(subtitle(source2,"original",size=32,align=2)\
,subtitle(result2,"autowhite, manual levels correction",size=28,align=2))
resultS3= stackhorizontal(subtitle(source2,"original",size=32,align=2)\
,subtitle(result3,"autolevels + manual color correction",size=28,align=2))
resultS4= stackhorizontal(subtitle(source2,"original",size=32,align=2)\
,subtitle(result4,"manual colors and levels correction",size=28,align=2))
resultS2H= stackhorizontal(subtitle(source2,"original",size=32,align=2)\
,subtitle(result2,"autowhite, manual levels correction",\
size=28,align=2).histogram(mode="levels"))
resultS3H= stackhorizontal(subtitle(source2,"original",size=32,align=2),\
subtitle(result3,"autolevels + manual color correction",\
size=28,align=2).histogram(mode="levels"))
resultS4H= stackhorizontal(subtitle(source2,"original",size=32,align=2),\
subtitle(result4,"manual colors and levels correction",\
size=28,align=2).histogram(mode="levels"))
result6= 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)
And here is the LimitedSharpenFaster.avs script I am using:
# LimitedSharpen() ( modified for standard definition dvds and dual core cpus. by jeremy duncan november 11, 2008 )
#
# A multi-purpose sharpener by Didée
#
#
# Changes in this mod:
#
# - RemoveGrain >= v0.9 IS REQUIRED!!
# ==================================
#
# - Smode=4 / sometimes does the magic ;-)
# - a separate "undershoot" parameter, to allow for some line darkening in comic or Anime
# - Lmode=3 / on edges, limited sharpening with zero OS & US. On not-edges, limited sharpening with specified OS + LS
# - "soft" acts different now: no more boolean true/false, but instead integer 0 - 100 (or -1 -> automatic)
# instead of blurring before finding minima/maxima, it now softens the "effect-of-sharpening"
# - edgemode=-1 now shows the edgemask. (scaling still not implemented :p )
# - If you use a different resolution than standard definition dvd. Disable supersampling ss_x and ss_y by setting them to 1.0
# - for ntsc supersampling set ss_x to 1.2, set ss_y to 1.2
# - for pal supersampling set ss_x to 1.3 set ss_y to 1.1
#
## - MODIFIED version using MaskTools 2.0 and dedicated support plugin LimitedSupport
function LimitedSharpenFaster( clip clp,
\ float "ss_x", float "ss_y",
\ int "dest_x", int "dest_y",
\ int "Smode" , int "strength", int "radius",
\ int "Lmode", bool "wide", int "overshoot", int "undershoot",
\ int "soft", int "edgemode", bool "special",
\ int "exborder" )
{
ox = clp.width
oy = clp.height
Smode = default( Smode, 3 )
ss_x = (Smode==4)
\ ? default( ss_x, 1.2)
\ : default( ss_x, 1.2 )
ss_y = (Smode==4)
\ ? default( ss_y, 1.2)
\ : default( ss_y, 1.2 )
dest_x = default( dest_x, ox )
dest_y = default( dest_y, oy )
strength = (Smode==1)
\ ? default( strength, 127 )
\ : default( strength, 127 )
strength = (Smode==2&&strength>100) ? 100 : strength
radius = default( radius, 2 )
Lmode = default( Lmode, 1 )
wide = default( wide, false )
overshoot = default( overshoot, 0)
undershoot= default( undershoot, overshoot)
softdec = default( soft, 60 )
soft = softdec!=-1 ? softdec : sqrt( (((ss_x+ss_y)/2.0-1.0)*100.0) ) * 10
soft = soft>100 ? 100 : soft
edgemode = default( edgemode, 0 )
special = default( special, false )
exborder = default( exborder, 0)
#radius = round( radius*(ss_x+ss_y)/2) # If it's you, Mug Funky - feel free to activate it again
xxs=round(ox*ss_x/12)*10
yys=round(oy*ss_y/12)*10
smx=exborder==0?dest_x:round(dest_x/Exborder/4)*4
smy=exborder==0?dest_y:round(dest_y/Exborder/4)*4
clp.isYV12() ? clp : clp.converttoyv12()
ss_x != 1.0 || ss_y != 1.0 ? last.MT("Spline64Resize(xxs, last.height)",2).MT("Spline64Resize(last.width, yys)",3, splitvertical=true) : last
tmp = last
edge = mt_logic( tmp.mt_edge(thY1=0,thY2=255,"8 16 8 0 0 0 -8 -16 -8 4")
\ ,tmp.mt_edge(thY1=0,thY2=255,"8 0 -8 16 0 -16 8 0 -8 4")
\ ,"max") .mt_lut("x 128 / 0.86 ^ 255 *") #.levels(0,0.86,128,0,255,false)
tmpsoft = tmp.removegrain(1,-1)
dark_limit1 = tmp.mt_inpand()
bright_limit1 = tmp.mt_expand()
dark_limit = (wide==false) ? dark_limit1 : dark_limit1 .removegrain(1,-1).mt_inpand()
bright_limit = (wide==false) ? bright_limit1 : bright_limit1.removegrain(1,-1).mt_expand()
minmaxavg = special==false
\ ? SimpleAverage(dark_limit1, bright_limit1)
\ : mt_merge(dark_limit,bright_limit,tmp.removegrain(1,-1),Y=3,U=-128,V=-128)
Str=string(float(strength)/100.0)
normsharp = Smode==1 ? unsharpmask(strength,radius,0)
\ : Smode==2 ? sharpen(float(strength)/100.0)
\ : Smode==3 ? mt_lutxy(tmp,minmaxavg,yexpr="x x y - "+Str+" * +")
\ : mt_lutxy(tmp,tmpsoft,"x y == x x x y - abs 16 / 1 2 / ^ 16 * "+Str+
\ " * x y - 2 ^ x y - 2 ^ "+Str+" 100 * 25 / + / * x y - x y - abs / * + ?")
OS = string(overshoot)
US = string(undershoot)
mt_lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x y x - "+OS+" - 1 2 / ^ + "+OS+" + ?")
mt_lutxy( dark_limit, last, yexpr="y x "+US+" - > y x x y - "+US+" - 1 2 / ^ - "+US+" - ?")
Lmode==1 ? clamp(normsharp, bright_limit, dark_limit, overshoot, undershoot) : last
normal = last
zero = clamp(normsharp, bright_limit, dark_limit, 0,0)
Lmode==3 ? mt_merge(normal,zero,edge.mt_inflate()) : normal
edgemode==0 ? last
\ : edgemode==1 ? mt_merge(tmp,last,edge.mt_inflate().mt_inflate().removegrain(1,-1),Y=3,U=1,V=1)
\ : mt_merge(last,tmp,edge.mt_inflate().mt_inflate().removegrain(1,-1),Y=3,U=1,V=1)
AMNT = string(soft)
AMNT2 = string(100-soft)
sharpdiff=MakeDiff(tmp,last)
sharpdiff2=mt_lutxy(sharpdiff,sharpdiff.removegrain(1,-1),
\ "x 128 - abs y 128 - abs > y "+AMNT+" * x "+AMNT2+" * + 100 / x ?")
soft==0 ? last : SubtractDiff(tmp,sharpdiff2)
(ss_x != 1.0 || ss_y != 1.0)
\ || (dest_x != ox || dest_y != oy) ? MT("Spline64Resize(dest_x, last.height)",2).MT("Spline64Resize(last.width, dest_y)",3, splitvertical=true) : last
ex=blankclip(last,width=smx,height=smy,color=$FFFFFF).addborders(2,2,2,2).coloryuv(levels="TV->PC")
\.blur(1.3).mt_inpand().blur(1.3).MT("bicubicresize(dest_x, last.height)",2).MT("bicubicresize(last.width, dest_y,0.6,.0)",3, splitvertical=true)
tmp = clp.MT("Spline64Resize(dest_x, last.height)",2).MT("Spline64Resize(last.width, dest_y)",3, splitvertical=true)
clp.isYV12() ? ( exborder==0 ? tmp.mergeluma(last)
\ : mt_merge(tmp,last,ex,Y=3,U=1,V=1) )
\ : ( exborder==0 ? tmp.mergeluma(last.converttoyuy2())
\ : tmp.mergeluma( mt_merge(tmp.converttoyv12(),last,ex,Y=3,U=1,V=1)
\ .converttoyuy2()) )
(edgemode!= -1) ? last : edge.MT("Spline64Resize(dest_x, last.height)",2).MT("Spline64Resize(last.width, dest_y)",3, splitvertical=true).greyscale
return last
}
Hope you can help.
Thanks,
Ron
Didée
3rd March 2009, 15:18
Spline64resize was introduced Avisynth 2.5.8. Earlier versions don't have it.
And, unless I am missing something unique about MT, that version of LimitedSharpenFaster completely disables supersampling on the x-axis:
ss_x != 1.0 || ss_y != 1.0 ? last.MT("Spline64Resize(xxs, last.height)",2).MT("Spline64Resize(last.width, yys)",3, splitvertical=true) : last
That's wrong, since the 2nd resize will scale back to the original input resolution ...
Corrected:
ss_x != 1.0 || ss_y != 1.0 ? last.MT("Spline64Resize(xxs, last.height)",2).MT("Spline64Resize(xxs, yys)",3, splitvertical=true) : last
Edit:
In the same manner, the final resizing (towards the end of the script) is wrong.
Moreover, the "soft" option has been crippled ... removegrain(1) will not do the intended operation.
That's a very funny version of LimitedSharpenFaster. I definetly recommend to NOT USE it ... it's full of errors.
videoFred
3rd March 2009, 15:44
I'm still using an old version of LimitedSharpenFaster(): 29 oct 2005 :eek:
That specific line of code looks like this:
ss_x != 1.0 || ss_y != 1.0 ? last.lanczosresize(xxs,yys) : last tmp = last
The scaling works very fine in this version..
But I will look for a more recent -and good working- version.
Fred.
Didée
3rd March 2009, 16:28
I was referring to the version posted by bigdog660 above. Sorry if that was not clear...
Ah, just now I saw the very first line of that mod: "modified ... by jeremy duncan november 11, 2008" :)
Gavino
3rd March 2009, 16:36
That's a very funny version of LimitedSharpenFaster. I definetly recommend to NOT USE it ... it's full of errors.
It appears to be the special version produced by Jeremy Duncan in this thread. Various people suggested at the time to rename the function to avoid confusion...
Fizick
3rd March 2009, 21:15
Gavino, you (we) can request moderator to rename script(s) modified by "Jeremy Duncan" (automatically :))
His method is practical, experimental, "rule of thumb", often (sometimes) it works (and fast), but seems, he often do not fully understand what does he do exactly. ;)
Usually me too, but I do not write guides (almost) :)
Sorry for offtopic, Fred!
At last I download your example clip from vimeo. Good works!
Will look to your script :)
videoFred
4th March 2009, 07:35
Will look to your script :)
Thank you Fizick! :)
Please have a special look at result6. You will see I have used a special clip for DepanEstimate(). This works very good.
PS: this clip shows very well how good DepanStabilize() can be:
( the yellow flowers and the butterfly)
http://www.vimeo.com/2827387
Fred.
bigdog660
4th March 2009, 11:39
Spline64resize was introduced Avisynth 2.5.8. Earlier versions don't have it.
That is exactly what I was thinking base on what I've been reading.
I have replaced the LimitedSharpenFaster with the version from 2005 and it now loads without error. Thanks for bring that version info to my attention.
Now with that clip loaded in virtualdub, I have a split screen showing the following text:
In the left screen, there is text at the top that says "frame 5708 from 174255 trim_begin-6 trim_en". At the bottom of the left screen, it says "original".
Then in the bottom right screen it says "autolevels + manual color correction".
It looks like if I encoded the video, that text will be included. It also look like my video would be a split screen. Any comments how to fix this?
Here is a pix:
http://www.etnwx.com/images/splitscn.jpg
Thanks for your help,
Ron
Gavino
4th March 2009, 11:58
It looks like if I encoded the video, that text will be included. It also look like my video would be a split screen. Any comments how to fix this?
Simply change the line near the start of the script
result="resultS3" # specify the wanted output here
to
result = "result3"
The script is set up to produce a number of possible different results and this is where you say which one you want. The names with 'S' (eg resultS3) give you a split screen for comparison with the original.
videoFred
4th March 2009, 12:02
Hey Ron!
*EDIT*: cross posting with Gavino.. he was faster :)
I see there is a lot of confusion about this.
Let me explain:
I have made these split screen clips for comparison reasons and to be able to tweak the parameters when watching the original vs the tweaked version.
Now, at the top of the script you will see:
result="resultS3"
The "S" stands for split screen.
The following code:
result="result3"
Will return clip "result3" without the split screen and without the text.
The following options are possible:
result1: autolevels and autowhite (manual disabled)
result2: autowhite, manual levels correction
result3: autolevels, manual color correction
result4: everything manual
result6: special comparison clip to test stabilizing.
resultS1,S2,S3,S4: split screens for comparison.
PS: in your case, the text is to large, it does not fit in the screen. Easy to change: in the "subtitle' code you must change "size=32" "to size=24" for example.
PS2: denoising, sharpening and gamma is always enabled on all clips, unless you set the parameters to zero. Levels and color adjustment is only applied on certain clips, see above.
For example, if you set "blue=-10" this is only applied on clips 3 and 4, it will have no effect on clips 1 and 2.
Fred.
Didée
4th March 2009, 12:45
Addendum to the LimitedSharpenFaster issue posted above.
After playing a bit with MT(), I have to correct what I said. The supersampling in the Jeremy-Version of LSF does work. MT() can cause changes in a script's flow.
Normal code:
clip
filter1().filter2(x=last.width())
Here, "last" in filter2 refers to "clip" one line above. In a dotted chain "filter().filter().filter()", the intermediate states are not stored in "inherent last".
Code with separated(!) MT() :
clip
MT("filter1()").MT("filter2(x=last.width))")
Now, this works different. Here, "last" in filter2 does NOT refer to "clip" one line above. Instead, it refers to the result of "filter1()". Eventhough the calls are chained by dots, the 2nd MT() is interpreted as if it was placed in a new line.
For that reason, supersampling in Jeremy's version indeed works correct. It only seems wrong, if you don't know about this particularity of MT().
But that's no excuse for replacing all 11/20 modes of removegrain with mode 1. "soft" is broken, smode=4 is broken, "special" is broken (more than it was from the start).
Note: the different behaviour due to MT() is not trivial. It's a pitfall when multithreading a script with MT(), and in some cases it may be the cause for complete failures when trying to do so.
Gavino
4th March 2009, 16:37
clip
MT("filter1()").MT("filter2(x=last.width))")
Now, this works different. Here, "last" in filter2 does NOT refer to "clip" one line above. Instead, it refers to the result of "filter1()". Eventhough the calls are chained by dots, the 2nd MT() is interpreted as if it was placed in a new line.
Right. Specifically, the way it works is similar to the behaviour of ScriptClip - the inner 'last' (note that it's inside a string) is not evaluated until inside the second MT, in a context where 'last' has been temporarily set to the clip parameter of that MT (which here is the result of the first MT).
Just like ScriptClip(c, "filter2(x=last.width)"), where 'last' refers to 'c'.
Note: the different behaviour due to MT() is not trivial. It's a pitfall when multithreading a script with MT(), and in some cases it may be the cause for complete failures when trying to do so.
Yes, you're right. The documentation doesn't really make that clear.
bigdog660
5th March 2009, 10:58
videoFred, thanks for the explanation. I applied the filter, and it did help, but the second DVD I had made is even worse than the 1st. Even using your filter, the images are too grainy and dark. I'm afraid I'm going to have to find someone who knows what they are doing when transferring film to DVD. As it was said in another thread, there are people who specialize in this on this forum, and I believe you are one of them. If you (or you have someone you can recommend) wants to take a shot at this, please PM me.
Sorry for the OT.
I'll post a sample of the film untouched here tomorrow for anyone who's interested to look at. Comments on the transfer will be welcome.
videoFred
5th March 2009, 11:43
I'll post a sample of the film untouched here tomorrow for anyone who's interested to look at. Comments on the transfer will be welcome.
About transfering film: please see my signature.
You can mail me direct from there.
Fred.
rfmmars
5th March 2009, 16:52
videoFred, thanks for the explanation. I applied the filter, and it did help, but the second DVD I had made is even worse than the 1st. Even using your filter, the images are too grainy and dark. I'm afraid I'm going to have to find someone who knows what they are doing when transferring film to DVD. As it was said in another thread, there are people who specialize in this on this forum, and I believe you are one of them. If you (or you have someone you can recommend) wants to take a shot at this, please PM me.
Sorry for the OT.
I'll post a sample of the film untouched here tomorrow for anyone who's interested to look at. Comments on the transfer will be welcome.
I am the film transfer business too and have used VideoFred's script which is excellent. You got to keep in mind that each film is different in its need for correction. There is no automatic correction process avalible period. It is you or me doing a sence by sence correction, using Virtualdub, Avisynth, and the best Editor for film\tape is Magix's MEP-14 Plus, which allows you to use Virtualdub plugins on a frame to frame bases. This is not easy stuff, many hours are spent on each project. best of luck.
Take a look at my website too.
Richard
photorecall.net
bigdog660
7th March 2009, 14:01
Hey guys,
I finally had time to encode and up a sample. Here is a 10 minute segment of the DVD. No filters or adjustments were make. I encoded using 2 pass Xvid at 1400 ABR. Resolution is 704x480, same as the DVD. Please let me know what you think.
http://www.sendspace.com/file/zorcqx
File size is 100,422 KB.
rfmmars
8th March 2009, 00:10
Hey guys,
I finally had time to encode and up a sample. Here is a 10 minute segment of the DVD. No filters or adjustments were make. I encoded using 2 pass Xvid at 1400 ABR. Resolution is 704x480, same as the DVD. Please let me know what you think.
http://www.sendspace.com/file/zorcqx
File size is 100,422 KB.
Looking at your raw capture footage, the camera is the weak link. Very little resolution, less than 200 lines, my Sony DXC 750 has 750 lines, and that going to be the limiting factor. The color film balance reminds me of Agfachrome, very warm. I used Video Fred's script and RGBeq 2.11 and Color mill 2.11 for grayscale balance. Also the camera may have color drupp or apeature correction problems, see yellow squares.
Again you will need to do custom correctio for every scene change.
Richard
photorecall.net
http://img6.imageshack.us/img6/892/doomavi.th.jpg (http://img6.imageshack.us/my.php?image=doomavi.jpg)
2Bdecided
8th March 2009, 01:13
the camera is the weak linkOr else something in the setup is just not in focus?
Cheers,
David.
rfmmars
8th March 2009, 14:03
Or else something in the setup is just not in focus?
Cheers,
David.
It could be that the film camera lens is a fault but looking at the film grain in other sections of the film, that seems to be ruled out, the grain is large, pointing to the capture camera is at fault.
I capture Mjpeg using the last version of "Dscaler". A lot of people don't like Descaler but it is the most flexable for real time film capture.
Richard
photorecall.net
scharfis_brain
8th March 2009, 14:41
DScaler (without 'e')
is good for viewing analogue stuff, but it is NOT good for capturing cause it doesn't properly handle A/V offset as well as framedropping.
Better go for VirtualVCR as it is specially built for capturing stuff.
rfmmars
8th March 2009, 23:47
DScaler (without 'e')
is good for viewing analogue stuff, but it is NOT good for capturing cause it doesn't properly handle A/V offset as well as framedropping.
Better go for VirtualVCR as it is specially built for capturing stuff.
Offset is not a problem since the films have no audio. Using Leadlool's Mjpeg codec with a AMD 1.8 gig old style XP chip, no drop frames ever using highest quality setting. I made it clear that it was a Sony analog camera doing film capture work. Tried VirtualVCR but didn't like it.
Richard
rfmmars
9th March 2009, 02:11
DScaler (without 'e')
NOT good for capturing cause it doesn't properly handle A/V offset.
So I did a 2 hour capture with my configuation using Dscaler and indeed it has a -6ms linera audio offset, so I reset it in VideoDeluxe Video Pro X with a +6ms correction for perfect audio sync, so what the big deal........audio offset is part of the video industry, related to the choice of video card, audio card, and codec conbination used.
Richard
scharfis_brain
9th March 2009, 22:50
if you got poor tapes (VHS, Video8 etc.) the framerate will be slightly off 25.000 or 29.970 fps thus introducing a variable audio offset.
VirtualVCR compensates for that. I never was able to get decent A/V sync out of Dscaler for poor sources.
But if you don't need audio dscaler might be fine.
Also I am able to use ffdshows (AVISynth) filtering in realtime while capturing if I want to.
Tagert
23rd April 2009, 09:13
Amazing work !
It was a joy to watch it :)
BillB
4th June 2009, 21:25
For us newbies not quite familiar with this: http://en.wikipedia.org/wiki/Motion_picture_film_scanner
videoFred
5th June 2009, 11:33
Yes,
But I'm using a 'poor mans' home build version. It's not a scanner.. It's a machine vision camera with trigger. You could say I'm taking a digital photo from every film frame, and store this on the fly in a "growing" AVI file. The capture software comes with the camera.
But my friend Frank is developing more sophisticated software right now.
For those who are interested, there is a lot more on Franks website.
http://www.cine2digits.co.uk/
I am going to test it very soon. Franks software is based on ActiveDcam.
http://www.ab-soft.com/activedcam.php
My system works like this: the projector sends a pulse (optical switch) to the camera trigger input everytime the film frame stands still in the projectors gate. It only takes a few ms to capture one film frame.
Capture speed does not matter at all. In fact, my capture speed is variable from 1 to 20 fps. The result is always the same: one film frame = one AVI frame. Play speed can be easily changed in post with AssumeFPS() and final frame rate with ChangeFPS() or ConvertFPS(). Or by interpolation with MVFlowFPS().
Fred.
stenews
16th June 2009, 20:40
Hi videoFred,
can I use your script to restoring a standard VHS tape as well?
In case, which type of variables should I look after with respect to the one you use for 8mm films?
Mind that I'm a newbie and my questions can sound with no sense at all... so please be gentle with me.
Thanks,
Stefano
videoFred
17th June 2009, 06:10
Hi videoFred,
can I use your script to restoring a standard VHS tape as well?
Hello Stefano,
Sorry, but my script is not made for this. For VHS you will find much better solutions here.
Fred.
videoFred
17th June 2009, 08:18
It is time for an update.
I have made the script more readable and I have added comments to make it more understandable. I have removed the 'short clip- long clip' code, that was just a test to see how far I could go with displaying frame numbers etc.
Final frame rate conversion with interpolation is part of the script, now. When returning the "S" clips you will see the original at the left and the interpolated clip at the right. Very interesting to see how MVFlowFPS works!
About the dll's: 'MVTools' must be the modified Multithreaded version. 'MVTools2' is the latest Fizick version.
Be sure that the multi version is named 'MVTools.dll' and the other one 'MVTools2.dll'
The script is using both versions without any problem.
*EDIT 16/09/2009*
The updated script is available for download now.
Please see first page of this thread.
stenews
17th June 2009, 08:26
Hi videoFred and thanks for your reply.
You said that:
...For VHS you will find much better solutions here
where...? I mean, could you provide a link where to see code(s) more suitable for restoring VHS tape(s)?
or I'm just miss understanding something in your answer?
Thanks, :)
Stefano.
videoFred
17th June 2009, 08:29
Hello Stefano,
Please use search here on this forum.
VHS in not my thing, sorry.
Fred.
stenews
17th June 2009, 08:35
all right...now I see what you mean.
Thanks the same,
bye,
Stefano
videoFred
17th June 2009, 12:22
You are welcome!
It has just been posted today, Stefano:
http://forum.doom9.org/showthread.php?t=147796
Fred.
stenews
17th June 2009, 13:02
you're a gentlemen, mate.
Thanks a lot for your help, I really appreciate that! ;)
Bye,
Stefano
superpat999
8th July 2009, 19:59
Hi,
Hello everyone
This is my first post on this forum. Unfortunately it is an appeal for assistance.
I recently discovered Avisynth and your fantastic restoration script!
I have a number of avi files of standard 8mm film that have been digitised by a 'professional' company for me. I am a bit disappointed with the results and decided to use your script to improve the avi images I received back from the company.
I have struggled with the steep learning curve involved with starting out with avisynth and using a complex script!, but I think I have installed Avisynth (2.58) and the required filters and auxilary scripts correctly.
The example scripts provided with Avisynth run fine!
I have created a short clip from one of my files to experiment with.
I have downloaded your 17-June-2009 script, and the particular filters as listed on that post.
However when I run your script, suitably edited for my avi clip file name and paths, after some tens of seconds without the monitor showing the input/output boxes I get the following error:-
AVI: Opening file "C:\films\freds.avs"
[E] Error: Avisynth open failure:
Error in MFlowFps : mvbw's overlap size is incorrect
(C:\films\freds.avs, line 168)
Line 168 in your script is:-
164. super= sharp1.MSuper(pel=2)
165. backward_vec= MAnalyse(super, isb=true)
166. forward_vec= MVAnalyse(super, isb=false)
167.
168. interpolated= sharp1.MFlowFps(super, backward_vec, forward_vec, num=numerator,\
169. den=denumerator,ml=100)#.TemporalSoften(temp_radius,temp_luma,temp_chroma,15,2)
170.
171. sharp3= unsharpmask(interpolated,USM_sharp_ness2,USM_radi_us2,USM_thres_hold2)\
172. .addgrainC(grain_luma,grain_chroma,0.2,0.2,5)
avisynth reports my unmodified avi clip as:-
Video stream
Frame size fps (us per frame 720x576 25.000fps (40000)us
Length 18614 frames 12:24.56
Decompressor Panasonic DV CODEC (dvsd)
Number key frames 144000/144000/144000 [2617954k]
no delta frames
Data rate 28800fps (0.02% overhead)
Googling for this error and searching the forum does not find any other people with this error which is very worrying.
I have tried altering the "block number" and "block overlap" parameters to no avail.
I have tried de-interlacing my clip and running it as a de-interlaced clip, but the error remains constant.
I obviously must have done something stupid, but I do not know enough to work it out for myself!
Please would some kind people put me out of my misery!
thanks in advance
Patrick
videoFred
9th July 2009, 06:35
Hello Patrick,
It's a type error :scared:
Line 166: forward_vec= MVAnalyse(super, isb=false)
Must be: forward_vec= MAnalyse(super, isb=false)
Of cource I have corrected the script.
Thank you for the good documented feedback!
Please report back here if it works now.
Fred.
superpat999
9th July 2009, 13:05
Hi Fred,
Thanks for that correction.
I am now sitting here waiting fo my first test clip to process.
It is processing at around 1 fps.. It is going to take a very long time to process all 37 Gbytes of avi's I have here produced from my family's old std 8mm films.
Some of the film dates back to the early 1940's. My father-in-law was an aero engine engineer, and went to the states to set up US factories to build the big Bristol Centurus radial engines under lease-lend during the war. He brought back some rolls of Kodachrome 8mm stock, which he used back here in the UK. Unfortunately most of the colour has gone, only blues and greens left. This will be a challenge to improve!
I have a AMD 64 X2 6400 ( dual 3gHz about) system, doing nothing here. I don't see a working 64bit version of avisynth. Would it be worthwhile installing a 32 bit XP operating system on it, and avisynth etc, and using this as a system, with MT enabled?
What fps approx would I expect from this system?
Any advice on the way to process all these avi's will be much appreciated.
One last question. Avisynth has just finished processing the clip, and the output images are FAR better than the original. However It only appears to run at 1 fps..
Where is the modified clip stored? so I can run it at "normal" speed? I will try to understand the result part of the scripts a bit better.
Thank you again for your work with these scripts
Patrick
videoFred
9th July 2009, 13:25
Some of the film dates back to the early 1940's.
Sounds interesting! Can we see something?
Unfortunately most of the colour has gone, only blues and greens left. This will be a challenge to improve!
Yes it will.... An example maybe?
What fps approx would I expect from this system?
On all my system(s) the script runs at 4fps, with a 720x576 source that is. I do not know why it is slower on yours...
Where is the modified clip stored? so I can run it at "normal" speed? I will try to understand the result part of the scripts a bit better.
When you run a script (in VirtualDub I assume?) you must save the output somewhere, Patrick!
The output will be what you see in the right Vdub window.
The result part of my script is simple: for example 'result3' will return the clip with autolevels and manual color corrections. If you not have done any 'blue' or 'red' color corrections, then there will be no corrections. 'resultS3' will return the original (at the left) vs the corrected one (at the right).
Fred.
superpat999
9th July 2009, 14:39
Hi Fred,
I found the save "file as avi" tab in Virtual Dub, just before I read your last post.
I had worked out how to use resultx and resultSx already.
I am getting 1.36fps on the conversion. (found the drop menu in Virtual dual that shows the exact info).
I am using an AMD Sempron (sp?) system about 1.5 Ghz. A quick check of the processor load, shows that it is balls to the wall, pegged at 100% load. I think I am going to build up the AMD x2 system. The time spent doing this will be recouped in a much shorter processing time!
I will put some clips of the early films on a view site for you soon! Besides the faded colour films, there are several hundred feet of black and white. I think there are some scenes from 1945 VE day of my wife's elder brother, aged about 9, riding his tricycle up and down the road with a Union flag tied to a stick, tied to the trike. There are also scenes I think of the winter snows of 1947.
Give me a few days to play with my new toy!
cheers
Patrick
Guest
9th July 2009, 14:41
I found the save "file as avi" tab in Virtual Dub, just before I read your last post. I hope you also found Video/Compression to set an output codec, otherwise your output file will be HUGE uncompressed RGB.
videoFred
9th July 2009, 14:54
I am getting 1.36fps on the conversion. (found the drop menu in Virtual dual that shows the exact info).
You mean.. while rendering?
But because your input is already film telecined to PAL, you should set play_speed=25 , numerator=25, denumerator=1. In other words, my script should not change this.
I will put some clips of the early films on a view site for you soon!
Yes, please do so. And if possible, the original transfered files. I think we will have to deal with interlacing and frame rate convertions too.
Give me a few days to play with my new toy!
Take your time... :)
Fred.
tedkunich
9th July 2009, 17:09
I think I am going to build up the AMD x2 system. The time spent doing this will be recouped in a much shorter processing time!
Don't expect a "huge" performance gain with a new CPU - for example, on my quad core AMD 940, I can only clock about 4-6 fps on my sources (granted they are 1440x1080 HDV AVI's).
There seems to be some interaction conflicts with some of the plugins used in the script - using Temporalsoften with Mdegrain seems to bring everything to a crawl with only ~30% CPU utilization. Call only one or the other, and you get 100% CPU utilization.
T
videoFred
10th July 2009, 07:01
Don't expect a "huge" performance gain with a new CPU - for example, on my quad core AMD 940, I can only clock about 4-6 fps on my sources (granted they are 1440x1080 HDV AVI's).
That's pretty fast, Ted!
I barely get 3 fps on my dual core Dell, with my 1024x768 source. Of cource, if the end target is standard DVD, we could win some speed by doing the resizing at the beginning of the script. But the quality is better when doing the resizing nearly at the end, with LimitedSharpenFaster().
Anyhow... I was thinking to spread the script over several computers in a network. But I have no experience with this at all. For example: how do you call a script like this? On the last computer in the chain? And how much speed would we win?
Fred.
superpat999
12th July 2009, 12:06
Hi,
I am struggling with the move to a faster system.
I have done a clean install of 32 bit XP + SP2 on a AMD 6400 X2.
Avsynth and Virtual dub works ok on the example scripts. (Only running as single thread at the moment)
However I am having problems with your restore script.
warpsharp and autolevels dlls will not load. These are the identical dlls and versions of Avisynth and Vdub that run ok on my old Sempron AMD 1.G machine.
Tried XP SP3 no improvement
Poking around on the forum, I found some cryptic posts about the need to install some extra dlls in the Windows XP System32 directory, when using an AMD64. Unfortunately I cannot find out what these dlls are.
Are there some extra dlls to fix his problem, or is there another way of going about it?
At this time I do not want to go to 64 bit O/S (it would have to be Windows 7 RC1! ), or even MT at this time, I just want to get Fred's script working on the faster AMD cpu.
regards
Patrick
superpat999
16th July 2009, 10:18
Hi,
As promised I have uploaded one minute of each of my two oldest Standard 8 avi's
They are exactly as I received them from the telecine company:-
10.1.avi. This dates from 1942/1943. My wife's elder brother is the focus character he was born in 1937. So you can guestimate the date of the film yourself. It is in B/W I think that when I last saw it many years ago, it was in colour that had almost faded to patchy blues and greens, but there is no colours in it at all now.
16.1.avi This dates from around 1945. It is in colour. The two babies are my wife and her twin brother born in March 1944, so you can guess the year quite accurately!
I would appreciate some advice on the best way to use your script to clean sharpen and get the colour balance correct in these images. There appears to be too much brightness, in the faces, washing details out.
I have tried running the clips through resultS3 and resultS1 in your script, but I am getting a bunch of short horizontal lines in the output where motion occurs in the frame.
I have noticed that the clips are interlaced. Does your script cope with this OK? Would it help to run a deinterlace script first and then run your script?
I am a complete novice in this subject and I am sinking fast.
I was going to upload to Vimeo, but they have a new policy and will only keep original files for a week unless you pay a $60 subscription.
I have used instead:-
http://www.filehosting.org/file/details/46110/10.1.avi
http://www.filehosting.org/file/details/46136/16.1.avi
regards
Patrick
videoFred
16th July 2009, 10:58
Hi Patrick,
This is footage with great historical value!
I am very sorry but my script is overkill for film transfers like this. For example there is almost no visible film grain, so why remove it? Blown out whites are lost.. forever. No way you can recover these.
I sure hope you still have the original films? Take my advice and get yourself a better transfer. If this is not possible then I would advice to use a much faster and simple script that only does some sharpening and perhaps some stabilising or you can even do this in VirtualDub.
I sure hope I have not dissapointed you, but the 'magic' of my script only works with better transfer quality files.
PS: where are you located? Perhaps I could point you to a decent transfer service (offline). You can send me a PM, I do not do this in public.
Fred.
m3mbran3
16th July 2009, 11:56
Since your files are so big superpat999 it is unlikely that most people will d/l them to have a look. I'm currently trying to restore some old family VHS tapes and some the filters could also be used on some of your footage. May I suggest you upload some smaller files as well (<50mb)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.