View Full Version : Restore24: Script to recover FILM from field-blended PAL
Dallemon
18th April 2004, 20:56
i get a script error :/
it says:
Script Error: there is no function named "DEdgeMask"
(bla\restore24.avs, line 25)
(bla\test.avs, line 15)
zettai
18th April 2004, 20:57
You need the latest Mask Tools (as posted in a thread recently)
Dallemon
18th April 2004, 21:06
the version i have is from 10. jan 2004 (1.4.6)
its the one from http://www.avisynth.org/warpenterprises/
edit: alright found a newer version in the forums and it fixed the problem, but now it says it need yv12 data :/
zettai
18th April 2004, 21:11
http://forum.doom9.org/showthread.php?s=&threadid=67232
it's in this forum, you just had to look a few thread down :)
Dallemon
18th April 2004, 21:13
thx but i found the search button :P
edit: argh if i change the converttoyuy2 to yv12 it says it cant crop with uneven numbers and if it stays @ yuy2 it says it needs yv12 data :/
scharfis_brain
18th April 2004, 22:02
please be sure, you have read my loong post above!
you have to load the plugins in th following order:
masktools.dll #for restore24
mpeg2dec.dll #for bobmatcher
mpeg2dec3.dll #for loading the d2v
Dallemon
18th April 2004, 22:12
i did
edit: except i have no idea which version of mpeg2dec.dll to use :/
edit2: the version i have is the one from the avisynth filter collection
edit3/5: the new script looks like so
setmemorymax(256)
import("C:\AviSynth 2.5\scripts\restore24.avs")
import("C:\AviSynth 2.5\scripts\bobmatcher.avs")
loadplugin("C:\AviSynth 2.5\plugins\masktools.dll")
loadplugin("C:\AviSynth 2.5\plugins\avisynth_c.dll")
loadcplugin("C:\AviSynth 2.5\plugins\smartdecimate.dll")
loadplugin("C:\AviSynth 2.5\plugins\tomsmocomp.dll")
loadplugin("C:\AviSynth 2.5\plugins\kerneldeint.dll")
loadplugin("C:\AviSynth 2.5\plugins\mpeg2dec.dll")
loadplugin("C:\AviSynth 2.5\plugins\mpeg2dec3.dll")
mpeg2source("C:\KORN_LIVE_DISC1\VIDEO_TS\KoRn - Live.d2v",CPU=4,iPP=true)
converttoyuy2(interlaced=true)
restore24(tomsbobsoft(last),bobmatcher(last))
edit4: ok i see you have changed the dlls that needed to loaded
scharfis_brain
18th April 2004, 22:40
Okay, does that work for you?
I've just cleaned up the post above. I didn't change anything important,
I've just knocked out some dlls because they aren't needed anymore.
EDIT: be sure to set the setmemorymax(x) correctly.
x should be about 2/3 of your RAM. If your have 384 MB of RAM, use setmemorymax(256).
(If x is set too high, the encoding process will end in a very funny harddrive swapping party :) )
Dallemon
18th April 2004, 22:48
i hate to say this... but no :(
and changed the mem max to 340 :)
edit: well you corrected the smartdecimate ;) it was loadplugin and should have been loadcplugin (which it is now)
scharfis_brain
18th April 2004, 23:06
and does it work now?
hint: not only post, what you did, additionally post, whether it worked or not!
Dallemon
18th April 2004, 23:11
i said it didnt work....
Okay, does that work for you?
i hate to say this... but no
scharfis_brain
18th April 2004, 23:27
then tell me your error-message, word by word and char by char!
are you just to lazy to write, or do you want to make me angry?
Dallemon
18th April 2004, 23:31
just doing it to piss you off... j/k
sry i missunderstood you
DEdgeMask: Needs YV12 data
(C:\AviSynth 2.5\scripts\restore24.avs, line 25)
(C:\AviSynth 2.5\test.avs, line 13)
scharfis_brain
18th April 2004, 23:43
did you tried applying
work.converttoyv12().dedgemask(...)
within the restore24-code?
you have to use converttoyuy2(interlaced=true) before all deinterlacing and restore24'ing because the built in deinterlacers need it.So do not change the external things.
Dallemon
18th April 2004, 23:46
no i havent tried that since i would concider myself a noob at this still (2nd project) (and the first one wasnt this troublesome :()
so i wouldnt think to mess around in other ppls scripts, but im gonna try what you suggested and report back
EDIT: yay it works (i think), well it didnt complain about anything ^^
so should i just add what filters i wanna use after the "restore24(tomsbobsoft(last),bobmatcher(last))"?
and thx a lot for the help :D
EDIT2: would this be a valid script?
setmemorymax(340)
import("C:\AviSynth 2.5\scripts\restore24.avs")
import("C:\AviSynth 2.5\scripts\bobmatcher.avs")
loadplugin("C:\AviSynth 2.5\plugins\masktools.dll")
loadplugin("C:\AviSynth 2.5\plugins\avisynth_c.dll")
loadcplugin("C:\AviSynth 2.5\plugins\smartdecimate.dll")
loadplugin("C:\AviSynth 2.5\plugins\tomsmocomp.dll")
loadplugin("C:\AviSynth 2.5\plugins\kerneldeint.dll")
loadplugin("C:\AviSynth 2.5\plugins\mpeg2dec.dll")
loadplugin("C:\AviSynth 2.5\plugins\mpeg2dec3.dll")
mpeg2source("C:\KORN_LIVE_DISC1\VIDEO_TS\KoRn - Live.d2v",CPU=4,iPP=true)
converttoyuy2(interlaced=true)
restore24(tomsbobsoft(last),bobmatcher(last))
KernelDeint(order=1,threshold=1,sharp=true)
VagueDenoiser(1.5,1,7,true,false,false)
Crop(6,4,708,570)
LanczosResize(640,352)
Undot()
EDIT3: just want to say sry for being so n00bish but i havent worked with "import" before :/ so i just wanna be sure
EDIT4: and if this script is ok, kan i then just start the encoding process? (i.e. open the avs in vdm and do the first pass, then second)
scharfis_brain
19th April 2004, 00:10
do NOT place a deinterlacer after Restore24.Restore24 returns a well deinterlaced, non combed video!
at first, you shouldn't apply any filtering at all.
just let the last line be restore24(...)
then open this avs into vdub and scroll to a place with good motion, mark this part (maybe a minute or so) and encode only this part with a encoder of your choice (doesn't matter).
then open this encoded file and analyse it containing blends and stutters. if it is okay, you can set up your filtering.
Dallemon
19th April 2004, 00:14
heh thx, got a point there ;)
would have been a waste of time if it was b0rked :D
thx a lot for your help and for being so tolerant :)
EDIT: it worked :D no problems at all :)
J-Wo
22nd April 2004, 02:23
Wow this is one of the most confusing posts I have ever seen! Took me forever to navigate through the various pages, discover which code worked, and also track down all those odd avs plugins I have never used before.
Okay, after a lot of fiddling around I *finally* got this script to work. I have PAL source with interlacing, but I'm not certain what the best method was to remove the combs. I tried various permutations of fielddeinterlace, greedyhma, and smoothdeinterlace. All of them did a good job of removing the combing, but what I was left with was blended fields. They were most noticeable during motion scenes as "motion blur" or "ghosting".
Anyway I was referred to this thread from another forum. After getting Restore24 to work (based on Shariff_Brain's mods) I notice that my video *does* have less interlaced frames, but the ones that aren't have MUCH larger combing than before. It's like the wrong fields were added together or something. I'm not very technical so I can't quite explain how to describe it!
Can anyone make some suggestions to me? Any modifications to the restore24 I should try? Or perhaps try a different filter altogether?
BTW my source is an AVI from a PAL DVD. However the original material I know is american, thus NTSC. Not too sure if the interlacing came from the PAL DVD itself or from the person who made the AVI into 25 fps.
J-Wo
22nd April 2004, 04:31
I loaded up my movie in virtualdub and started to examine the interlacing frame by frame. What I notice is a pattern that starts with 1 frame progressive, 1 frame interlaced which repeats a total of 5 times, or 5x(1p,1i) followed by a long stream of ~11-13 interlaced frames, giving a pattern something like this:
p i p i p i p i p i i i i i i i i i i i i i
If I add a simple SeparateFields() to my script, I notice that the fields themselves exhibit combing, and that these combs appear much larger with SeparateFields than without.
Does this make sense to anyone? Hoping someone can help me!
scharfis_brain
22nd April 2004, 05:27
no chance here, getting something good out of this file, if even separatefields() shows combing.
your video has been resized. This made the interlacing go worse.
forget fixing this one. get the dvd and be happy.
J-Wo
22nd April 2004, 06:15
darn, I was afraid you might say that. As I mentioned earlier, a simple fielddeinterlace(blend=true) does a perfect job of getting rid of the combing, but then what I'm left with is a lot of blended frames and ghosting. Do you think I could use unblend or your script for unblendpattern?
scharfis_brain
22nd April 2004, 06:29
forget it. your avi is broken due to false image resampling.
before any unblending you have to deinterlace (without introducing new blending like blend=true does).
And I doubt, that kerneldeint / kernelbob will give a acceptable result.
Lefungus
25th April 2004, 19:04
Amazing filter !
I used to think blended interlaced PAL crap was impossible to recover, but i'm proven wrong :)
It's not perfect yet though, extremely slow and it miss sometimes, but it surely is promising !
Uanime5
24th February 2006, 16:58
I've already changed the main avs file to so that it reads 'aviSource' and made other relevent changes to it. How can I modify 'bobmatcher.avs' so it accepts avi files? The current bobmatch.avs I have is
# Test-Mask-Deinterlacer (for Restore24)
function Tomsbobsoft(clip c)
{ input=c.separatefields.tomsmocomp(1,-1,1)
a = getparity(input) ? input.selectodd : input.selecteven
b = getparity(input) ? input.selecteven : input.selectodd
a=stackvertical(a.crop(0,0,0,0-a.height),a.crop(0,0,0,-0))
output = getparity(input) ? interleave(b,a) : interleave(a,b)
output.assumeframebased
}
# Pre-Deinterlacer for Bobmatcher
# can also be used as standalone-bobber
# Kernelbob, using kernel-interpolation for achieving
# a higher resolution at slow-, and nonmoving locations
function kernelbob(clip a, int th)
{ ord = getparity(a) ? 1 : 0
f=a.kerneldeint(order=ord, sharp=true, twoway=true, threshold=th)
e=a.separatefields.trim(1,0).weave.kerneldeint(order=1-ord, sharp=true, twoway=true, threshold=th)
interleave(f,e).assumeframebased
}
# TMCbob, uses tomsmocomp-interpolation for getting
# diagonal lines with reduced stairstepping
function TMCbob(clip c)
{ ord = getparity(c) ? 1 : 0
c = c.SeparateFields.TomsMoComp(1,-1,0)
c = stackvertical(c.crop(0,0,0,1-c.height),c,c.crop(0,c.height-1,0,0))
evn = c.SelectEven
odd = c.SelectOdd
evn = (ord == 0) ? evn : evn.crop(0,0,1,0).addborders(0,0,0,1)
odd = (ord == 1) ? odd : odd.crop(0,0,1,0).addborders(0,0,0,1)
interleave(evn,odd).crop(0,0,0,-2).assumeframebased()
}
# Hehe, the TV-Simulator:
function TVdeint(clip clip, float kell)
{
clip=clip.addborders(0,4,0,4)
input=clip.converttoyuy2().separatefields()
blank=blankclip(selecteven(input))
even=interleave(selecteven(input),blank).weave()
odd =interleave(selectodd(input) ,blank).weave()
output=interleave(even,odd)
kell = (kell < 0 ) || (kell > 1) ? 0 : kell
(kell == 0) ? output : output.blur(0,kell).levels(0,1,255-int(128*kell),0,255)
crop(0,4,0,-4)
}
# And finally: the bobmatcher
function bobmatcher(clip fg, int "md", int "deintth", bool "showmask", bool "showmatch", bool "domatch",float "matchth", int "bobmethod")
{
# add borders to prevent the border-bug of motionmask
fg.AddBorders(8,0,8,0)
x1=last .ConvertToYV12(interlaced=true)
# set vars
md = default(md,3)
deintth = default(deintth,3)
# maskedtmc = default(maskedtmc,true)
matchth = default(matchth, 0.3)
showmask = default(showmask,false)
showmatch = default(showmatch,false)
domatch = default(domatch,true)
bobmethod = default(bobmethod,128)
# create bobbing motionmask
evn = x1.motionmask(md,deintth)
odd = x1.doubleweave.selectodd.motionmask(md,deintth)
mask = interleave(evn,odd)
# create bobbed clip
# bobmethod = 0 only uses kernelbob for getting the interpolated data
# bobmethod = 255 only uses TMCbob
# bobmethod = 1..254 uses a weighted mix of kernelbob and TMCbob for getting
# the interpolated data, 128 creates a 1:1-blend (default)
bobx = (bobmethod == 0 ) ? x1.kernelbob(5) :
\ (bobmethod == 255) ? x1.tmcbob() :
\ layer(x1.coverttoYUY2.kernelbob(5),x1.coverttoYUY2.tmcbob(),"add",level=bobmethod)
bobx = showmask ? bobx.coloryuv(gain_v=-48) : bobx
# create doubleweaved clip
douw = x1.doubleweave
douw = showmask ? douw.coloryuv(gain_u=48) : douw
# calculate smartbobbed streams:
# using previous field to get the interpolation of the current field
global out1 = maskedmix(douw,bobx.trim(1,0),mask)
# using next field to get the interpolation of the current field
global out2 = maskedmix(douw,bobx,mask).trim(1,0)
# setup mask for matching
global mask1 = mask.converttoyv12
global mask2 = mask1.trim(1,0)
# if masks are to similar (No Matching), blend both bobbed streams together for best output
global outnomatch = overlay(out2,out1,opacity=0.5,mode="blend")
# create debug messages
global outnomatch = showmatch ?
\outnomatch.subtitle("Using Both Fields - No Matching") : outnomatch
global out1 = showmatch ? out1.subtitle("Using Previous Field") : out1
global out2 = showmatch ? out2.subtitle("Using Next Field") : out2
# do the matching
global outmatch = domatch ? ConditionalFilter(out1, out2, "averageluma(mask1)",
\ "<", "averageluma(mask2)") : outnomatch
# disable matching, if lumadifference between the prev-mask and the next-mask is smaller than p*100 percent
global p = matchth
o6 = ScriptClip(blankclip(out1), "outx")
o8 = FrameEvaluate(o6, "global outx = ((AL1*(1+p) > AL2) && (AL2 > AL1*(1-p))) ? outnomatch : outmatch")
o9 = Frameevaluate(o8,"global AL1 = averageluma(mask1)")
out= Frameevaluate(o9,"global AL2 = averageluma(mask2)")
# do some final things to get the output in sync with other bobbers
out = bobx.trim(0,-3) + out.assumeframebased().trim(2,0)
out.Crop(8,0,-8,0)
}
However I have a problem with the two lines ' interleave(evn,odd).crop(0,0,0,-2).assumeframebased()' and
' \ layer(x1.coverttoYUY2.kernelbob(5),x1.coverttoYUY2.tmcbob(),"add",level=bobmethod)'.
The error message is:
Interleave: the videos must be of the same size
How can I solve this problem?
scharfis_brain
24th February 2006, 17:05
Do mot mess with that old stuff. it has no use anymore and has been replaced by other - much better - algorithms
Uanime5
25th February 2006, 21:36
Where can I find the a better algorithm?
Where can I find the a better algorithm?
My thoughts exactly. I am a n00b what comes to video encoding, I have those problematic DVD's with "stuttering", and looking for an easy way to fix them -> convert them to XviD.
I tried that restore24 script without success, after first fighting with those incompatible versions, put everything together, all I got was errors after errors.
I would appreciate if someone could point me a guide which not only has links to compatible plugin etc. versions, but also explains the procedure step by step so even I can understand it :)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.