Skip to content
Table of contents

GreenScreenVideotoAlphaPNGs: A transparent-frame production pipeline

GreenScreenVideotoAlphaPNGs separates video acquisition, frame extraction and chroma keying from final encoding. RGBA PNG frames are an intermediate output that can feed either the GIF path or an alpha-capable video codec.

Application and tools
  • Updated
  • 1
  • C++ · 57.96%
  • MIT
Documented components
2Explore modules
Source documents
1Read the instructions
Repository languagesC++ 57.96%5

Shares calculated from GitHub Linguist bytes.

C++57.96%
57.96%41,566 bytes
Python32.32%
32.32%23,177 bytes
JavaScript7.93%
7.93%5,687 bytes
PowerShell0.94%
0.94%673 bytes
Language%Bytes
C++57.96%41,566
Python32.32%23,177
JavaScript7.93%5,687
PowerShell0.94%673
Shell0.85%610

1. Overview

1.1. Why it exists

OpenCV color-keying pipeline converting chroma-key green videos to RGBA alpha PNG sequences.

1.2. Best fit

Asset preparation for augmented reality (Snapchat Lens Studio, Spark AR).

2. Use cases

A Python CLI that turns green-screen video into transparent PNG frames, GIFs or alpha .mov files for Lens Studio.

Use-case diagram for GreenScreenVideotoAlphaPNGs: Download footage from a URL; Split a video into frames; Key out the green background; Build a transparent GIF; Encode an alpha .movGreenScreenVideotoAlphaPNGsDownload footage from a URLSplit a video into framesKey out the green backgroundBuild a transparent GIFEncode an alpha .movAR lens creator«system»YouTube (yt-dlp)«system»ffmpeg
People on the left, external systems on the right; each oval is a use case backed by the files cited below.
Download footage from a URL
AR lens creatorYouTube (yt-dlp)

greenscreen convert accepts a YouTube URL; convert.py calls download_video() and download_audio() from download.py, which use yt-dlp.

Split a video into frames
AR lens creatorffmpeg

frames.py writes numbered PNGs (0.png, 1.png…) with ffmpeg, or with OpenCV when --no-ffmpeg is passed.

Key out the green background
AR lens creator

chroma.py computes a YCbCr distance from the key color (pixel 1,1 by default, tolerance 50–130) and writes RGBA PNGs into a sibling *_alpha folder.

Build a transparent GIF
AR lens creatorffmpeg

greenscreen gif <dir> uses numpngw and the optional APNGLib extension by default, or an ffmpeg palette with --fast-ffmpeg; the GIF is written next to the folder.

Encode an alpha .mov
AR lens creatorffmpeg

greenscreen video <dir> --fps 30 encodes the PNG sequence to Videogen-<stamp>.mov with the qtrle or prores_4444 codec.

2.1. Scenario: From a green-screen clip to a Lens Studio animation

  1. Run bash install.sh (or .\install.ps1 on Windows), then uv run greenscreen --help.
  2. Run uv run greenscreen convert clip.mp4 to extract frames into clip/ and keyed frames into clip_alpha/.
  3. Outputs that start with the clip name are moved into project_clip/ unless --no-project-dir is set.
  4. Run uv run greenscreen gif project_clip/clip_alpha --fast-ffmpeg to get a transparent GIF without APNGLib.
  5. In Lens Studio, use Resources → Add New → 2D animation from files and pick the *_alpha PNGs.

Files readREADME.mdpyproject.tomlsrc/greenscreen/cli.pysrc/greenscreen/convert.pysrc/greenscreen/chroma.pysrc/greenscreen/frames.pysrc/greenscreen/gif_pipeline.pysrc/greenscreen/video_pipeline.py

3. Getting started

These commands come from the repository documentation. They were not run during this review.

README.md · Quick start (uv)
.\install.ps1
uv run greenscreen --help
README.md · Quick start (uv)
bash install.sh
uv run greenscreen --help
README.md · APNGLib (optional C++ extension)
$env:SKIP_APNGLIB='1'; uv sync --extra dev
README.md · APNGLib (optional C++ extension)
$env:SKIP_APNGLIB='0'; uv sync --extra dev

