View Full Version : Clean DV Bluescreen/Greenscreen Composites?
KKLL
24th January 2004, 18:18
Are there any filters or scripts for simple blue/greenscreen compositing with AviSynth?
mf
24th January 2004, 21:29
ColorKeyMask (http://www.avisynth.org/index.php?page=Layer).
Mug Funky
25th January 2004, 14:28
there's a better way (i wrote a script for it...)
depending on whether it's green or blue screen, you'll want to grab out one of the colour channels and make it a mask.
do this in a few stages...
firstly, make sure your DV decoder is not b0rking the colour up (most do, but setting ffdshow to decode DV with "simple" iDCT type, then using directshowsource is the nicest in my experience)
then when you import into avisynth you'll be getting a YV12 clip.
run something like this script into virtualdub:
directshowsource("thing.avi")
UtoY()
this will give you the U channel. if there's a nice big difference between foreground and screen, stay with it. otherwise replace UtoY() with VtoY() and see if that's got a higher contrast.
once you've found the best colour channel for your screen, use levels in virtualdub to get a solid black and white mask with a grey fringe.
then write down the levels setting you used. you may tweak this later on.
oh... poo. looks like overlay isn't treating masks properly... i'll have to get back to you with my script :) there's ways, but my preferred one doesn't seem to be working yet.
mf
25th January 2004, 14:31
@Mug Funky
Re-read the first post in the thread. "Simple". :D
Mug Funky
25th January 2004, 14:45
@mf... tried that. gives annoying hard edge (unless it's been changed without me knowing...)
try this:
fore=directshowSource("F:\captures\green screen.avi", audio=false).converttoyuy2(interlaced=true)
back=directshowSource("F:\captures\stuf.avi", audio=false).converttoyuy2(interlaced=true)
matte = fore.vtoy().converttoyv12()
matte = matte.separatefields().bilinearresize(fore.width,fore.height/2)
matte = matte.weave().levels(94,1,123,0,255)
overlay(back,fore,mask=matte.ColorYUV(levels="TV->PC"),opacity=1)
KKLL
25th January 2004, 17:15
fore=directshowSource("c:\myavi", audio=false).converttoyuy2(interlaced=true)
above line gives me an error about "audio false". Snipping it to:
fore=directshowSource("c:\myavi")
hangs VirtualDub.
Do I need a library or newer AviSynth?
mf
25th January 2004, 17:34
Originally posted by Mug Funky
@mf... tried that. gives annoying hard edge (unless it's been changed without me knowing...)
I know, but it's simple, and just works. Personally I'd use OverlayMask, but that's also not simple ;).
Mug Funky
28th January 2004, 09:06
you'll probably need a newer avisynth, or (if the DV avi is type-2) just change that line to AviSource("something.avi")
to do that you'll need a DV decoder in Video for Windows, not just directshow
sh0dan
28th January 2004, 09:19
Do you have a sample clip?
Backwoods
1st February 2004, 22:45
www.mikegetoffline.com/01-clean.avi
www.mikegetoffline.com/02-matte.avi
www.mikegetoffline.com/03-result.avi
Here are some DV clips, 01 being the background, 02 being the material to blue screen, and 03 being the result of blue screening in Adobe Premiere. I only blue screened half of the 01-clean.avi to show that in Premiere the material gets darker after blue screening. If AVISynth can do otherwise, that would be great. I've tried the filters mentioned in this thread with some good time spent on trial and error and I personally can not make the footage look seemless.
sh0dan
2nd February 2004, 05:26
Still not happy with it - but this is as far as I got before going to bed:
bg = DirectShowSource("C:\temp\matte\01-clean.avi")
orgmatte = DirectShowSource("C:\temp\matte\02-matte.avi")
matte = orgmatte.utoy()
matte = levels(matte, 110,1.0,250,0,255, coring=false)
matte = bicubicresize(matte, width(bg), height(bg)).converttoyv12()
black = blankclip(orgmatte)
deblued = overlay(orgmatte,black, mode="chroma", mask=levels(matte,0,1.0,64,0,255, coring=false))
matte = matte.invert()
overlay(bg, deblued, mask=matte)
Edit: Requires MaskTools (I should probably get started on an internal Invert function).
sh0dan
2nd February 2004, 15:00
Improved version:
bg = AviSource("01-clean.avi")
orgmatte = AviSource("02-matte.avi")
matte_y = orgmatte.utoy()
matte = levels(matte_y, 110,1.0,250,0,255, coring=false)
matte = bicubicresize(matte, width(bg), height(bg)).converttoyv12()
mat = levels(matte_y, 110,1.0,240,0,255, coring=false).coloryuv(cont_y=128)
blue = orgmatte.crop(0,0,32,32).bicubicresize(width(bg), height(bg))
blue = blue.coloryuv(off_y=-256, off_u=-128)
blue = blue.utoy()
m_u = orgmatte.utoy()
deblued = overlay(m_u, blue, mode="subtract", mask=mat)
ytouv(deblued, orgmatte.vtoy(), orgmatte)
overlay(bg, last, mask=invert(matte))
On the supplied material it works nicely - it might however need adjustment for other material.
mf
2nd February 2004, 15:35
Originally posted by sh0dan
Edit: Requires MaskTools (I should probably get started on an internal Invert function).
If you don't have MaskTools, you could always put this in a .avsi:
function Invert(clip c) { c.Levels(0, 1, 255, 255, 0) }
;)
Btw, I wonder about 2 things...
1) Do scripted functions have "priority" over DLLs, when autoloading is enabled?
2) If you call a function from an identically named script function, it can't call itself, right? So will it call the next-best match (in this case DLL-contained) or throw an error?
Cause if these are true, you could do:
function Invert(clip c) {
Try() { c.Invert() }
Catch(err_msg) { c.Levels(0, 1, 255, 255, 0) }
}
:D
hanfrunz
3rd February 2004, 23:04
hi,
a friend of mine is a "senior inferno artist" (www.discreet.com) and told me that keys work better for DV material, if you digitise it analog (analog component signal not cvbs!). Then it gets a little blury, which makes it easier to key...
hanfrunz
sh0dan
4th February 2004, 00:05
Originally posted by mf
Btw, I wonder about 2 things...
1) Do scripted functions have "priority" over DLLs, when autoloading is enabled?
2) If you call a function from an identically named script function, it can't call itself, right? So will it call the next-best match (in this case DLL-contained) or throw an error?
1) Yes.
2) It would probably invoke the previously defined Invert in your case (ie. actually work). Something you should test, though.
Mug Funky
6th February 2004, 13:16
@ hanfrunz: wouldn't there be unacceptable quality loss there? the blurring could be simulated with blur filters i'm sure (if it's really necessary...).
hehe. if i'm using inferno i'd be working with better source than DV
hanfrunz
6th February 2004, 19:17
@ hanfrunz: wouldn't there be unacceptable quality loss there? the blurring could be simulated with blur filters i'm sure (if it's really necessary...). hehe. if i'm using inferno i'd be working with better source than DV
the quality loss is not that big as you think, if you use an analog YCrBr Signal. Its just a quick and easy realtime blur effect :) And of course DV is not 8k Film :)
hanfrunz
Mug Funky
8th February 2004, 16:39
oh... i was thinking s-vhs, which seems to always give me insane crosstalk. so long as it's clean blur...
8k film... *drools*
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.