pylibobs
Python bindings for libobs — the core C library of OBS Studio.
Lets Python scripts and apps drive libobs directly: initialize OBS, build scenes, configure encoders, mix audio, and record / stream — all without OBS Studio's UI running.
Status: beta. The public API is feature-complete and covered by tests. Reference counting semantics match OBS 32's
obs_*_get_ref()model.
Why?
Existing options:
obspythonruns inside OBS only — you can'tpip installit or use it from a normal Python app.obsws-python/simpleobswstalk to OBS via WebSocket — requires OBS to be running, and only exposes what the WebSocket API allows.
pylibobs links libobs directly (via cffi), so your Python process is the OBS host.
License
Copyright (C) 2026 Jonata Bolzan Loss and contributors.
pylibobs is licensed under GPL v2 or later, inherited from libobs. See LICENSE for the full text.
The published wheels bundle libobs's compiled binaries (also GPLv2+), so the wheel as distributed is covered by GPLv2+. Anything you build on top of pylibobs must be GPL-compatible if you redistribute it. Personal use carries no obligation.
Installation
pip install pylibobs
That's it on Windows / macOS / Linux. The wheel ships with bundled libobs binaries (libobs plus its plugin DLLs and data files, sourced from the official OBS Studio release on PyPI's build server). You don't need to install OBS Studio.
If you're installing from sdist (rare — only when no wheel is published for your platform), or you want to use a system-installed OBS, the loader falls back through:
$LIBOBS_PATHenvironment variable (explicit override)- Bundled libs inside the wheel —
pylibobs/_libs/<platform>/<arch>/ ctypes.util.find_library("obs")- Well-known OBS Studio install paths
Maintainers / contributors can refresh the bundled libs by running:
python scripts/fetch_libs.py # current platform
python scripts/fetch_libs.py --all # every platform
python scripts/fetch_libs.py --version 32.2.2 # pin OBS version
This downloads libobs from the official OBS GitHub release. The _libs/ tree is .gitignored
and only populated during wheel builds.
Quick start
import time
from pylibobs import (
OBSContext, OBSData, Source, Scene, Output,
VideoEncoder, AudioEncoder,
)
with OBSContext() as obs:
obs.set_video(width=1920, height=1080, fps_num=60)
obs.set_audio()
obs.load_modules()
scene = Scene.create("main")
cap = Source.create("monitor_capture", "Desktop", {"monitor": 0})
scene.add(cap)
venc = VideoEncoder.create("obs_x264", "video", {"crf": 23, "preset": "veryfast"})
aenc = AudioEncoder.create("ffmpeg_aac", "audio", {"bitrate": 192})
out = Output.create("ffmpeg_muxer", "rec", {"path": "out.mkv"})
out.set_video_encoder(venc)
out.set_audio_encoder(aenc)
out.start()
time.sleep(10)
out.stop()
See examples/ for full recording and streaming scripts.
pylibobs-studio (tkinter, stdlib only)
examples/pylibobs_studio.py is a complete OBS-style desktop application
built on nothing but the Python standard library:
python examples/pylibobs_studio.py
Features:
| Pane | What it does |
|---|---|
| Live preview | libobs's D3D11 renderer draws directly into a tkinter Frame via its native HWND (Frame.winfo_id() → Display.from_window(hwnd, w, h)). No Qt, no GTK, no extra deps. |
| Scenes | Add / remove scenes; selecting one routes it to the program output. |
| Sources | Per-scene list; add via a type-picker dialog populated from enum_input_types(), with auto-launched monitor/window/file pickers for the source types that need them. Reorder, toggle visibility, remove. |
| Audio mixer | One row per audio-capable source: live VU meter (green / yellow / red), volume slider on an IEC dB curve, mute toggle. Levels come from a VolumeMeter queue read on the tk main loop. |
| Recording | Standard MKV recording with live frames / bytes / dropped-frames in the status bar. |
The whole app is ~600 lines in a single file. Use it as a starting point for your own pylibobs-based applications.
API overview
| Class | Wraps | Notes |
|---|---|---|
OBSContext |
obs_startup / obs_shutdown, video/audio reset |
Use as a context manager. |
OBSData |
obs_data_t |
Dict-like; OBSData({"k": "v"}) |
Source |
obs_source_t |
Source.create(kind, name, settings) |
Scene / SceneItem |
obs_scene_t / obs_sceneitem_t |
Add sources, set visibility, iterate items |
VideoEncoder / AudioEncoder |
obs_encoder_t |
Per-type factory |
Service |
obs_service_t |
RTMP/streaming targets |
Output |
obs_output_t |
File or stream sinks; start()/stop() |
Display |
obs_display_t |
Live preview into a native window (HWND) |
Testing
pip install -e ".[dev]"
# Unit tests (mocked cffi layer — fast, no libobs needed)
pytest tests/unit
# Integration tests (need a real libobs)
pytest tests/integration -m integration
# On Linux CI with no display:
Xvfb :99 -screen 0 1920x1080x24 &
DISPLAY=:99 pytest tests/integration -m integration
CI runs the full matrix on Windows, Linux, and macOS — see .github/workflows/ci.yml.
Project layout
pylibobs/
├── pylibobs/
│ ├── _lib.py # Library locator
│ ├── _ffi.py # cffi instance
│ ├── _declarations.py # C API declarations for cdef()
│ ├── context.py # OBSContext
│ ├── data.py # OBSData
│ ├── source.py # Source
│ ├── scene.py # Scene / SceneItem
│ ├── encoder.py # VideoEncoder / AudioEncoder
│ ├── service.py # Service
│ ├── output.py # Output
│ └── _libs/ # Bundled libobs binaries (after fetch_libs.py)
├── tests/unit/ # Mocked tests
├── tests/integration/ # Real libobs tests
├── scripts/fetch_libs.py # Pull libobs from OBS releases
└── examples/ # record_to_file.py, stream_to_rtmp.py
Coverage / known gaps
pylibobs targets libobs 32.2.2 and declares every function it exports (1384
obs_* / gs_* / signal_* / proc_* / calldata_* / audio_output_* / video_output_*
symbols), reachable via pylibobs._ffi.get_lib(). 1157 of them carry their full C
signature; the remaining 227 are declared as void f(void) placeholders because
scripts/generate_cdef.py cannot parse their headers yet — they resolve, but need a
curated signature in _declarations.py before they can be called correctly.
Pythonic class-based wrappers cover the common workflows:
- Lifecycle, video/audio init, scenes, sources, scene items, transforms (pos/scale/rot/crop/bounds)
- Outputs (file + RTMP streaming), encoders (incl. ROI hints and
EncoderCaps), services - Live preview (
Displayattached to a native window via HWND) - Filters, transitions, hotkeys, fader + VU meter, audio monitoring
- Type lookups: display names, defaults, encoder capabilities, themed source icons (32.2+)
- Raw audio/video callbacks (numpy-friendly), audio resampler, media remux
- Properties API (read + edit, with type-aware widgets in
examples/pylibobs_studio.py) - Save / load whole scene collections to JSON
What's intentionally raw-only (callable via get_lib() but no class wrapper):
- The 290
gs_*graphics primitives — exposing them invites GPU-thread bugs; useobs_render_main_texture()instead. - Property builders (
obs_properties_add_*) — only useful for C plugin authors. - Multi-canvas API (
obs_canvas_*),obs_view_*, codec bitstream parsers (obs_avc_*/obs_av1_*).
Contributing
git clone https://github.com/jonata/pylibobs.git
cd pylibobs
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
python scripts/fetch_libs.py # download bundled libobs
pytest # 100+ tests, mock + integration
The integration suite needs process isolation (libobs can't gracefully restart inside a single process); use the included runner:
python scripts/run_tests.py
Release process
pylibobs is versioned after the libobs it bundles: pylibobs X.Y.Z ships libobs X.Y.Z. A release that only changes pylibobs, on the same libobs, adds a fourth number (X.Y.Z.1, X.Y.Z.2, …). Moving to a new libobs resets to its version.
- Set the same version in
pyproject.tomlandpylibobs/__init__.py; when moving to a new libobs, also updateDEFAULT_OBS_TAGinscripts/fetch_libs.py.python scripts/check_version.pychecks they agree. - Tag the commit
v<version>(e.g.v32.2.2) and push the tag. GitHub Actions:- Refuses to build unless the tag, both version strings and
DEFAULT_OBS_TAGagree - Builds platform-specific wheels with bundled libobs (Windows x64 / Linux x86_64 / macOS Apple Silicon)
- Builds the sdist
- Publishes to PyPI via Trusted Publishing (no token needed in repo secrets)
- Attaches all wheels to a GitHub Release with auto-generated notes
- Refuses to build unless the tag, both version strings and
To set up Trusted Publishing on PyPI for this repo, register pylibobs as a project on PyPI,
then in Project settings → Publishing, add a "GitHub Actions" trusted publisher pointing at
<owner>/pylibobs / workflow release.yml / environment pypi.
Contributions welcome — PRs against main.
Metadata
Release files for pylibobs 32.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pylibobs-32.2.2.tar.gz | 106.2 kB | With provenance | Details for pylibobs-32.2.2.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pylibobs-32.2.2-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details for pylibobs-32.2.2-py3-none-win_amd64.whl |
| pylibobs-32.2.2-py3-none-manylinux_2_31_x86_64.whl | Python 3 | none | Linux glibc 2.31+ x86-64 | Details for pylibobs-32.2.2-py3-none-manylinux_2_31_x86_64.whl |
| pylibobs-32.2.2-py3-none-macosx_13_0_arm64.whl | Python 3 | none | macOS 13.0+ ARM64 | Details for pylibobs-32.2.2-py3-none-macosx_13_0_arm64.whl |
Total release size: 102.5 MB
Release files / pylibobs-32.2.2.tar.gz
| Download URL | pylibobs-32.2.2.tar.gz |
|---|---|
| Size | 106.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a36bf46303efdb0312376e1754d5bc5d58c331a040ff4bce06931c1db504ba7
|
|
BLAKE2b-256 checksum How to use checksums |
e02fc98bedf0c864a5ed6c0552012019233667d18837e3c33cbc84d4c1459c1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 26, 2026.
Transparency logRelease files / pylibobs-32.2.2-py3-none-win_amd64.whl
| Download URL | pylibobs-32.2.2-py3-none-win_amd64.whl |
|---|---|
| Size | 44.2 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
7cd23d41d3852b5799c7e05b9dcc2e0536f9d055736b18cbd780f004c68dd2cc
|
|
BLAKE2b-256 checksum How to use checksums |
568c26dc7db8a3d16be0b9f141b4eed8f868d9a0ecb2fe8667053357351d85d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 26, 2026.
Transparency logRelease files / pylibobs-32.2.2-py3-none-manylinux_2_31_x86_64.whl
| Download URL | pylibobs-32.2.2-py3-none-manylinux_2_31_x86_64.whl |
|---|---|
| Size | 17.0 MB |
| Tags | Linux glibc 2.31+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
73da88930d1c4a7dbe902289c3c2960e22a9986827ca4c3130e656fb24416fb0
|
|
BLAKE2b-256 checksum How to use checksums |
84cdaa9bd92fc69cb42fbd38c1733b1026ad6baef98ad54212c81969e2f011d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 26, 2026.
Transparency logRelease files / pylibobs-32.2.2-py3-none-macosx_13_0_arm64.whl
| Download URL | pylibobs-32.2.2-py3-none-macosx_13_0_arm64.whl |
|---|---|
| Size | 41.2 MB |
| Tags | Python 3 macOS 13.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
26520571481700fc56769f9b15c3b1d549b0e006c1073de4862064ac07ed0606
|
|
BLAKE2b-256 checksum How to use checksums |
c4e0329cda0b5165a11db93e2ce732d379091cd5972a51f5e0c9c850729fea5e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 26, 2026.
Transparency logSecurity for pylibobs 32.2.2
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 4 files in this release have been uploaded with provenance metadata.
Attestation for pylibobs-32.2.2.tar.gz
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 Sep 26, 2026.
Transparency logA 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.