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

Total release size: 134.0 MB

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

Download URL glass2glass-0.14.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
d29f79136c9d0bd8dc1f34515f3f2bbbc511f5381b164c738a4b4d026eaeb7e7
BLAKE2b-256 checksum
How to use checksums
0c126097829ec15780fa08e1b00f8098b1f50c047841b959a19079c800f9433d
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 5, 2026.

Transparency log

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

Download URL glass2glass-0.14.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
be75fc25ac9c06ca34504892d2946c789a48e96bf98d4c539ea1b58f64c0ae82
BLAKE2b-256 checksum
How to use checksums
d2e59bfb2e39110a258fe2cc8d6aba2de6069807ce44ca429cb4ded5e373838b
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 5, 2026.

Transparency log

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

Download URL glass2glass-0.14.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
02af75f5453f0edf30fb49f3e3f803dab89ea13632dc13eef4f913434dcfb731
BLAKE2b-256 checksum
How to use checksums
08c39780a53d3157cc268ac1cc64a5834a1417b6e21841485e195225f83d845d
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 5, 2026.

Transparency log

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

Download URL glass2glass-0.14.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
ce32ca7a23b7f649fc0b66a3b90a8e28875554a3f2e8e8dc249d53c5eaac41e4
BLAKE2b-256 checksum
How to use checksums
84f9f98d0edd8786f562d62ea006c54ba358aadbb58891707b70bb11cae4c01f
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 5, 2026.

Transparency log

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

Download URL glass2glass-0.14.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
b3653ff1880fadcf455a458c716282f511bea8d4ebd982ccc7825e12514c860d
BLAKE2b-256 checksum
How to use checksums
1348ec67ad5552f6079dffeed2b62a1039e59bb62e664c7f565009ff5264d549
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 5, 2026.

Transparency log

Security for glass2glass 0.14.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.14.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 5, 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