Skip to main content

g2g-pyapi

Python bindings to drive glass2glass pipelines: parse a gst-launch-style string, run it on a background thread, watch the bus, and push/pull buffers via appsrc / appsink. This is the inverse of g2g-python, which hosts Python elements inside a pipeline; both sit on the same language-neutral waist as g2g-capi.

The compiled extension imports as g2g (the #[pymodule] fn g2g) and exposes Pipeline, AppSrc, AppSink, and FrameView.

Install

pip install glass2glass

Wheels exist for Linux (x86_64, aarch64), macOS (arm64) and Windows (x86_64) on CPython 3.11 and later. They carry the same elements as the release binaries, and the Linux wheels include the LGPL ffmpeg libraries. For PipeWire, or vpxenc on Windows, build the wheel yourself.

Building the wheel (maturin)

The crate ships a pyproject.toml with the maturin backend. From this directory, in a virtualenv:

pip install maturin numpy

# Build + install into the active venv (fastest dev loop):
maturin develop --release

# Or build a redistributable wheel:
maturin build --release         # -> ../target/wheels/glass2glass-*.whl
pip install ../target/wheels/glass2glass-*.whl

pyproject.toml enables the python feature plus pyo3/extension-module, so the wheel is loaded by an existing interpreter (it does not embed/link libpython, the inverse of the auto-initialize path the in-crate cargo test suite uses).

Example

import g2g
import numpy as np

src  = g2g.AppSrc("in")
sink = g2g.AppSink("out")
p = g2g.Pipeline(
    "appsrc channel=in caps=video/x-raw,format=RGBA,"
    "width=2,height=2,framerate=30/1 ! appsink channel=out"
)

src.push(np.full(16, 1, np.uint8).tobytes(), 0)
src.end_of_stream()

view = sink.pull()                      # a zero-copy FrameView, None at EOS
arr  = np.frombuffer(view, np.uint8)    # shares the buffer (OWNDATA False)
print(arr, view.pts_ns)
p.wait()

AppSink.pull() lends the frame through the buffer protocol: the FrameView owns the Frame, so the bytes (and any memoryview / numpy array over them) stay valid past later pulls and pipeline teardown. Pass timeout_ms for a bounded blocking pull; pair it with Pipeline.is_done() to tell a timeout from a real end of stream.

A runnable version is in examples/appsink_numpy.py:

maturin develop --release
python examples/appsink_numpy.py

The C equivalent (same waist, via g2g-capi) is in ../examples/g2g-c-example.

Changing a running pipeline

A Pipeline accepts edits while it runs. Elements are addressed by their instance name: the name= from the launch line, or the name an insert returned. A new element is written as one launch-line element, "videoflip method=rotate-180", without name= or log-category=.

p = g2g.Pipeline("videotestsrc name=src ! clocksync ! fakesink name=sink")
gate = p.insert_after("src", "valve drop=false")
p.set_property(gate, "drop", "true")
print(p.get_property(gate, "drop"))   # "true"
p.remove(gate)
Method Does
insert_after(node, description) Splices the element onto the edge below node, returns its name.
insert_before(node, description) Splices the element onto the edge above node, returns its name.
insert_chain_after(node, description) Splices a chain such as "identity ! valve" below node, all of it or none, returns the names.
insert_chain_before(node, description) The same, above node.
remove(node) Lifts a transform out of the pipeline and drops it.
add_branch(tee, description) Attaches a chain under the tee, its last element the branch's sink, returns the names.
remove_branch(sink) Drops the branch ending at sink from under its tee.
add_input(muxer, description) Attaches a source to the muxer's next free pad, returns its name.
replace_sink(node, description) Swaps the sink node for a new one, returns the new name.
replace_source(node, description) Swaps the source node for a new one, returns the new name.
set_property(node, name, value) Sets a property from its launch-line text.
get_property(node, name) The property's launch-line text, None if the element has no such property.

A refused edit raises ValueError carrying the reason (UnknownNode, NotMutable, PropertyRejected, ...) and leaves the pipeline running as it was. Each call blocks, with the GIL released, until the element upstream of the edit pushes its next packet, and raises TimedOut after 5 s. An element whose output format the pipeline below refuses gets a videoconvert or audioconvert spliced in after it. A launch line gives a muxer one pad per linked input, so add_input only finds a free pad on a muxer with fixed pads, such as cccombiner fed only video.

Testing

The in-crate tests drive the bindings through an embedded interpreter, so they need libpython at build time:

cargo test -p g2g-pyapi --features python

Metadata

Release files for glass2glass 0.20.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for glass2glass 0.20.0
File Actions
glass2glass-0.20.0-cp311-abi3-win_arm64.whl CPython 3.11 abi3 Windows ARM64 Details for glass2glass-0.20.0-cp311-abi3-win_arm64.whl
glass2glass-0.20.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for glass2glass-0.20.0-cp311-abi3-win_amd64.whl
glass2glass-0.20.0-cp311-abi3-manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64 Details for glass2glass-0.20.0-cp311-abi3-manylinux_2_28_x86_64.whl
glass2glass-0.20.0-cp311-abi3-manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64 Details for glass2glass-0.20.0-cp311-abi3-manylinux_2_28_aarch64.whl
glass2glass-0.20.0-cp311-abi3-macosx_12_0_x86_64.whl CPython 3.11 abi3 macOS 12.0+ x86-64 Details for glass2glass-0.20.0-cp311-abi3-macosx_12_0_x86_64.whl
glass2glass-0.20.0-cp311-abi3-macosx_12_0_arm64.whl CPython 3.11 abi3 macOS 12.0+ ARM64 Details for glass2glass-0.20.0-cp311-abi3-macosx_12_0_arm64.whl

Total release size: 161.1 MB

Release files / glass2glass-0.20.0-cp311-abi3-win_arm64.whl

Download URL glass2glass-0.20.0-cp311-abi3-win_arm64.whl
Size 24.1 MB
Tags CPython 3.11 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
3262a9e4be953e635507f8ffa297364373fc3290c8934fe61825a8bed51e698a
BLAKE2b-256 checksum
How to use checksums
be4024ef6fc470df964cf0df2f89bbf0c41f4405f8519617152674ca89e92b14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / glass2glass-0.20.0-cp311-abi3-win_amd64.whl

Download URL glass2glass-0.20.0-cp311-abi3-win_amd64.whl
Size 25.8 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
e693b52f9e813a55c75fc728c531059d0907aa5153339f8566b958e3a763a31c
BLAKE2b-256 checksum
How to use checksums
44f5b50e1ccc79ccce4d7d35c5def28a4b710b04bd9ddf7f21e7d97ddaac1e04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / glass2glass-0.20.0-cp311-abi3-manylinux_2_28_x86_64.whl

Download URL glass2glass-0.20.0-cp311-abi3-manylinux_2_28_x86_64.whl
Size 31.0 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
79f96fcf4e0a42fbc954ce2cfcc27e01c27689f22b48d4d09d74b63fb1dca709
BLAKE2b-256 checksum
How to use checksums
6722bc4d0748cf156fe458cd63e389a3149493ac7ee2cefe06bf999f9a4285aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / glass2glass-0.20.0-cp311-abi3-manylinux_2_28_aarch64.whl

Download URL glass2glass-0.20.0-cp311-abi3-manylinux_2_28_aarch64.whl
Size 30.0 MB
Tags CPython 3.11 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
e77f1c32583df4da68bf5ea07df460eba2e0d6158e22c8fb96a32ae1b2a20651
BLAKE2b-256 checksum
How to use checksums
d6c2995da6396cce6deeacac7ea11c08747c101f0dd58edc5ac632251c0292a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / glass2glass-0.20.0-cp311-abi3-macosx_12_0_x86_64.whl

Download URL glass2glass-0.20.0-cp311-abi3-macosx_12_0_x86_64.whl
Size 26.5 MB
Tags CPython 3.11 abi3 macOS 12.0+ x86-64
SHA-256 checksum
How to use checksums
a74cd31a9cd75636a8bc8a1a100f83fbd5ff4516b39fd2ef927348cc094c410e
BLAKE2b-256 checksum
How to use checksums
e87220bfb9bdd4ea2ee0be0894de3818dee9230d271a190c51c51e881e00381f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / glass2glass-0.20.0-cp311-abi3-macosx_12_0_arm64.whl

Download URL glass2glass-0.20.0-cp311-abi3-macosx_12_0_arm64.whl
Size 23.7 MB
Tags CPython 3.11 abi3 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
5610c81daf81bf44772afe8972d51072558693b13b26c107d45cb52083377d50
BLAKE2b-256 checksum
How to use checksums
7b5c666a1c1e99e1e9bd5ea4954cc436895e8fe69263afaf7ad955a7c928d9b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Security for glass2glass 0.20.0

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.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for glass2glass-0.20.0-cp311-abi3-win_arm64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page