Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Display Modes
Old 3rd November 2004, 16:38   #21  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,510
@joshbm: my interpretation of MugFunky's mvbob() currently is limited to TFF-video.
If you work with BFF-Video, you need to place doubleweave().selectodd() before calling mvbob1()

@MugFunky: I'll try the new version with the changed mvtools-syntax.
(I was too lazy to implement this myself, I was sure, you would do it )

I also have an Idea in mind to detect and knock out artifacts caused by motion compensation.

currently, you estimate motion using the half-sized bobbed clip and compensate motion on the bare fields.

to detect artifacts, one will need to compensate the bobbed clip, too (fwd AND bwd)
than compare the compensated frames to the original frame.
if the deviation is bigger than an certain threshold, one has to use the bobbed pixels instead of the mocomped ones for such detected areas.

I'll try to script such a detection. but do not count on my sucsess.
The things I tested so far showed, that mocomping introduces a lot of noise the the subtraction, so detection may hard to realize.

I do not have enough space available for that clip anymore.
PM me, if you want to get it transferred using another way.
It is about 20MB 640x480@29.97 fps YUY2-MJPEG-avi.
I found it somewhere here on the forums, but don't know anymore where it was.
This clip is my all-purpose-testclip. Because it:
- is interlaced
- has static parts with max. vertical detail
- has rainbowing (to confuse deinterlacers)
- has some little grain (try to denoise it without smearing the low contrasted background!)
- has loooong smooth camera-pans
- has a rapid zoom
- has clear defined diagonals (visualize edge directed interpolation)
- is NTSC (searching for a good way to make crisp & smooth PAL out of it)

Maybe I'll try to setup another account for hosting it.
__________________
Don't forget the 'c'!

Don't PM me for technical support, please.
scharfis_brain is offline   Reply With Quote
Old 3rd November 2004, 20:55   #22  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,510
for those, who don't trust in static images.
here is a sample video:
http://home.arcor.de/scharfis_brain/...mv-vs-krnl.avi
( left side == mvbob() ; right side == kernelbob() )

and here is the unprocessed video:
http://home.arcor.de/scharfis_brain/mvbob/doom9.avi

(deactivated, because else my 1GB/Month-Traffic limit is reached tomorrow, and we are just at the beginning of November!)

__________________
Don't forget the 'c'!

Don't PM me for technical support, please.

Last edited by scharfis_brain; 4th November 2004 at 20:33.
scharfis_brain is offline   Reply With Quote
Old 4th November 2004, 06:37   #23  |  Link
acrespo
Brazilian Anime Ripper
 
Join Date: Nov 2001
Location: Brazil
Posts: 233
I have tried on anime source and there are some interlaced artifacts with latest version of MVBob. Is MVBob recomend to anime or only to real image?
__________________
Capture cards:
Compro VideoMate Gold+ (Philips SAA7134 based) (not active)
Hauppauge PVR 150MCE (not active)
ATI TV Wonder Elite (active)
acrespo is offline   Reply With Quote
Old 4th November 2004, 08:04   #24  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,270
eek... i didn't get round to saying "you shouldn't use this on anime", but i guess i probably should have.

anime doesn't have "real" motion in the same way video does, so motion-compensation will artefact heavily on it.

if you like you can use it as a pre-processor for another deinterlacer, so long as it hits the right fields (the non-comped ones, not the mocomped ones). it's not much of a solution.

for anime i recommend Tdeint, personally (or simple IVTC, but Tdeint handles both).
__________________
interlace... right or wrong, just deal with it.
Mug Funky is offline   Reply With Quote
Old 4th November 2004, 20:28   #25  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,510
@Mug Funky: had you been able masking out mismatched areas?
all my tests so far show, that it will be a hard job to do so.

chroma-compensation currently seems to be broken...
It is really important to get the chroma compensated, too (of course with the same vectors as lume is compensated!)

This will be needed to create a good detection, cause luma-only masking will not catch all mismatches.
__________________
Don't forget the 'c'!

