Skip to content

livepeer/livepeer-python-gateway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 

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 = {
    "orchestrators": [
        "https://orch-1.example.com:8935",
        "https://orch-2.example.com:8935",
    ],
    "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 |
|---|---|---|
| `orchestrators` | `string[]` (optional) | Ordered orchestrator addresses to try before discovery |
| `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.

For token payloads, `orchestrators` must be a JSON array of non-empty strings.
Comma-delimited string format is not supported in the token.

Selection/discovery precedence (highest -> lowest):
1) explicit `orch_url`
2) token `orchestrators`
3) explicit `discovery_url`
4) token `discovery`
5) signer-derived discovery endpoint

`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).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages