Maybe my Googling skills are poor, but I'm having a hard time finding any tutorial on how to create green screen movies with avisynth. I searched this forum, but this is the closest thing I could find that was of help:
https://forum.videohelp.com/threads/304286-My-first-attempt-at-a-bluescreen-chroma-key
I tried to use that guy's code to create my own green screen with avisynth, but it didn't work.
This guy claims that he used Avisynth to create the very professional looking green screen video here: http://www.youtube.com/watch?v=RXByaCFgIHc
I have a green screen video of a girl dancing. I downloaded it from the internet. So I don't need instructions on how to film a green screen video, since I already have the green screen footage. What I need help with is figuring out how to get avisynth to take a background clip and overlay the green screen video on top of it.
Fyi, my knowledge of Avisynth is at the beginner's level. I've successfully used the program to join 9 videos into 1 video, and other basic stuff like cropping, resizing, etc.
Any help would be appreciated.
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 18 of 18
Thread
-
-
The last post in the thread linked below may be helpful to you. I experimented with the script several years ago (mainly just to see it work using AviSynth) and tweaked settings of RGB, opacity, etc. with varying results.
http://forum.doom9.org/showthread.php?t=157013 -
Thanks for the info. russell_t!
The script looks promising, but I'm having a hiccup with RGB32. The script says that the green screen video must be RGB32 (in bold below):
Code:clip1 = AviSource("background.avi") clip2 = AviSource("greenscreen186by300.avi") #clip2 must be RGB32 maskclip = ColorKeyMask(clip2, $125d12, 40) # Second argument is RGB into hexadecimal numbers. Third argument is a tolerance. Overlay(clip1, clip2, mask=ShowAlpha(maskclip), mode="blend", opacity=1)
I tried this, to no avail:
Code:clip2 = AviSource("greenscreen186by300.avi").ConvertToRGB32()
-
NV12 is treated the same as YV12 in avisynth. It's essentially the same thing, but U, V planes are interleaved and the memory layout is different
ConvertToRGB32() should work
Code:AviSource("greenscreen186by300.avi").ConvertToRGB32() Info()
Post the exact error message verbatim, and your avs script verbatim -
I'm not sure what you mean about color space.
There's no error message. The background plays, but the green screen overlay doesn't appear. I've tried running the script in both VirtualDub and MediaPlayerClassic, but the same results. I have the script and the videos in the same folder, so it's not an issue of the files not being where they should be or named incorrectly.
Here's the code:
Code:clip1 = AviSource("background.avi") clip2 = AviSource("greenscreen186by300.avi").ConvertToRGB32() #clip2 must be RGB32 maskclip = ColorKeyMask(clip2, $125d12, 40) # Second argument is RGB into hexadecimal numbers. Third argument is a tolerance. Overlay(clip1, clip2, mask=ShowAlpha(maskclip), mode="blend", opacity=1)
I don't know if the following information will be useful, but thought I should add it:
background clip: 23.98fps
green screen clip: 29.97fps
background clip: 608x352
green screen clip: 186x300Last edited by vidvidhh; 20th Jan 2014 at 15:56.
-
Could it be a case of needing to "tweak the settings of RGB, opacity, etc", as Russell stated?
-
Yes, adjust the hex value, maybe increase the tolerance
If you open the greenscreen video in avspmod, there is a hex color picker (mouse over some areas of the greenscreen, and it will show the corresponding hex values) . You can set it to show RGB values as well
It's working ok here on some test videos. If you still can't get it to work, post a small sample video
There is another avisynth plugin, colorscreenmask, as well
Other free non avisynth methods cinegobs keyer, blender. Blender will get you the best results out of the free methods by far, but learning curve is steep. It will get you similar results to professional keyers like keylight, primatte -
@vidvidhh - For whatever it's worth, the two video clips in my experiment had the same frame rate and resolution. I'm uncertain if they need to be the same in this scenario, but I know they are a necessity in other areas of AviSynth usage, so it may be true in this case as well (perhaps poisondeathray or someone else can assist here). The RGB tweaking I performed was on the hex value of the green background (in ColorKeyMask). As I recall, I had downloaded a color chart with corresponding hex values, then used some of those values in various AviSynth scripts to see how the changes would effect keying. If you don't make the progress you'd like with AviSynth, then the CineGobs Keyer might be worth a look. Although no longer in development, it is still available for download. CineGobs doesn't support audio, but demuxing the audio from your source video and muxing it into your keyed video would be a possible option.
Edit: thanks poisondeathray for your post above. -
I was able to get it working using a script I found on this thread: https://forum.videohelp.com/threads/184560-AviSynth-Chroma-Key
Code:clip1=avisource("greenscreen186by300.avi").converttorgb32() transparent=resetmask(clip1).colorkeymask($0DB40C, 128) clip2=avisource("background.avi").converttorgb32() layer(clip2, transparent)
One thing that's different about this script is that clip1 is the green screen video and not the background.
I went back to the older script and switched some code around:
Code:clip1 = AviSource("greenscreen186by300.avi").ConvertToRGB32() clip2 = AviSource("background.avi").ConvertToRGB32() #clip2 must be RGB32 maskclip = ColorKeyMask(clip2, $0DB40C, 128) # Second argument is RGB into hexadecimal numbers. Third argument is a tolerance. Overlay(clip1, clip2, mask=ShowAlpha(maskclip), mode="blend", opacity=1)
I also changed $125d12 to $0DB40C.
So I think I'll use the script I found above, which gives much better results. -
Just to show you the difference with both codes:
With code Russell recommended:
Code:clip1 = AviSource("greenscreen186by300.avi").ConvertToRGB32() clip2 = AviSource("background.avi").ConvertToRGB32() #clip2 must be RGB32 maskclip = ColorKeyMask(clip2, $0DB40C, 128) # Second argument is RGB into hexadecimal numbers. Third argument is a tolerance. Overlay(clip1, clip2, mask=ShowAlpha(maskclip), mode="blend", opacity=1)
You can see that the green appears/disappears in places and the dancing girl appears/disappears in place. Also the video takes on the dimensions of the smaller green screen vid and not the bigger background vid.
With the code I got from this thread:
Code:clip1=avisource("greenscreen186by300.avi").converttorgb32() transparent=resetmask(clip1).colorkeymask($0DB40C, 128) clip2=avisource("background.avi").converttorgb32() layer(clip2, transparent)
I put a black bar over the naughty bits.
It's a bit rough, but at least she mostly appears and the video has the dimensions of the background video. -
Change the Overlay() order (ie.. Overlay(clip 2, clip1) )
The syntax is Overlay(background image, foreground image, x=, y=) . You can reposition the foreground image by using x=, y= . x=0,y=0 is the top left corner . You can do the same with layer() if you wanted to move the girl to the middle
Overlay() takes the properties of the background clip (the clip you specify first). So different fps, different lenght, etc.. means it takes the background video's fps, length etc... -
Thanks poisondeathray, but how do I incorporate that overlay positioning code into the following code?
Code:clip1=avisource("greenscreen186by300.avi").converttorgb32() transparent=resetmask(clip1).colorkeymask($0DB40C, 128) clip2=avisource("background.avi").converttorgb32() layer(clip2, transparent)
-
The same way . Layer() uses almost the same syntax as Overlay()
For example, if you wanted to move the girl 50 pixels to the right, 10 pixels down
layer(clip2, transparent, x=50, y=10) -
I just made a green screen in CineGobs and it's pretty easy. There are no invisible bits, but the edges of the dancing girl were ragged. But I was able to overcome that somewhat by using the blur function.
CineGobs is a neat tool I intend to explore. But I still would like to pursue AviSynth and maybe become sophisticated enough with it to produce green screens as good as the guy in the YouTube clip I posted in the OP. -
Honestly - you will have a very difficult time getting awesome chroma key results in avisynth unless your lighting was perfect. Good lighting on the greenscreen shoot makes everything easy. Avisynth is great for many things, unfortunately chroma/color keying is not one of them
There are a lot of "tricks" that FX people use to get good results. The "key" (nice pun) is trying to preserve edge detail. Unless your lighting was perfect, often you have to use multiple keys and composites with masks. It's just too difficult to do that sort of thing in avisynth . Much easier to do in other programs. It's difficult to address green spill in avisynth as well -
Another reason you're probably having a very difficult time - your greenscreen shot is low resolution, probably 4:2:0, also probably full of compression artifacts
If your naming is correct, 186x300 is tiny, tiny. The chroma resolution would be 93x150 for 4:2:0. It's difficult to get tight around the subject and there will be a ring of ugly "crunchiness" -
I'll take your advice and focus my attention on Cinegobs for keying. I've been playing around with Cinegobs and the results are much better, since it has lots of controls to tweak things.
A higher resolution version, with a scene from Blade Runner as the background:
Next step is figuring out how to get the background to not scrunch up to the dimensions of the green screen layer.
Similar Threads
-
Adjust Red Green Blue in Avisynth in YV12?
By VideoFanatic in forum RestorationReplies: 2Last Post: 23rd Aug 2013, 11:42 -
Avidemux Green Screen
By FrozenInferno in forum Video ConversionReplies: 4Last Post: 2nd Apr 2011, 23:31 -
Underwater Green Screen
By kccannon in forum EditingReplies: 6Last Post: 21st May 2009, 20:35 -
Funny green screen
By timmythesaint in forum Newbie / General discussionsReplies: 18Last Post: 14th Apr 2009, 15:41 -
avisynth tutorial
By pitaridis in forum EditingReplies: 1Last Post: 2nd Feb 2009, 07:46