Don't PM me for technical support, please.
scharfis_brain is offline   Reply With Quote
Old 4th November 2004, 20:44   #26  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,510
there is an copy & paste error in mvbob!

you all need to correct this line:

odd2=mergeluma(odd2a,odd2b,0.5).mergechroma(odd2b,0.5)

then chroma looks better in the odd frames!
__________________
Don't forget the 'c'!

Don't PM me for technical support, please.
scharfis_brain is offline   Reply With Quote
Old 5th November 2004, 13:53   #27  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,270
thanks, scharfi

i knew if anyone found bugs, it'd be you (and i was kinda counting on it).

yeah, thinking about error detection, it's going to be a little tricky with the whole half-pixel offset stuff. perhaps keep the full-size bob handy and check it against that?
__________________
interlace... right or wrong, just deal with it.
Mug Funky is offline   Reply With Quote
Old 5th November 2004, 14:31   #28  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,510
fullsize checking is a very bad idea, cause it would detect the jaggyness of kerneldeint!

I prefer the half-size checking:


complete untested idea to check for errors, I had on my way home:

bob=c.kernelbob(order=order).verticalreduceby2()
...motion-analysis...

bobf=bob.mvcompensate(mvf)
bobb=bob.mvcompensate(mvb)

fwdmask=interleave(bob,bobf).motionmask(...).selecteven/odd ?

bwdmask=interleave(bob,bobb).motionmask(...).selecteven/odd ?
__________________
Don't forget the 'c'!

Don't PM me for technical support, please.
scharfis_brain is offline   Reply With Quote
Old 5th November 2004, 22:52   #29  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,126
Sorry for offtopic, but anybody can translate word "bob" to English? Is it some abbreviation B... O... B... ?
__________________
My Avisynth plugins are now at http://avisynth.org.ru
I usually do not provide a technical support in private messages.
Fizick is offline   Reply With Quote
Old 5th November 2004, 22:58   #30  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,510
please fill in the form with the word "bobbing" here:
http://www.thefreedictionary.com/
__________________
Don't forget the 'c'!

