PDA

View Full Version : script for 8mm - advice


marcobrd
27th January 2007, 01:02
hi all, sorry for my english, i'm italian :o
i was reading this forum for months, first times working on my holidays dv material, doing my first step with the avisynth world. then in last months for a new job with a old 8mm film material.

i learned many things reading the forum, so first i have to thank you all very much.

this was my steps for the 8mm job: project on 30-40cm distant white paper, and record directly to pc with an "old" sony cam s-video connected to pinnacle pctv card, with the record function of dscaler software. i used the "interlaced" mode recording of dscaler because it was the best method of this software and because i was shure that it means "linear 2 field frame based". i was shure to get great results with just a "simply" deinterlacer if i would have a progessive destination.
later i learned about telecined/ivtc question, and i found that my recording is just composed by an irregular pattern of progressive and "combed" frames (i hope i'm right..i'm newbby!).

so, after much testing, here the script i have now:

***
aviSource("clip.avi")

tfm()
# tdecimate(mode=2, rate=18)

crop(48,42,620,496)
converttoyv12()

fields=last

backward_vec2 = fields.MVAnalyse(isb = true, delta = 2, pel = 2, overlap=4, idx = 1)
backward_vec1 = fields.MVAnalyse(isb = true, delta = 1, pel = 2, overlap=4, idx = 1)
forward_vec1 = fields.MVAnalyse(isb = false, delta = 1, pel = 2, overlap=4, idx = 1)
forward_vec2 = fields.MVAnalyse(isb = false, delta = 2, pel = 2, overlap=4, idx = 1)
fields.MVDegrain2(backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=230,idx=1)

FFT3DFilter(Sigma=1.5, dehalo=-0.5, sharpen=0.5)

HDRAGC(coef_gain=1, corrector=0.7, max_sat=1.7)

dull = last
sharp = dull.LimitedSharpenfaster( ss_x=1.25, ss_y=1.25, strength=150, overshoot=1 )

Soothe( sharp, dull, 25 )
***

i use tfm because, in this case, i get better result than telecide (perhaps i'm not able to give it the right parameters)

i dont decimate, for 2 reasons: a) sometimes the first of the two equal frame looks better, sometimes the second, and i don't know if there is a method to keep always the better of the two frames. b) the destination will be a 25fps pal, so when i have the 18fps video, i should add 7fps.
i will decimate if i had a method to keep always the better of the 2 equal frame and if there is a *great* method to "create" 7fps every 18.

then i do some denoise, hdragc, and then some sharpening. i'm a niubby, please tell me if i made mistake or if you think my script could be better.. i go at 2fps processing speed.. it does'nt matter to me, if the results are better, i will happy even at 0.2fps

here a screen that show the results, before and after:

http://img241.imageshack.us/img241/7938/oldei5.th.jpg (http://img241.imageshack.us/my.php?image=oldei5.jpg)

http://img241.imageshack.us/img241/8333/newpa3.th.jpg (http://img241.imageshack.us/my.php?image=newpa3.jpg)

(this scene has perhaps a little bit higher hdragc coef gain.. i have to use a compromise for other darker scene in the clip)

then i must resize to 720*576 for pal.. i was thinking about iip :) but i have to learn to use it :scared: :)

i can give you other screen/sequence/clip if you want. i hope i don't make a mistake with this post, obviously i will post in specific thread for specific filter-questions.
hello everybody and thanks again!

rfmmars
27th January 2007, 01:53
You need to do more color correction. Below is a "AVS-P" script to do so.

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

AVISource("e:\1.vdr.avi")
LoadPlugin("e:\AVS\Plugins\AGC.dll")
LoadPlugin("e:\AVS\plugins\removegrain.dll")
LoadPlugin("e:\AVS\Plugins\mt_masktools.dll")
LoadPlugin("e:\AVS\Plugins\warpsharp.dll")
Loadplugin("e:\avs\plugins\gradfun2db.dll")
loadplugin("e:\avs\plugins\DeGrainMedian.dll")
loadplugin("e:\avs\plugins\Smoothdeinterlacer.dll")
LoadPlugin("e:\avs\plugins\Convolution3d.dll")
LoadPlugin("e:\avs\plugins\FFT3DFilter.dll")
LoadPlugin("e:\avs\plugins\VagueDenoiser.dll")
LoadPlugin("e:\avs\plugins\depan.dll")
ConvertToYV12()


[Pre-Auto Gain=0]
colorYUV(autogain=true)
[/Pre-Auto Gain]


[Analyze Input Signal=0]
colorYUV(analyze=true)
[/Analyze Input Signal]


[Open White balance=0]
colorYUV(autowhite=true)
[/Open White balance]



Smoothdeinterlace()