4. Repository references

Excerpts from the repository’s guides, in their original language. Links open the inspected source revision.

Prerequisites and first run

4.1. Quick start (uv)

README.md

Install dev tools: uv sync –extra dev
Read the full instructions ↗

4.2. Prerequisites

README.md

  • Python 3.12+ (repo pins .python-version to 3.12 for uv).
  • ffmpeg on PATH for fast frame extract and for gif –fast-ffmpeg / video. A fallback binary can come from imageio-ffmpeg if PATH has no ffmpeg.
Read the full instructions ↗
Configuration and usage

4.3. CLI

README.md

Legacy entry points still work and forward to the same CLI:

  • python GreenVideotoAlphaPNGs.py → greenscreen convert
  • python GIFGenerator.py → greenscreen gif
  • python VideoGenerator.py → greenscreen video
Read the full instructions ↗
Source documentation

1 documents read from 1 candidates.

5. Features and components 2

Conversion stage
The Typer convert command delegates to run_convert. It accepts a local video or URL and can prefer FFmpeg or force OpenCV extraction. The chroma module handles pixel transparency separately from acquisition.
Encoding choices
gif and video take a directory of PNG frames. The GIF path offers an FFmpeg palette option; video accepts qtrle or prores_4444. Encoding is a new stage, so frame rate and format can change without repeating acquisition.

6. Architecture

Expand a component to follow its connections, or explore the full diagram.

System components Context
Mermaid Interactive diagram

System overview of the components and connections verified in the repository.

Static architecture view for GreenScreenVideotoAlphaPNGs
Static preview. The interactive diagram replaces it after Mermaid loads.
flowchart LR
  n0["Video file or URL"]
  n1["Frame extraction"]
  n2["Chroma key"]
  n3["RGBA PNG sequence"]
  n4["GIF encoder"]
  n5["Alpha video encoder"]
  n0 --> n1
  n1 --> n2
  n2 --> n3
  n3 --> n4
  n3 --> n5
Text version of the diagram
  • Video file or URL → Frame extraction
  • Frame extraction → Chroma key
  • Chroma key → RGBA PNG sequence
  • RGBA PNG sequence → GIF encoder
  • RGBA PNG sequence → Alpha video encoder
Follow one path through the code

Follow cmd_convert into run_convert, then reuse its PNG output for cmd_video. Preserving the intermediate frames makes it easier to inspect matte edges before compression obscures them.

7. Technical dossier

Built from the source at commit b487e51 (22 files). Each item comes from a pattern match in the code, so open the linked file before relying on it.

7.1. Layers and modules

Folders are sorted into layers by name, from the user interface down to data access. Because the sorting uses names only, the diagram says nothing about calls between layers.

Mermaid Layered view
flowchart TB
  subgraph L_interface["Entry points and API"]
    direction TB
    interface_0["greenscreen<br/>1 file"]
  end
  subgraph L_application["Application services"]
    direction TB
    application_0["TemplatesCutout/Public<br/>4 files"]
    application_1["greenscreen<br/>2 files"]
  end
  subgraph L_infrastructure["Data and infrastructure"]
    direction TB
    infrastructure_0["APNGLib_fix<br/>1 file"]
    infrastructure_1["APNGLib_fix/APNGLib<br/>1 file"]
  end
  subgraph L_core["Core source"]
    direction TB
    core_0["(root)<br/>6 files"]
    core_1["greenscreen<br/>6 files"]
  end
  subgraph L_tests["Tests"]
    direction TB
    tests_0["tests<br/>2 files"]
  end
  L_interface ~~~ L_application
  L_application ~~~ L_infrastructure
  L_infrastructure ~~~ L_core
  L_core ~~~ L_tests
