An advanced, real-time green screen remover and background replacer using Python, OpenCV, and MoviePy. Supports webcam or video input, live background toggling, and high-quality chroma keying with spill suppression and edge feathering.
- Real-time or video file input
- Advanced chroma keying (soft masking, spill suppression, edge feathering)
- Automatic background resizing and blending
- Toggle between image, video, or black backgrounds live
- Save recordings and snapshots with unique filenames
- Export with audio preservation (for video files)
- Clone the repository:
git clone https://github.com/yourusername/ai-powered-green-screen.git cd ai-powered-green-screen - Create a virtual environment (recommended):
python -m venv .venv .venv\Scripts\activate # On Windows # or source .venv/bin/activate # On Mac/Linux
- Install dependencies:
pip install opencv-python numpy pillow moviepy
- Add your background image:
- Place your background image at
background/background.jpg(create the folder if needed). - (Optional) Add a background video as
background.mp4.
- Place your background image at
Run the script:
python green_screen_remover.pyb— Toggle background (image, video, black)q— Quits— Save a snapshot (saved insnapshot/folder)
- Recordings are saved in the
recording/folder with unique timestamps. - Snapshots are saved in the
snapshot/folder with unique timestamps. - If using a video file as input, the final output with audio is also saved in
recording/.
- For best results, use even lighting and a solid green background.
- You can tune the chroma key parameters in the script for your setup.
MIT