Metadata-Version: 2.4
Name: frametrunk-encoder
Version: 0.2.0
Summary: Frametrunk Encoder V2 control-plane CLI
Author: Frametrunk
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: numpy>=1.24

# frametrunk-encoder

Python control plane for Frametrunk Encoder V2.  
Version: `0.2.0`

Handles CLI entry, profile management, background job lifecycle, SRT URL validation, health checks, and worker discovery.  
The latency-critical media path runs in the C++ native worker (`frametrunk-worker`).

For full documentation see the [main project README](../README.md).

---

## Install

```bash
pip install -e .
```

## CLI quick reference

```bash
frametrunk-encoder version
frametrunk-encoder scan [--wait-s N]
frametrunk-encoder doctor
frametrunk-encoder start --source "…" --url "srt://…" [flags]
frametrunk-encoder start --profile NAME
frametrunk-encoder profile save NAME --source "…" --url "srt://…"
frametrunk-encoder profile list
frametrunk-encoder profile show NAME
frametrunk-encoder profile run NAME
frametrunk-encoder status NAME
frametrunk-encoder stop NAME
frametrunk-encoder support-bundle
```

Profile deletion is available via the GUI (Profiles tab → Delete).

## SRT latency

The SRT URL is passed through to FFmpeg verbatim, so any SRT option works
directly in the query string. FFmpeg expresses URL latency in microseconds, so
200 ms is `srt://host:9000?passphrase=…&latency=200000`.

To derive the latency from the live network instead of hard-coding it, use
ping-based auto-latency (SRT latency = measured RTT × multiplier, clamped):

```bash
# One-shot: ping at launch, set latency = RTT × 6
frametrunk-encoder start --source "CAM" --url "srt://host:9000?passphrase=…" \
    --auto-latency --latency-multiplier 6

# Adaptive: keep re-measuring RTT and reconnect when it drifts
frametrunk-encoder start --source "CAM" --url "srt://host:9000?passphrase=…" \
    --track-latency --track-interval-s 30 --drift-ratio 0.30
```

`--track-latency` implies `--auto-latency`. When tracking, the worker is wrapped
by a small supervisor process (the `supervise` subcommand) that owns the
worker, re-pings on an interval, and restarts the SRT connection only when the
target latency drifts past `--drift-ratio` (since SRT negotiates latency at
connect time and can't change it mid-stream). Clamp the result with
`--latency-min-ms` / `--latency-max-ms`. The same controls are available in the
GUI under the Launch and Profiles tabs.

## Key public API

```python
from frametrunk_encoder.models import StartRequest, EncoderProfile
from frametrunk_encoder.launcher import build_launch_plan, execute_launch_plan
from frametrunk_encoder.profiles import save_profile, load_profile, list_profiles, delete_profile
from frametrunk_encoder.process_manager import (
    start_background_process, stop_run, delete_run,
    get_status, list_run_states,
)
from frametrunk_encoder.runtime import get_runtime_paths
from frametrunk_encoder.diagnostics import build_doctor_report, create_support_bundle
from frametrunk_encoder.discovery import scan_sources
```

## Package layout

```
src/frametrunk_encoder/
├── cli.py              Entry point + argument parser
├── config.py           SRT URL parser and validator
├── diagnostics.py      Doctor report builder + support bundle
├── discovery.py        NDI source scan + native worker locator
├── doctor.py           Health checks (ffmpeg, ffprobe, worker, ndi-runtime, gpu-encoders)
├── latency.py          Ping RTT measurement + SRT latency computation
├── launcher.py         build_launch_plan() / execute_launch_plan()
├── models.py           StartRequest, EncoderProfile, RuntimePaths, DoctorCheck
├── process_manager.py  start / stop / delete / status / list background runs
├── profiles.py         save / load / delete / list profiles
├── supervisor.py       Latency-tracking supervisor (re-ping + reconnect on drift)
├── runtime.py          Platform paths + worker binary resolution order
└── version.py          APP_NAME, APP_VERSION, BUILD_CHANNEL
```
