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.13.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.13.0
File Actions
glass2glass-0.13.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for glass2glass-0.13.0-cp311-abi3-win_amd64.whl
glass2glass-0.13.0-cp311-abi3-manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64 Details for glass2glass-0.13.0-cp311-abi3-manylinux_2_28_x86_64.whl
glass2glass-0.13.0-cp311-abi3-manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64 Details for glass2glass-0.13.0-cp311-abi3-manylinux_2_28_aarch64.whl
glass2glass-0.13.0-cp311-abi3-macosx_12_0_x86_64.whl CPython 3.11 abi3 macOS 12.0+ x86-64 Details for glass2glass-0.13.0-cp311-abi3-macosx_12_0_x86_64.whl
glass2glass-0.13.0-cp311-abi3-macosx_12_0_arm64.whl CPython 3.11 abi3 macOS 12.0+ ARM64 Details for glass2glass-0.13.0-cp311-abi3-macosx_12_0_arm64.whl

Total release size: 134.0 MB

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

Download URL glass2glass-0.13.0-cp311-abi3-win_amd64.whl
Size 25.1 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
635cf7da39d6046eaefb7b03bc244a480c5e3178f64d322fc1123e3f03fc0395
BLAKE2b-256 checksum
How to use checksums
4ebdcd6be64d297319d9cdfa1b1a8d29685783260e679c5a22538f7d877bbb7d
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 4, 2026.

Transparency log

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

Download URL glass2glass-0.13.0-cp311-abi3-manylinux_2_28_x86_64.whl
Size 30.4 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
430a704bee9da696d237614b0e6939d2a775d4223a1de1da1c08d165f50a8ff7
BLAKE2b-256 checksum
How to use checksums
80540e0bd7b39e945d2d52008028565a09626afba2d728bcbb4936f768ad55b6
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 4, 2026.

Transparency log

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

Download URL glass2glass-0.13.0-cp311-abi3-manylinux_2_28_aarch64.whl
Size 29.4 MB
Tags CPython 3.11 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
1eeb790b6d0b9df581201f5292b298aeb14bed14e5b47ce85080084bb16cebb2
BLAKE2b-256 checksum
How to use checksums
ff75246f49cf0c5927d5a15a7fba6152c74efd70ec1caa8cb0e877ddb8fe5de9
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 4, 2026.

Transparency log

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

Download URL glass2glass-0.13.0-cp311-abi3-macosx_12_0_x86_64.whl
Size 25.9 MB
Tags CPython 3.11 abi3 macOS 12.0+ x86-64
SHA-256 checksum
How to use checksums
e7720e038b69122d92ab993ae7c049595df17c75379d14589c25be796a794516
BLAKE2b-256 checksum
How to use checksums
f2658493b11c9854051eb9aed68d2653c00bdad8f14b16c6ae5296d2082c1b6a
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 4, 2026.

Transparency log

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

Download URL glass2glass-0.13.0-cp311-abi3-macosx_12_0_arm64.whl
Size 23.3 MB
Tags CPython 3.11 abi3 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
ac64aff08ece0d7665e58a984b4f33eb93f620b9fdcdd445e555fc05992b17e5
BLAKE2b-256 checksum
How to use checksums
0bfe1ecb8760ebd4c0947b588d9ae52ab09e4aa8982bf7402900c665531f1ea5
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 4, 2026.

Transparency log

Security for glass2glass 0.13.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 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for glass2glass-0.13.0-cp311-abi3-win_amd64.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 4, 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