Deinterlacing Full Field Blended Footage

Locked
User avatar
Uanime5
Joined: Fri Aug 15, 2003 6:11 am
Contact:
Org Profile

Deinterlacing Full Field Blended Footage

Post by Uanime5 » Sat Feb 18, 2006 6:19 pm

Several of my AMVs have Full Field Blended Footage interlacing (http://www.animemusicvideos.org/guides/ ... ocId981000) (I know its this because I have tried a lot of deinterlacing methods recommended in the guides and only Full Field Blended Footage methods have any effect).

In my search for a way to deinterlace my AMVs I went to this website
http://forum.doom9.org/showthread.php?s=&threadid=61792
and copied their program for cleaning up DVD footage. However I am having some problems. I will post the files I have used and what I have done. The I will explain my problem.

This is the main avs file.

Code: Select all

setmemorymax(256)
import("C:\My Videos\my amv\restore24.avs")
import("C:\My Videos\my amv\bobmatcher.avs")

loadplugin("C:\Program Files\AviSynth 2.5\plugins\masktools.dll")      
loadplugin("C:\Program Files\AviSynth 2.5\plugins\avisynth_c.dll")
loadcplugin("C:\Program Files\AviSynth 2.5\plugins\smartdecimate.dll")

loadplugin("C:\Program Files\AviSynth 2.5\plugins\tomsmocomp.dll")     

loadplugin("C:\Program Files\AviSynth 2.5\plugins\LeakKernelDeint.dll")  
loadplugin("C:\Program Files\AviSynth 2.5\plugins\mpeg2dec.dll")
loadplugin("C:\Program Files\AviSynth 2.5\plugins\mpeg2dec3.dll")

mpeg2Source("C:\My Videos\AMV clips\special olympics 2.d2v" cpu=4,iPP=true)

converttoyuy2(interlaced=true)

restore24(tomsbobsoft(last),bobmatcher(last))
If I change 'mpeg2' and 'd2v' to 'avi' and delete the 'cpu=4,iPP=true' I get this error message
Motion mask: input clip must be YV12'
If I change the ‘yuy2’ to ‘YV12’ I get the error message
‘Crop: YV12 images can only be cropped by even numbers (bottom)
It also says that there is an error with line 7 of ‘bobmatcher.avs’ (shown below).

Code: Select all

 # 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,1-a.height),a.crop(0,0,0,-1))
	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,1,0,0).addborders(0,0,0,1)
	odd = (ord == 1) ? odd : odd.crop(0,1,0,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 .converttoyuy2(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.kernelbob(5),x1.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)
}
Basically if I change some on the 1’s to 0’s I stop getting these error messages. However I get an error message at line 88 which reads:
Layer only support RGB32 and YUY2 formats
I tried converting my AMV to both of these setting using Virtualdub and an uncompressed codex. However I have not overcome this problem.

I then tried to convert my AMV into an MPEG2 and a vob file (as this program was meant to work with DVD footage). However Virtualdub will not allow me to run the script with these files.

Does anyone know how I can alter this script to deinterlace avi files or how I can turn my avi's into something that this program will accept? (In bold so you know what my question is)

User avatar
badmartialarts
Bad Martial Artist
Joined: Sat Oct 25, 2003 5:31 am
Location: In ur Kitchen Stadium, eatin ur peppurz
Org Profile

Post by badmartialarts » Sun Feb 19, 2006 12:34 am

You're gonna have to convert back and forth from RGB32 and YV12. Every time you get an error saying "Can't do this in YV12" put a ConvertToRGB32() in front of that line. When it says "Need YV12" put a ConvertToYV12() in front of that one. Repeat as necessary. Yeah, that's the lazy way to do it, but I'm known for laziness.
Life's short.
eBayhard.

User avatar
Scintilla
(for EXTREME)
Joined: Mon Mar 31, 2003 8:47 pm
Status: Quo
Location: New Jersey
Contact:
Org Profile

Re: Deinterlacing Full Field Blended Footage

Post by Scintilla » Sun Feb 19, 2006 2:32 am

Uanime5 wrote:

Code: Select all

mpeg2Source("C:\My Videos\AMV clips\special olympics 2.d2v" cpu=4,iPP=true)
I don't know if this will help, but you're missing a comma before "cpu".
ImageImage
:pizza: :pizza: Image :pizza: :pizza:

User avatar
Uanime5
Joined: Fri Aug 15, 2003 6:11 am
Contact:
Org Profile

Re: Deinterlacing Full Field Blended Footage

Post by Uanime5 » Sun Feb 19, 2006 10:12 am

Scintilla wrote:
Uanime5 wrote:

Code: Select all

mpeg2Source("C:\My Videos\AMV clips\special olympics 2.d2v" cpu=4,iPP=true)
I don't know if this will help, but you're missing a comma before "cpu".
I delete the whole 'cpu=4,iPP=true' line because I'm using an avi source.

User avatar
Uanime5
Joined: Fri Aug 15, 2003 6:11 am
Contact:
Org Profile

Post by Uanime5 » Sun Feb 19, 2006 11:26 am

Sorry to doublepost.
badmartialarts wrote:You're gonna have to convert back and forth from RGB32 and YV12. Every time you get an error saying "Can't do this in YV12" put a ConvertToRGB32() in front of that line. When it says "Need YV12" put a ConvertToYV12() in front of that one. Repeat as necessary. Yeah, that's the lazy way to do it, but I'm known for laziness.
I'm having a problem with this area.

Code: Select all

#	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.kernelbob(5),x1.tmcbob(),"add",level=bobmethod)
	bobx 	= showmask ? bobx.Coloryuv(gain_v=-48) : bobx
It won't let me change 'x1=last .ConvertToYV12(interlaced=true)' to anything else but it says that the layer in '\ layer(x1.kernelbob(5),x1.tmcbob(),"add",level=bobmethod)' must be YUY2 or RGB32. Simply adding ConvertToRGB32() or ConvertToYUY2() does not fix this problem. What should I do?

User avatar
Scintilla
(for EXTREME)
Joined: Mon Mar 31, 2003 8:47 pm
Status: Quo
Location: New Jersey
Contact:
Org Profile

Post by Scintilla » Sun Feb 19, 2006 11:58 am

Change that line to
layer(x1.<b>ConvertToYUY2().</b>kernelbob(5),x1.<b>ConvertToYUY2().</b>tmcbob(),"add",level=bobmethod)
, perhaps?
ImageImage
:pizza: :pizza: Image :pizza: :pizza:

User avatar
Uanime5
Joined: Fri Aug 15, 2003 6:11 am
Contact:
Org Profile

Post by Uanime5 » Tue Feb 21, 2006 3:54 am

That did work but now I have another problem with the same line.

Code: Select all

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,1,0,0).addborders(0,0,0,1)
   odd = (ord == 1) ? odd : odd.crop(0,1,0,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 
The problem involves 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 video must be the same size
Any ideas about how I solve this problem?

Locked

Return to “Video & Audio Help”