question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Green Screen Video

See original GitHub issue

Hello, I have succeed the fact to remove green on a image and to add a video in the background, but it doesn’t work with a green screen video. How can I achieve that ?

Here is the code that works:

ai=ImageClip("afterimage.png")
masked_clip = vfx.mask_color(ai, color=[0,255,1]) # for green

some_background_clip = VideoFileClip("random_stuff.mp4")

final_clip = CompositeVideoClip([some_background_clip, new],
                                    use_bgclip=True)
final_clip.duration=5
final_clip.write_videofile("afterimage.mp4", fps=30)

I want ai that is a ImageClip to be a VideoFileClip like a mp4 that as a green screen

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

5reactions
mowshoncommented, Jul 27, 2019

I did not find much information in the official documentation. Only from sourcecode: https://zulko.github.io/moviepy/_modules/moviepy/video/fx/mask_color.html#mask_color

import moviepy.editor as mp

clip = mp.VideoFileClip('/home/me/path/to/green-screen-video.mp4')
# Mountains background
background = mp.ImageClip('https://www.worldatlas.com/r/w728-h425-c728x425/upload/66/14/d8/kangchenjunga.jpg')

masked_clip = clip.fx(mp.vfx.mask_color, color=[0, 255, 8], thr=100, s=5)
# You can remove this resize, it's just for test...
masked_clip = masked_clip.resize(0.3).set_pos(('center', 'bottom'))

final_clip = mp.CompositeVideoClip([
    background,
    masked_clip
]).set_duration(1)

final_clip.write_videofile('test.mp4')

For each video I selected individually the parameters.

clip.fx(mp.vfx.mask_color, color=[0, 255, 8], thr=100, s=5)

I left the “s” parameter unchanged. I only changed “thr” from 1 to 150 … The higher the value of the parmatter, the better it removes the edges. But if it is too large, then the code starts to remove other colors besides green.

img2

0reactions
BenLorecommented, Mar 31, 2021

To be honest, I don’t know how to solve your problem, but I want to recommend a website with green screen, maybe something would be interesting for you, and you will make something like that https://greenscreenstock.com/

Read more comments on GitHub >

github_iconTop Results From Across the Web

1000+ Free Green Screen Stock Videos - Pixabay
Add creativity to your projects with a green screen. Browse and download from our excellent collection of high-quality stock videos for free.
Read more >
Download the Best Free Green Screen Videos - Mixkit
Choose from 205 Free Green Screen Stock Videos to download. ... downloaded for free, to be used in your next awesome video project...
Read more >
Free Green screen Videos - Pexels
Download and use 13981+ Green screen stock videos for free. ✓ Thousands of new 4k videos every day ✓ Completely Free to Use...
Read more >
Free Green Screen Videos - Videvo
Download 118,715 Green screen stock video footage for use on any personal or commercial project. Find royalty free Green screen videos on Videvo....
Read more >
Green screen video editor | Clipchamp
Create the perfect green screen video using high-quality stock videos, images, backgrounds, and GIFs. Select your green screen stock asset, layer it with ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found