Don't PM me for technical support, please.
scharfis_brain is offline   Reply With Quote
Old 6th November 2004, 05:08   #31  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,270
hehe... that's an intricacy of english. "bob" is usually a person's name (typically your uncle's, though in my case it was my grandfather ).

full rate dumb deinterlace is nicknamed "bob" because the picture bobs up and down (sort of in the sense "bobbing along").
__________________
interlace... right or wrong, just deal with it.
Mug Funky is offline   Reply With Quote
Old 6th November 2004, 06:27   #32  |  Link
joshbm
Registered User
 
joshbm's Avatar
 
Join Date: Jun 2003
Location: Land of the Noobs & the Home of the Brave
Posts: 349
I've tested it and wow it's great! Hopefully you guys can resolve the chroma issue. Once it is fixed it will be my main bobber!

Thanks guys,
Josh
joshbm is offline   Reply With Quote
Old 6th November 2004, 14:32   #33  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,510
Code:
function MVbob(clip c,int "blksize", int "pel", int "lambda", int "thy", int "thc", int "bobth", bool "predenoise")
{

#disable all scene detection, because it is self-correcting 
sc=255 

# luma and chroma thresholds for correcting false detected motion 
thy=default(thy,20) 
thc=default(thc,10)

# threshold of kerneldeint
bobth=default(bobth,8)

#denoise the video for kerneldeint (better static areas for noisy video)
predenoise=default(predenoise,false)

blksize=default(blksize,8)
scd=(blksize==8)? 300 : round(300/4)
pel=default(pel,2)

#I decided lambda=0 being better, cause it stupidly trys to catch everything. errors are corrected afterwards.
lambda=default(lambda,0)

order=(c.getparity==true)? 1:0

bobx=predenoise ? c.temporalsoften(2,5,7) : c
bobx=bobx.kernelbob(order=order,threshold=bobth)
bobd=bobx.verticalreduceby2().lanczos4resize(c.width,c.height)


fields=c.separatefields().tomsmocomp(-1,-1,0)
fields1=fields

mvf=bobd.mvanalyse(blksize=blksize,pel=pel,isb=false,compensate=false)
mvb=bobd.mvanalyse(blksize=blksize,pel=pel,isb=true,compensate=false)

bobdf=bobd.mvcompensate(mvf,mode=1,thscd1=scd,thSCD2=sc)
bobdb=bobd.mvcompensate(mvb,mode=1,thscd1=scd,thSCD2=sc)
difff=interleave(bobdf,bobd).motionmask(thy1=thy,thy2=thy,thc1=thc,thc2=thc,thSD=sc).selectodd()
diffb=interleave(bobdb,bobd).motionmask(thy1=thy,thy2=thy,thc1=thc,thc2=thc,thSD=sc).selectodd()
diff=logic(difff,diffb,"OR")

even1=c.separatefields().selecteven()
odd1a=fields.mvcompensate(mvf,mode=1,thscd1=scd,thSCD2=sc)
odd1a=maskedmerge(odd1a,fields1,difff,y=3,u=3,v=3).selecteven()
odd1b=fields.mvcompensate(mvb,mode=1,thscd1=scd,thSCD2=sc)
odd1b=maskedmerge(odd1b,fields1,diffb,y=3,u=3,v=3).selecteven()
odd1=mergeluma(odd1a,odd1b,0.5).mergechroma(odd1b,0.5)
odd1=(order==1) ? odd1.separatefields().selecteven() : odd1.separatefields().selectodd()

even2=c.separatefields().selectodd()
odd2a=fields.mvcompensate(mvf,mode=1,thscd1=scd,thSCD2=sc)
odd2a=maskedmerge(odd2a,fields1,difff,y=3,u=3,v=3).selectodd()
odd2b=fields.mvcompensate(mvb,mode=1,thscd1=scd,thSCD2=sc)
odd2b=maskedmerge(odd2b,fields1,diffb,y=3,u=3,v=3).selectodd()
odd2=mergeluma(odd2a,odd2b,0.5).mergechroma(odd2b,0.5)
odd2=(order==1) ? odd2.separatefields().selectodd() : odd2.separatefields().selecteven()

even=interleave(even1,odd1)
even=even.weave()
odd=interleave(even2,odd2)
odd=odd.weave()


analysis=maskedmerge(bobx,diff,diff,y=3,u=3,v=3)
interleave(even,odd)

#stackhorizontal(last,analysis).converttoyuy2().bilinearresize(1280,height)
}
this is my first release of a full motion compensated fullframerate deinterlacer with correction of false matched motion.

there are a lot of things to improve:

- a much nicer error-replacement is needed
it curerently is stupid replacing with folled blending of bwd&fwd clip.
there must be a decision:
if only on clip (bwd or fwd) has errors on a certain pixel, return only the clip with the good pixel, instead of leaving the good clip as it is, repleace the other clip with some interpolated stuff and afterwards blend both together.

- I'll try if I can use another motionmasking, than kdeints internal one. it is far to sensible to noise.

- re-structurize the script
it has some naming issues, introduced by muf funky (odd isn't always odd and even not always even...)




I found, that a lambda of 0 gives the best motion estimation (especially for low contrastened areas!)
__________________
Don't forget the 'c'!

Don't PM me for technical support, please.
scharfis_brain is offline   Reply With Quote
Old 6th November 2004, 17:51   #34  |  Link
joshbm
Registered User
 
joshbm's Avatar
 
Join Date: Jun 2003
Location: Land of the Noobs & the Home of the Brave
Posts: 349
I get "Script error: motion mask does not have a named argument "thy1" (line 69).

I have the latest MVTools as well as MaskTools.

[fixed] lol.. Kind of weird but I capitalized it to thY1. It worked like a charm.

PS- This thing works awesome!

Regards,
Josh

Last edited by joshbm; 6th November 2004 at 17:57.
joshbm is offline   Reply With Quote
Old 6th November 2004, 20:59   #35  |  Link
Manao
Registered User
 
Join Date: Jan 2002
Location: France
Posts: 2,774
Quote:
Kind of weird but I capitalized it to thY1. It worked like a charm
What ? it shouldn't happen, avisynth is case insensitive.
Manao is offline   Reply With Quote
Old 7th November 2004, 02:23   #36  |  Link
joshbm
Registered User
 
joshbm's Avatar
 
Join Date: Jun 2003
Location: Land of the Noobs & the Home of the Brave
Posts: 349
I know, but it worked lol...

Maybe some character was incorrect, but it worked like a charm.

Regards,
Josh
joshbm is offline   Reply With Quote
Old 7th November 2004, 11:07   #37  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,510
another version:
- improved motion detection
- improved mismatch-replacement

Code:
function MVbob(clip c,int "blksize", int "pel", int "lambda", int "thy", int "thc", int "bobth", bool "predenoise", bool "showmask")
{

#Helper functions:

	function tmcstupid(clip c)
	{	input=c.converttoyuy2(interlaced=true).separatefields.tomsmocomp(1,-1,0)
		a = getparity(input) ? input.selectodd : input.selecteven
		b = getparity(input) ? input.selecteven : input.selectodd
		a=stackvertical(a.crop(0,0,0,1-a.height),a.crop(0,0,0,-1))
		output = getparity(input) ? interleave(b,a) : interleave(a,b)
		output.assumeframebased().converttoyv12()
	}

#disable all scene detection, because it is self-correcting 
sc=255 

showmask=default(showmask,false)

# luma and chroma thresholds for correcting false detected motion 
thy=default(thy,20) 
thc=default(thc,10)

# threshold of kerneldeint
bobth=default(bobth,8)

#denoise the video for kerneldeint (better static areas for noisy video)
predenoise=default(predenoise,false)

blksize=default(blksize,4)
scd=(blksize==8)? 300 : round(300/4)
pel=default(pel,2)

#I decided lambda=0 being better, cause it stupidly trys to catch everything. errors are corrected afterwards.
lambda=default(lambda,0)

#determine clip Fieldorder
order=(c.getparity==true)? 1:0

# create clip for motion analysis and hole-filling
bobx=predenoise ? c.temporalsoften(2,5,7) : c
bobx=bobx.kernelbob(order=order,threshold=bobth).undot()
bobd=bobx.verticalreduceby2()
#bobd=bobd.lanczos4resize(bobx.width,bobx.height) 
bobd=bobd.tomsmocomp(-1,-1,0).undot()

# create clip for motion compensation
fields=c.tmcstupid().undot()

# define clip for hole filling
fields1=bobx 

# create motion vectors
mvf=bobd.mvanalyse(blksize=blksize,pel=pel,isb=false,compensate=false,search=3,searchparam=10)
mvb=bobd.mvanalyse(blksize=blksize,pel=pel,isb=true, compensate=false,search=3,searchparam=10)

# detect mismatched areas of motion compensation
bobdf=bobd.mvcompensate(mvf,mode=1,thscd1=scd,thSCD2=sc)
bobdb=bobd.mvcompensate(mvb,mode=1,thscd1=scd,thSCD2=sc)
difff=interleave(bobdf,bobd).motionmask(thy1=thy,thy2=thy,thc1=thc,thc2=thc,thSD=sc).selectodd()
diffb=interleave(bobdb,bobd).motionmask(thy1=thy,thy2=thy,thc1=thc,thc2=thc,thSD=sc).selectodd()
diff=logic(difff,diffb,"OR")

# do the deinterlacing
even1=c.separatefields().selecteven()
odd1a=fields.mvcompensate(mvf,mode=1,thscd1=scd,thSCD2=sc)
odd1a=maskedmerge(odd1a,fields1,difff,y=3,u=3,v=3).selecteven()
odd1b=fields.mvcompensate(mvb,mode=1,thscd1=scd,thSCD2=sc)
odd1b=maskedmerge(odd1b,fields1,diffb,y=3,u=3,v=3).selecteven()
odd1=mergeluma(odd1a,odd1b,0.5).mergechroma(odd1b,0.5)
odd1=(order==1) ? odd1.separatefields().selecteven() : odd1.separatefields().selectodd()

even2=c.separatefields().selectodd()
odd2a=fields.mvcompensate(mvf,mode=1,thscd1=scd,thSCD2=sc)
odd2a=maskedmerge(odd2a,fields1,difff,y=3,u=3,v=3).selectodd()
odd2b=fields.mvcompensate(mvb,mode=1,thscd1=scd,thSCD2=sc)
odd2b=maskedmerge(odd2b,fields1,diffb,y=3,u=3,v=3).selectodd()
odd2=mergeluma(odd2a,odd2b,0.5).mergechroma(odd2b,0.5)
odd2=(order==1) ? odd2.separatefields().selectodd() : odd2.separatefields().selecteven()

even=interleave(even1,odd1)
even=even.weave()
odd=interleave(even2,odd2)
odd=odd.weave()

# output
interleave(even,odd)
analysis=maskedmerge(last.levels(0,1,255,0,200),diff,diff,y=3,u=3,v=3)
showmask ? analysis : last
}
usage: generally just mvbob()

but if static areas are flickering (logos, subtitles etc.)
one need to raise bobth and/or set predenoise to true.

if motion errors appear (small dot-like holes) one need to lower the bobth.

thy (luma) and thc (chroma) are used for artifact prevention from mvtools.
the lower those values, the more artifacts are catched, but the more detail as well.

blksize, pel and lambda should be clear.

within mvbob() I am currently using ,search=3,searchparam=10
it makes a better compensation, but is painly slow.
you may want to delete ,search=3,searchparam=10 from both line for better speed...
__________________
Don't forget the 'c'!

Don't PM me for technical support, please.
scharfis_brain is offline   Reply With Quote
Old 11th November 2004, 02:05   #38  |  Link
malkion
Registered User
 
Join Date: Feb 2004
Posts: 156
scharfis, I keep getting kernelbob does not have a named arguement "order"... with the last mvbob() script.

could you help?
malkion is offline   Reply With Quote
Old 11th November 2004, 10:20   #39  |  Link
Leak
ffdshow/AviSynth wrangler
 
Leak's Avatar
 
Join Date: Feb 2003
Location: Austria
Posts: 2,437
Quote:
Originally posted by malkion
scharfis, I keep getting kernelbob does not have a named arguement "order"... with the last mvbob() script.
What version of KernelDeint are you using? If you're using one of scharfis_brain's scripted versions, you might want to take a look here:

http://forum.doom9.org/showthread.php?s=&threadid=81322

This version definitely has an order parameter...
Leak is offline   Reply With Quote
Old 12th November 2004, 00:42   #40  |  Link
malkion
Registered User
 
Join Date: Feb 2004
Posts: 156
Thanks Leak...

I did find the problem when I had the time. It's my KernelBob function. I don't have the right version.

line 42 in MvBob

bobx=bobx.kernelbob(order=order,threshold=bobth).undot()

my KernelBob (most likely too outdated) has no such call in it...

function kernelbob(clip a, int "th",bool "mask")
{ mask=default(mask,false)
th=default(th,5)
ord = getparity(a) ? 1 : 0
f=a.kerneldeint(order=ord, sharp=true, twoway=false, threshold=th,map=mask)
e=a.separatefields.trim(1,0).weave.kerneldeint(order=1-ord, sharp=true, twoway=false, threshold=th,map=mask)
interleave(f,e).assumeframebased
}

you see? only mask and th values... Can someone post the latest KernelBob while I searches for it? Thanks.

(error msg in vdub)

kernelbob does not have a named argument "order"

[edit]

ok, fixed. Kernelbob found in kerneldeint.dll

Last edited by malkion; 12th November 2004 at 01:13.
malkion is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 20:17.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.