Modules and their main layer
ModuleLayerFilesTypesExtensions
greenscreenCore source90.py
(root)Core source60.py .ps1 .sh
TemplatesCutout/PublicApplication services40.js
APNGLib_fixData and infrastructure10.py
APNGLib_fix/APNGLibData and infrastructure12.cpp

7.2. C4 model

From system context to code declarations. Each level reflects the available source evidence.

UML 1 · System context
1 · System context

The widest C4 view: who uses the project and which outside systems and data stores it relies on. Rendered with uml-mcp.

PlantUML source
@startuml
!include <C4/C4_Context>
LAYOUT_LEFT_RIGHT()
Person(P_cli, "CLI user")
System(SYS, "GreenScreenVideotoAlphaPNGs", "GreenScreenVideotoAlphaPNGs separates video acquisition, frame extrac…")
Rel(P_cli, SYS, "Uses")
@enduml
UML 2 · Containers
2 · Containers

One level closer: the parts that run separately inside the project, their main language and how calls flow between them. Rendered with uml-mcp.

PlantUML source
@startuml
!include <C4/C4_Container>
LAYOUT_LEFT_RIGHT()
Person(P_cli, "CLI user")
System_Boundary(SYS, "GreenScreenVideotoAlphaPNGs") {
  Container(APP, "GreenScreenVideotoAlphaPNGs", "Python")
}
Rel(P_cli, APP, "Uses")
@enduml
UML 3 · Components and layers
3 · Components and layers

Modules grouped by source-layer classification. Boundaries show organization, not runtime isolation or call relationships. Rendered with uml-mcp.

PlantUML source
@startuml
!include <C4/C4_Component>
LAYOUT_TOP_DOWN()
System_Boundary(SYS, "GreenScreenVideotoAlphaPNGs") {
Boundary(L0, "Entry points and API", "layer") {
Component(M0_0, "greenscreen", "Python", "1 files")
}
Boundary(L1, "Application services", "layer") {
Component(M1_0, "TemplatesCutout/Public", "JavaScript", "4 files")
Component(M1_1, "greenscreen", "Python", "2 files")
}
Boundary(L2, "Data and infrastructure", "layer") {
Component(M2_0, "APNGLib_fix", "Python", "1 files")
Component(M2_1, "APNGLib_fix/APNGLib", "C++", "1 files")
}
Boundary(L3, "Core source", "layer") {
Component(M3_0, "(root)", "Python, .ps1, .sh", "6 files")
Component(M3_1, "greenscreen", "Python", "6 files")
}
Boundary(L4, "Tests", "layer") {
Component(M4_0, "tests", "Python", "2 files")
}
}
@enduml
UML 4 · Code
4 · Code

Selected declarations, fields and methods grouped by source file. No inheritance or call edges are inferred. Rendered with uml-mcp.

PlantUML source
@startuml
skinparam backgroundColor transparent
skinparam shadowing false
skinparam roundCorner 10
skinparam defaultFontName Arial
skinparam defaultFontSize 13
skinparam ArrowColor #4e6070
skinparam ArrowFontColor #3d4f5f
skinparam titleFontSize 14
skinparam actorBorderColor #006a62
skinparam actorBackgroundColor #e9f3f4
skinparam usecaseBorderColor #006a62
skinparam usecaseBackgroundColor #e9f3f4
skinparam componentBorderColor #006a62
skinparam componentBackgroundColor #e9f3f4
skinparam interfaceBorderColor #006a62
skinparam interfaceBackgroundColor #ffffff
skinparam nodeBorderColor #4e6070
skinparam nodeBackgroundColor #f4f8fb
skinparam databaseBorderColor #006a62
skinparam databaseBackgroundColor #ffffff
skinparam cloudBorderColor #4e6070
skinparam cloudBackgroundColor #f0f5fa
skinparam artifactBorderColor #006a62
skinparam artifactBackgroundColor #ffffff
skinparam rectangleBorderColor #b0c2d3
skinparam activityBorderColor #006a62
skinparam activityBackgroundColor #e9f3f4
skinparam partitionBorderColor #b0c2d3
skinparam stereotypeCBackgroundColor #ffffff
top to bottom direction
hide empty members
package "GreenScreenVideotoAlphaPNGs" {
package "lib/APNGLib_fix/APNGLib/APNGLib.cpp" as F0 {
class "APNGFrame" as T0_0 {
}
class "CHUNK" as T0_1 {
}
}
object "src/greenscreen/gif_pipeline.py" as FN0 {
  _list_pngs()
  create_gif_apnglib()
  create_gif_ffmpeg()
  create_gif()
}
object "src/greenscreen/cli.py" as FN1 {
  cmd_convert()
  cmd_gif()
  cmd_video()
}
object "src/greenscreen/chroma.py" as FN2 {
  _alpha_from_cb_cr()
  green_screen_rgba()
  remove_green_dir()
}
object "src/greenscreen/convert.py" as FN3 {
  _is_probably_url()
  run_convert()
}
object "src/greenscreen/download.py" as FN4 {
  video_title()
  download_video()
  _hook()
  download_audio()
  _hook()
}
}
@enduml

