alpha2 for Python
Build, validate and render alpha2 project documents from
Python. A project is a plain dict in the engine's project.v1 shape (typed as
alpha2.types.Project). Validation runs the engine's own validator in-process; rendering runs the
native alpha2-host process on the GPU, or on the CPU where there is none.
pip install alpha2
On Linux x86_64 and aarch64, macOS arm64 and Windows x64 this also installs alpha2-host, the
native renderer, as a platform wheel of the same version. Elsewhere, or where that wheel cannot be
installed (a Linux older than its glibc baseline), see Finding alpha2-host.
import alpha2
project = alpha2.ProjectBuilder("Intro", width=1280, height=720, frame_rate=30)
title = project.source("image", "title.png")
project.video_track().clip(title, at=0, duration=3)
result = alpha2.export(
project.build(),
"intro.mp4",
assets=project.assets(),
on_progress=lambda p: print(f"{p.completed}/{p.total}"),
)
print(result["videoOutputPath"], result["frames"])
alpha2.export,alpha2.conformandalpha2.capabilitiesrun on a sharedHostClient; make your own (alpha2.HostClient(concurrency=2)) to bound or separate them.- Setting a
cancelevent (threading.Event) or pressing Ctrl-C ends the host, which removes its partial output, before the call returns. - Every failure is an
alpha2.Alpha2HostErrorwith a machine-readablecodeand a classifiedfailuredict for retry policies. - Options you write use snake_case (
loudness={"target_lufs": -14, ...}); what the host reports keeps the protocol's camelCase keys (result["effectiveRange"]).
Renderer and video decode
renderer= ("auto", "gpu", "cpu"; typed as alpha2.client.RendererMode) chooses what draws
the frames, and video_decode= ("software", "auto", "hardware-required") how video is
decoded, on HostClient(...) for every request or per call to export and capabilities. Unset,
the host reads ALPHA2_RENDERER and ALPHA2_VIDEO_DECODE, else decides: auto renderer, and
auto decode on Linux, software on macOS and Windows.
autorenders on a hardware GPU when there is one and on the CPU otherwise, never on a software GPU adapter (lavapipe, llvmpipe, WARP, SwiftShader).gputakes whatever adapter the host finds and fails withGPU_INIT_FAILEDwithout one;cpuopens no graphics driver.- Results and capabilities report
renderer("gpu"or"cpu"),rendererReason(why the host renders on the CPU) and, on the CPU,rendererThreads; the capability report's["capabilities"]["features"]hasrenderer.gpu,renderer.cpuandeffects.runtime. A runtime WGSL effect cannot run on the CPU renderer: such an export fails withEFFECT_ERROR. - Under
autodecode, an export whose hardware decoder stalls runs once more decoding in software.
Compose: videos by intent
alpha2.compose describes a video by what it is made of and compiles it into a project. Times are
seconds, lengths are pixels of the canvas, and files are paths: the compiled project carries its
assets, fonts and loudness to alpha2.export.
from pathlib import Path
import alpha2
from alpha2 import compose as c
video = c.Video(
canvas="youtube-1080p",
body=c.Slideshow(
sorted(Path("photos").glob("*.jpg")), seconds=6, transition=c.Crossfade(1), ken_burns=1.15
),
overlays=[c.Title("Summer 2026", at=0.5, duration=4)],
audio=c.MusicBed("music.m4a", fade_out=3),
)
compiled = video.compile(fonts=["DejaVuSans-Bold.ttf"]) # compiled.project is a plain dict
alpha2.export(compiled, "summer.mp4")
- Nodes:
Sequence,Stack,Grid,Media,Text,Color,Captions(SubRip, WebVTT, cues or word timestamps),Layout,Audio,Raw(part of a project, as an overlay); componentsSlideshow,CaptionedVideo,Title,TitleCard,LowerThird,EndCard,ComparisonGrid,Reframe,Logo,MusicBed. Themesclean-darkandclean-light, or your own (theme={"base": "clean-light", "accent": "#e63946"}). - Compiling needs each file's size and length.
compileasks the host'sconformfor them (no GPU), or takes them asfacts=; with every fact given it runs without a host. The same spec, facts and fonts compile to the same project. - Templates are Python: loops, conditions and arithmetic build the lists the nodes take. A spec is
JSON (
video.to_json(), typed asalpha2.compose_types.VideoSpec) that every binding compiles the same way. - An error names where in the spec it lies (
alpha2.Alpha2ComposeError,.path == "spec.body.items[3].path").
Finding alpha2-host
In this order: the host_path argument, ALPHA2_HOST_PATH, the alpha2-host wheel of this
version, the archive of this version in the shared cache, then PATH.
python -m alpha2 install downloads the release archive into the cache (ALPHA2_HOST_CACHE_DIR,
else ~/.cache/alpha2, ~/Library/Caches/alpha2 or %LOCALAPPDATA%\alpha2), the one
@alpha2-sh/node uses, so one download serves both; --thin installs the archive that loads the
system's FFmpeg 8. Or unpack the archive from the GitHub release yourself and point
ALPHA2_HOST_PATH at its bin/alpha2-host.
Software H.264 (OpenH264)
Where no hardware H.264 encoder is available, alpha2-host can encode H.264 in software with
Cisco's OpenH264 library, which it loads at run time. Neither this package nor the alpha2-host
wheel includes that library, and nothing downloads it unless you ask: Cisco's patent licence covers
its binary only when the user fetches it from Cisco.
python -m alpha2 install --openh264
This downloads Cisco's OpenH264 2.7.0 binary for the platform from
https://ciscobinary.openh264.org, checks the download and the library in it against their
SHA-256s, and puts the library in the shared cache, in openh264-2.7.0-<target>/, where
alpha2-host finds it. It installs only the library, not alpha2-host. --force downloads again,
alpha2.install_openh264() does the same from code, and ALPHA2_OPENH264_DOWNLOAD_URL (or the
download_url argument) names a mirror. Every run prints Cisco's notice:
OpenH264 Video Codec provided by Cisco Systems, Inc.
The library is Cisco's binary, under Cisco's terms.
Set ALPHA2_OPENH264=0 to keep alpha2-host from using it.
Development
The extension module is the Rust crate bindings/alpha2-python; maturin builds it into the package.
cd python/alpha2
uv venv -p 3.11 && uv pip install --group dev
uv pip install --no-deps -e . # rebuild after changing the Rust crate
.venv/bin/pytest # end-to-end tests use ALPHA2_HOST_BINARY or target/debug/alpha2-host
.venv/bin/mypy && .venv/bin/ruff check
--no-deps because the pinned alpha2-host wheel exists only once a release is published; the
tests find a host through ALPHA2_HOST_BINARY, ALPHA2_HOST_PATH or the cache instead.
src/alpha2/types.py and src/alpha2/compose_types.py are generated from the project and compose
schemas by npm run generate:schema.
python/alpha2-host builds the alpha2-host wheel from a release archive.
Metadata
Release files for alpha2 0.4.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| alpha2-0.4.4-cp311-abi3-win_amd64.whl | CPython 3.11 | abi3 | Windows x86-64 | Details for alpha2-0.4.4-cp311-abi3-win_amd64.whl |
| alpha2-0.4.4-cp311-abi3-manylinux_2_34_x86_64.whl | CPython 3.11 | abi3 | Linux glibc 2.34+ x86-64 | Details for alpha2-0.4.4-cp311-abi3-manylinux_2_34_x86_64.whl |
| alpha2-0.4.4-cp311-abi3-manylinux_2_34_aarch64.whl | CPython 3.11 | abi3 | Linux glibc 2.34+ ARM64 | Details for alpha2-0.4.4-cp311-abi3-manylinux_2_34_aarch64.whl |
| alpha2-0.4.4-cp311-abi3-macosx_11_0_arm64.whl | CPython 3.11 | abi3 | macOS 11.0+ ARM64 | Details for alpha2-0.4.4-cp311-abi3-macosx_11_0_arm64.whl |
Total release size: 10.0 MB
Release files / alpha2-0.4.4-cp311-abi3-win_amd64.whl
| Download URL | alpha2-0.4.4-cp311-abi3-win_amd64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.11 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
27023ecb2165eedcf9652a35a9e8c975ab92a837d8fb0cdf29bfaea508440d2e
|
|
BLAKE2b-256 checksum How to use checksums |
2f48c21e35fc21cb3d881aba08fd1f3edf3e2a306669339653a61fe37a4283a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / alpha2-0.4.4-cp311-abi3-manylinux_2_34_x86_64.whl
| Download URL | alpha2-0.4.4-cp311-abi3-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.11 Linux glibc 2.34+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
e027ac5fa56acd2d2269378c32d77dea621c9fc691b62b74a1c37a6543898a14
|
|
BLAKE2b-256 checksum How to use checksums |
abbc84de58d4e3e4d690d220cd5ba766f3dcb5f795a780c2f1de7f30c3fe1acf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / alpha2-0.4.4-cp311-abi3-manylinux_2_34_aarch64.whl
| Download URL | alpha2-0.4.4-cp311-abi3-manylinux_2_34_aarch64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.11 Linux glibc 2.34+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
090eac2c4721b70288efd495710db0c9a7ab7e1031e0a9a032d8f92788d2bd8c
|
|
BLAKE2b-256 checksum How to use checksums |
3a808fff7bec1f9da98818a2c5af8f90e5985ae88ddc08472ac7344902ca4287
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / alpha2-0.4.4-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | alpha2-0.4.4-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
6b6805ed7304b96bf4c0b0c43abadf189ca5a9dbc5dde5efae9da779a09edd94
|
|
BLAKE2b-256 checksum How to use checksums |
01cc555d3a83785acdd46da7b501361bd5f185cd22837f703f87fdc26bd82447
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for alpha2 0.4.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.