VideoHelp Forum
+ Reply to Thread
Results 1 to 13 of 13
Thread
  1. Is there a script for AviSynth that will do chroma keying?
    Quote Quote  
  2. Hi,

    I'm not sure if you're talking the same thing here, but have you tried using
    the chroma smoother fitler built-into virtualdub v1.5.10 ??

    It has 6 chroma settings.. including one for DV (4:1:1) but it has to be an
    honest suffer of the chroma bug to work (be noticable) .

    -vhelp
    Quote Quote  
  3. Free Flying Soul liquid217's Avatar
    Join Date: Feb 2002
    Location: United States
    Search Comp PM
    ColorKeyMask(clip clip, int color, int tolerance)

    the selected color will then be transparent. Now just layer that clip with another clip, and you got it. Here's an example:
    Code:
    clip1=colorbars(720,480).converttorgb32()
    
    transparent=resetmask(clip1).colorkeymask($0DB40C, 128)
    
    clip2=version().bicubicresize(720,480).converttorgb32()
    
    layer(clip2, transparent)
    This chromakeys out the green in the colorbars. This is layered on top of another clip (the version info)
    Quote Quote  
  4. Thanks liquid217.

    I'm new to AviSynth. Could you tell how to modify your code for my clips, how to change the color that will transparent, and how to adjust the tolerance incase my background isn't a solid shade of a color? My videos are 720 by 480.
    Quote Quote  
  5. Free Flying Soul liquid217's Avatar
    Join Date: Feb 2002
    Location: United States
    Search Comp PM
    Lets suppose that clip1 is you walking around on a green screen. Clip2 is a beautiful video of a beach somewhere.
    I would recommend you take a screenshot, and open the screenshot in a paint program to determine the appx color. (I used virtualdub to get the screenshot, and paintshop pro to determine the color). Then adjust the tolerance if you need more/less.

    Code:
    clip1=avisource("MeAndTheGreenScreen.avi").converttorgb32()
    transparent=resetmask(clip1).colorkeymask($0DB40C, 128)
    clip2=avisource("BeautifulScenery.avi").converttorgb32() 
    layer(clip2, transparent)
    Quote Quote  
  6. So if my green screen is slighly darker on one side than the other, I can just try to find a shade of green inbetween the light and dark side for the transparent color?
    Quote Quote  
  7. Free Flying Soul liquid217's Avatar
    Join Date: Feb 2002
    Location: United States
    Search Comp PM
    Yes, try to find a shade that it the average 'green', then adjust the tolerance. The larger the value in the tolerance, the more that will be transparent. Below is the function's documentation from www.avisynth.org

    ColorKeyMask [RGB32]

    ColorKeyMask(clip clip, int color, int tolerance)

    Sets the alpha-channel (similar as Mask does) but generates it by comparing the color. Each pixel with a color differing less than tolerance is set to transparent, otherwise it is left unchanged (it is NOT set to opaque).
    Quote Quote  
  8. Great thread. I looked into this a while back with no results. My questions is, what makes "green" equate to $0DB40C? What's blue then? etc, etc...
    Quote Quote  
  9. Free Flying Soul liquid217's Avatar
    Join Date: Feb 2002
    Location: United States
    Search Comp PM
    $0DB40C is the color if the 'green' portion of the colorbars example. pure green would be $00ff00 Blue would be $0000ff. As I mentioned before, take a screenshot and open in a paint program to determine the color needed to key out. (Paintshop pro has a tool for determining the color of a pixel.)
    Quote Quote  
  10. The gimp also has a tool for picking a color. It will give it to you in three values, ie. Red=97 Green=176 Blue=111. There is a handy converter on the web that will change these numbers into a hex number for you. It is found at http://www.321webmaster.com/colorconverter.php

    Thanks for this post. It has helped me out a lot.
    Quote Quote  
  11. Cool. Thank you very much for the interesting thread. I found the function in the documentation but couldn't figure out the variables.

    On a related issue, I don't suppose it would be possible to lift out (to a transparent background) objects moving on a multicolored background if the contrast between them and the background was sufficient? Weeding out certain colours will weed them out globally, from both the objects and the background.

    Is there some nifty trick for tracking movement of a certain object and "lifting it out" the rest of the clip?
    Quote Quote  
  12. Free Flying Soul liquid217's Avatar
    Join Date: Feb 2002
    Location: United States
    Search Comp PM
    I think it might be possible with the 'mask' function, but only if it meets the proper criteria. For example, suppose you have a camera on a tripod, filming a still set (nothing is moving in the frame). you can take athat one frame with nothing moving and use that as some type of base. you would then need some type of function that would compare the still image with the actual videoclip. Everything that is the same (or equal) make transparent, otherwise, let the video show through. Ideally, that function would create a alpha layer (black being transparent, and white being opaque) which could be used with the mask function.
    Masktools (a pluging package for avisynth) might have just the tool for that job, but I am not sure. If I have some time this week, ill look into it.
    Quote Quote  
  13. Interesting. I'll have to look into this, too. Thank you.
    Quote Quote  



Similar Threads