livepeer/livepeer-python-gateway
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
Generate protobufs:
```
uv sync --extra dev
uv run generate-lp-rpc
```
## Usage Examples
First install dependencies for example code
```
uv sync --extra examples
```
Get orchestrator info, offchain mode
```
uv run examples/get_orchestrator_info.py localhost:8935
```
On-chain mode with a remote signer
```
uv run examples/get_orchestrator_info.py --signer "<signer-host:port>"
# Use a custom discovery endpoint to filter orchestrators
uv run examples/get_orchestrator_info.py --signer "<signer-host:port>" '<discovery-host>/discover-orchestrators?cap=streamdiffusion-sdxl-v2v'
```
Write raw frames to a LiveVideoToVideo job
```
uv run examples/write_frames.py localhost:8935
```
Capture MacOS camera frames and publish via write_frame
```
uv run examples/camera_capture.py localhost:8935
```
Capture MacOS camera frames and subscribe to media output (stdout or file)
```
uv run examples/camera_capture.py localhost:8935 --output - | ffplay -fflags nobuffer -flags low_delay -probesize 32 -i -
uv run examples/camera_capture.py localhost:8935 --output out.ts
```
Composite camera input and decoded output side-by-side with PTS delta
```
uv sync --group examples
uv run examples/in_out_composite.py localhost:8935
```
Subscribe to a LiveVideoToVideo trickle events channel
```
uv run examples/subscribe_events.py localhost:8935
```
Start a LiveVideoToVideo job using a token (base64 JSON)
```python
import base64
import json
from livepeer_gateway.lv2v import StartJobRequest, start_lv2v
payload = {
"signer": "https://signer.example.com",
"signer_headers": {"Authorization": "Bearer abcdef"},
"discovery": "https://discovery.example.com",
"discovery_headers": {"Authorization": "Bearer qwerty"},
}
token = base64.b64encode(json.dumps(payload).encode("utf-8")).decode("utf-8")
job = start_lv2v(
orch_url=None,
req=StartJobRequest(model_id="noop"),
token=token,
timeout=5.0, # timeout for the initial /live-video-to-video request
# signer_url="https://override-signer.example.com", # explicit args take precedence
)
```
## Token schema (base64-encoded JSON object)
| Field | Type | Description |
|---|---|---|
| `signer` | `string` (optional) | Signer base URL |
| `signer_headers` | `{"key": "value"}` (optional) | Extra HTTP headers sent to all signer endpoints |
| `discovery` | `string` (optional) | Discovery endpoint URL |
| `discovery_headers` | `{"key": "value"}` (optional) | Extra HTTP headers sent to the discovery endpoint |
Explicit keyword arguments in a function or method always take precedence over token values.
`signer_headers` are sent with requests to the signer service. `discovery_headers` are only used when an explicit `discovery_url` is provided (and not when using the signer service as a discovery fallback).