HDRAGC(avg_lum=[<"Screen Radial (128)", 128, 2000, 1345>],mode=[<"Mode (2)", 0, 2, 2>],passes=[<"Resample (4)", 1, 9, 4>],shift_u=[<"U Color Yel. Blue (0)", -100, +100, 0>], shift_v=[<"V Color Cyan Magenta (0)", -100, +100, 0>],protect=[<"Protect (2)", 0, 2, 2>],coef_gain=[<"Shadow Brightness (1)", 0.00, 0.5, 0.2>],max_gain=[<"Max Level (3)", 0.00, 8, 8.0>],corrector=[<"Corrector ((0)", 0.5, 1.5, 1.2>],reducer=[<"Reducer (0.5)", 0, 2, 2.0>],avg_window=[<"Frames Adverage (30)", 0, 120, 0>],black_clip=[<"Black Clip (0.00)", 0.0, 2, 1.1>],max_sat=[<"Max Satuation (9)", 0.00, 20, 9.0>],min_sat=[<"Min Satuation (1)", 0.00, 2, 1.1>],coef_sat=[<"Dark Color Level (1)", 0, 2, 0.7>])
Tweak([<"Hue (0)", -60, 60, 0.0>])
Converttorgb24
RGBadjust([<"Red (0)", 0.00, 2, 1.0>],[<"Green (0)", 0.00, 2, 1.0>],[<"Blue (0)", 0.00, 2, 1.0>])


#ConverttoYV12



#motion=DepanEstimate(trust=2.5, fftw=true)
#DepanInterleave(data=motion)
#YToUV(fft3dfilter(sigma=3, plane=1).UToY,\
#fft3dfilter(sigma=3, plane=2).VToY,\
#fft3dfilter(sigma=2, plane=0))
#SelectEvery(3,1)



ConvertToYV12()

gradfun2db( )



[Grain Reduction Heavy=0]
DeGrainMedian(limitY=7,limitUV=9,mode=0)
DeGrainMedian(limitY=7,limitUV=9,mode=1)
[/Grain Reduction Heavy]

[Grain Reduction Lite=0]
DeGrainMedian(limitY=2,limitUV=3,mode=1)
DeGrainMedian(limitY=2,limitUV=3,mode=1)
[/Grain Reduction Lite]

[Large Grain Reduction=0]
DeGrainMedian(limitY=40,limitUV=56,mode=0)
[/Large Grain Reduction]





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.25)
\ : default( ss_x, 1.5 )
ss_y = (Smode==4)
\ ? default( ss_y, 1.25)
\ : default( ss_y, 1.5 )
dest_x = default( dest_x, ox )
dest_y = default( dest_y, oy )
strength = (Smode==1)
\ ? default( strength, 160 )
\ : default( strength, 100 )
strength = (Smode==2&&strength>100) ? 100 : strength
radius = default( radius, 2 )
Lmode = default( Lmode, 1 )
wide = default( wide, false )
overshoot = default( overshoot, 1)
undershoot= default( undershoot, overshoot)
softdec = default( soft, 0 )
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/8)*8
yys=round(oy*ss_y/8)*8
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.lanczosresize(xxs,yys) : 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(11,-1)
dark_limit1 = tmp.mt_inpand()
bright_limit1 = tmp.mt_expand()
dark_limit = (wide==false) ? dark_limit1 : dark_limit1 .removegrain(20,-1).mt_inpand()
bright_limit = (wide==false) ? bright_limit1 : bright_limit1.removegrain(20,-1).mt_expand()
minmaxavg = special==false
\ ? mt_average(dark_limit1, bright_limit1)
\ : mt_merge(dark_limit,bright_limit,tmp.removegrain(11,-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 ? mt_clamp(normsharp, bright_limit, dark_limit, overshoot, undershoot) : last

normal = last
zero = mt_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(11,-1),Y=3,U=1,V=1)
\ : mt_merge(last,tmp,edge.mt_inflate().mt_inflate().removegrain(11,-1),Y=3,U=1,V=1)

AMNT = string(soft)
AMNT2 = string(100-soft)
sharpdiff=mt_makediff(tmp,last)
sharpdiff2=mt_lutxy(sharpdiff,sharpdiff.removegrain(19,-1),
\ "x 128 - abs y 128 - abs > y "+AMNT+" * x "+AMNT2+" * + 100 / x ?")

soft==0 ? last : mt_makediff(tmp,sharpdiff2)

(ss_x != 1.0 || ss_y != 1.0)
\ || (dest_x != ox || dest_y != oy) ? lanczosresize(dest_x,dest_y) : 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).bicubicresize(dest_x,dest_y,1.0,.0)
tmp = clp.lanczosresize(dest_x,dest_y)

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.lanczosresize(dest_x,dest_y).greyscale


}


LimitedSharpenFaster(Smode=1, ss_x=2.0, ss_y=2.0,strength=[<"Sharpness (400)", 0, 2400, 930>],overshoot=[<"OverShoot (0)", 0, 6, 0>])



[Post-Auto Gain=0]
colorYUV(autogain=true)
[/Post-Auto Gain]

[White Balance=0]
colorYUV(autowhite=true)
[/White Balance]


[Analyze Signal Output=0]
colorYUV(analyze=true)
[/Analyze Signal Output]

ConverttoYUY2()


[HQ Movie=0]
Convolution3D (preset="movieHQ")
[/HQ Movie]


[LQ Movie=1]
Convolution3D (preset="movieLQ")
[/LQ Movie]


[Bad Tape=0]
Convolution3D (0,32,128,16,64,10,0)
[/Bad Tape]

return last

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

Best of luck.

Richard
www.photorecall.net

marcobrd
28th January 2007, 18:10
thank you very much rfmmars! this script is usefull for tuning colors, hdragc settings etc.

if someone has others suggestions for others improvements please tell me. i hope my script can be usefull to people doing similar job.

:)