This Python-based tool converts green screen videos into sequences of PNG files, replacing the green background with an alpha layer. This tool is particularly useful for importing videos into Lens Studio, as demonstrated in the following video: Lens Studio Guide
The tool depends on the following Python libraries:
- PIL (pillow)
- numpy
- natsort
- cv2
- youtube_dl
- argparse
- argcomplete
- imageio
- numpngw
- APNGLib
To install the necessary dependencies, run the provided shell script:
bash install.sh
To convert a YouTube video, use the following command:
python3 GreenVideotoAlphaPNGs.py https://www.youtube.com/watch?v=ybX4VuArZOQ
First, set the dir
variable in the main function to the desired folder name.
To create a transparent GIF, use the following command:
python3 GIFGenerator.py "Joker from Persona 5 Default Dance (Green Screen)-ybX4VuArZOQ_alpha"
Note: GIF generation is quite slow due to the use of the APNGLib library, which is currently the only viable solution.
You can create a video with a custom speed (fps) using the following command:
python3 GIFGenerator.py "Joker from Persona 5 Default Dance (Green Screen)-ybX4VuArZOQ_alpha" --fps 24
After generating the sequence of images, you can import them into Lens Studio:
- Click on the Resources panel.
- Choose Add New -> 2D animation from files -> Ok in the popup menu.
- Adjust the settings for the imported object, including audio and cutout animation.
Alternatively, you can import the generated alpha GIF or video directly into Lens Studio.
This Python-based tool simplifies the process of using green screen videos in Lens Studio, thereby facilitating the creation of immersive AR experiences.