7.3. Public interface

Outside code can use everything listed here. The project also declares 2 public types.

UML Use cases
Use cases

Each actor is a kind of caller, linked to what it can ask the project to do. Rendered with uml-mcp.

PlantUML source
@startuml
skinparam backgroundColor transparent
skinparam shadowing false
skinparam roundCorner 10
skinparam defaultFontName Arial
skinparam defaultFontSize 13
skinparam ArrowColor #4e6070
skinparam ArrowFontColor #3d4f5f
skinparam titleFontSize 14
skinparam actorBorderColor #006a62
skinparam actorBackgroundColor #e9f3f4
skinparam usecaseBorderColor #006a62
skinparam usecaseBackgroundColor #e9f3f4
skinparam componentBorderColor #006a62
skinparam componentBackgroundColor #e9f3f4
skinparam interfaceBorderColor #006a62
skinparam interfaceBackgroundColor #ffffff
skinparam nodeBorderColor #4e6070
skinparam nodeBackgroundColor #f4f8fb
skinparam databaseBorderColor #006a62
skinparam databaseBackgroundColor #ffffff
skinparam cloudBorderColor #4e6070
skinparam cloudBackgroundColor #f0f5fa
skinparam artifactBorderColor #006a62
skinparam artifactBackgroundColor #ffffff
skinparam rectangleBorderColor #b0c2d3
skinparam activityBorderColor #006a62
skinparam activityBackgroundColor #e9f3f4
skinparam partitionBorderColor #b0c2d3
skinparam stereotypeCBackgroundColor #ffffff
left to right direction
actor "CLI user" as A_cli
rectangle "GreenScreenVideotoAlphaPNGs" {
  usecase "Command convert" as U0
  usecase "Command gif" as U1
  usecase "Command video" as U2
}
A_cli --> U0
A_cli --> U1
A_cli --> U2
@enduml

Command line 3

Entry points

7.4. Private interface

These names are internal by the language’s conventions: a leading underscore, private, static or pub(crate).

underscore helper
8
static (file-local) function
2

7.5. Entities and data model 2

Mermaid Entity class diagram
classDiagram
  direction LR
  class E0["APNGFrame"] {
  }
  class E1["CHUNK"] {
  }

An arrow links a field to the entity its type names.

EntityKindFirst fields
APNGFrameData struct
CHUNKData struct

7.6. Business logic

No classes were extracted, so these are the largest source files and their functions.

src/greenscreen/gif_pipeline.py
_list_pngs, create_gif_apnglib, create_gif_ffmpeg, create_gif
src/greenscreen/cli.py
cmd_convert, cmd_gif, cmd_video
src/greenscreen/chroma.py
_alpha_from_cb_cr, green_screen_rgba, remove_green_dir
src/greenscreen/convert.py
_is_probably_url, run_convert
src/greenscreen/download.py
video_title, download_video, _hook, download_audio, _hook

7.7. Stack and dependencies

Python pyproject.toml 11 runtime, 3 dev

Python >=3.12

Open the manifest

External dependencies

14 declared packages (11 runtime, 3 development) in pyproject.toml.

Package table 14
External dependencies
PackageVersionScopePurposeRegistry
typer>=0.12runtimeCommand linepypi.org
rich>=13.7runtimeCommand linepypi.org
tqdm>=4.66runtimeCommand linepypi.org
pillow>=10.0runtimeGraphics, imaging and 3Dpypi.org
numpy>=1.26runtimeData analysispypi.org
opencv-python>=4.9runtimeGraphics, imaging and 3Dpypi.org
natsort>=8.4runtimeSimple yet flexible natural sorting in Python.pypi.org
imageio>=2.33runtimeGraphics, imaging and 3Dpypi.org
imageio-ffmpeg>=0.4.9runtimeGraphics, imaging and 3Dpypi.org
numpngw>=0.1.2runtimeWrite numpy array(s) to a PNG or animated PNG file.pypi.org
yt-dlp>=2024.1runtimeA feature-rich command-line audio/video downloaderpypi.org
pytest>=8.0developmentTestingpypi.org
pytest-cov>=4.1developmentTestingpypi.org
ruff>=0.8developmentLinting and formattingpypi.org

7.8. CI/CD pipeline

No CI/CD pipeline in the repository. The code is built and run by hand, as described above.

7.9. Deployment

Mermaid Deployment diagram
flowchart LR
  repo[("GitHub repository")]
  local["Local machine<br/>Python"]
  repo -->|"clone and run"| local

The repository has no Dockerfile, Compose file or hosting configuration, so the code runs on the machine that clones it.

7.10. Security

Supply chain

Environment variables 1

The page lists names without their values and underlines the ones that look like secrets.

SKIP_APNGLIB

7.11. Testing

Test files
2
Source files
21
Test cases, about
3
Unit tests
2

Code coverage

No measured coverage report in the analyzed sources.

Where the tests are

tests 2

Nothing found for: Services, Database, External integrations, Monitoring.

8. Types and file structure

2 declared types, with 2 in the base-relationship overview.

Type diagram
classDiagram
direction TB
class t6f7d26235a07["CHUNK"] {
  <<struct>>
}
class t05c53bd05b93["APNGFrame"] {
  <<struct>>
}

Unresolved bases remain labelled; full signatures are not reconstructed.

9. Reference

21 / 21 eligible files read (45 in the tree); 0 oversized, 0 failed reads and 0 syntax diagnostics.

What the scan covers

Known dependency/build folders, credential files and binaries are excluded. The scan covers READMEs, recognized manifests and parser-supported source files.

Linguist statistics cover the whole repository and may include other languages.

11. Files to read 3

12. Glossary

Repository

The versioned source files, configuration, and history of a project.

README

The repository’s entry document, usually covering its purpose and initial setup.

Dependency

A library, tool, or service that another component needs to build or run.

CLI

A text interface in which commands and arguments select operations. Exit codes let scripts detect success or failure.

Build

The steps that turn source files and dependencies into a runnable program or distributable artifact.

Video decoder

A component that reconstructs video frames from a compressed stream. Decoding and displaying a frame are separate stages.

13. References

  1. antoinebou12. (2026, November 5). GreenScreenVideotoAlphaPNGs. [Software repository] github.com.
  2. antoinebou12. (2026, November 5). GreenScreenVideotoAlphaPNGs: README. [Repository documentation] github.com.
  3. antoinebou12. (2026, November 5). src/greenscreen/cli.py. [Source file] github.com.
  4. antoinebou12. (2026, November 5). src/greenscreen/chroma.py. [Source file] github.com.
  5. antoinebou12. (2026, November 5). src/greenscreen/video_pipeline.py. [Source file] github.com.
  6. Boucher, A. (2026, October 23). GreenScreenVideotoAlphaPNGs: A transparent-frame production pipeline. [Project article] antoineboucher.info.

Sources without a publication date show the date they were last checked, November 5, 2026. File links retain the inspected revision where available.