Metadata-Version: 2.5
Name: vided
Version: 0.1.69
Summary: A local CLI for speeding up silence and adding rectangular blur redactions.
License-Expression: MIT
License-File: LICENSE
Requires-Python: >=3.11
Requires-Dist: cyclopts>=4.11.2
Requires-Dist: onnxruntime>=1.16.1
Requires-Dist: pillow>=10.1
Provides-Extra: transcribe
Requires-Dist: onnx-asr[cpu,hub]<0.13,>=0.12; extra == 'transcribe'
Description-Content-Type: text/markdown

# Vided

Vided is a small local command-line tool for making screen recordings shorter
and safer to share.

It trims dead air, speeds up longer pauses, and lets you blur fixed rectangular
areas like emails, account IDs, tokens, URL bars, sidebars, or terminal panes. It
runs locally with `ffmpeg`; your video does not leave your machine.

Vided is intended to be used as a CLI tool with `uvx` or `uv tool`, not as a
Python library dependency.

## Example

This is the 90-second public-domain NASA fixture in this repo. VAD trim keeps
speech at normal speed and removes or speeds up the gaps, producing a
61.1-second output.

**Input, 90.0s**

https://github.com/user-attachments/assets/24b476e4-72d3-4bad-843a-3c801cc3adcb

**VAD trim, 61.1s**

https://github.com/user-attachments/assets/c0ccba07-e2be-45b0-a6a9-d4a7d57f3f28

```bash
uvx vided init tests/fixtures/media/realistic-speech-gaps.mp4 realistic-speech-gaps-vad --symlink --overwrite
uvx vided trim realistic-speech-gaps-vad --detector vad --overwrite
uvx vided render realistic-speech-gaps-vad --overwrite
```

The final clip is written to `realistic-speech-gaps-vad/output/final.mp4`.

## Install

Requirements: `uv`, `ffmpeg`, and `ffprobe`. `uv` provides Python 3.11+ if needed.

```bash
uvx vided --help          # one-off use (uvx is short for `uv tool run`)
uv tool install vided     # or install a persistent `vided` command
uvx vided doctor          # check ffmpeg/ffprobe when something fails
```

Optional: install the packaged skill so a coding agent can drive Vided for you:

```bash
uvx vided install-skill --agent claude   # or --agent codex
```

## Workflow

Every project is a folder. Commands take that folder, and existing outputs are
replaced only with `--overwrite`. Other relative paths you pass, such as
`--output`, are relative to the current directory. `--dry-run` prints what a
command would do without writing files.

### 1. Create a project

```bash
uvx vided init /path/to/recording.mp4 my-video
```

This copies the recording into `my-video/input/original.mp4` (`--symlink` links it
instead). Without a folder name, the folder is named after the input file.

### 2. Trim

```bash
uvx vided trim my-video --detector vad --overwrite
```

Trim writes `work/trimmed.mp4`, which later steps use, so run it even if you only
want to blur (use `--mode keep`).

Choose a detector:

- `--detector vad`: speech-aware. Best for narration, interviews, demos, lectures.
- `--detector loudness` (default): keeps any sufficiently loud sound, such as
  music, game audio, or sound effects.

Choose what happens to the gaps with `--mode`:

| Mode | Gaps |
| --- | --- |
| `hybrid` (default) | gaps under `--long-gap` (1.5s) are cut; longer gaps play at 8x, muted |
| `cut` | all gaps are cut |
| `speed` | all gaps play at 8x, muted |
| `keep` | nothing is trimmed |

Tuning:

- `--gap-speed 4` changes the 8x speed; `--no-mute-gaps` keeps gap audio.
- `--speed-indicator` shows a ▶▶ 8x badge on sped-up gaps lasting at least 1
  output second (`--speed-indicator-corner`, `--speed-indicator-theme`,
  `--speed-indicator-min-duration`).
- Loudness detector: `--loudness-threshold` (`0.04`, `4%`, or `-28dB`);
  `--loudness-margin 0.2s` pads around sound (`BEFORE,AFTER` also works, and
  negative times cut into it); `--loudness-smooth 0.2s,0.1s` bridges silences
  shorter than the first time and ignores sounds shorter than the second.
- VAD: `--vad-threshold`, `--vad-min-speech`, `--vad-min-silence`,
  `--vad-speech-pad`, and `--vad-merge-gap`.

A trim saves the options it used in `project.json` under `trim`, so later re-trims
and `render --source original` reuse them. Dry runs and samples save nothing.

### 3. Blur sensitive areas (optional)

```bash
uvx vided ui my-video
```

This opens a local browser UI (Ctrl+C stops it). In the UI:

1. Click a thumbnail where the redaction starts.
2. Click **Set start**.
3. Draw the rectangle to blur.
4. Click a thumbnail where it ends.
5. Click **Add redaction**.

Select a saved redaction to move or resize it or change its pre/post buffers
(0.5s by default). Changes save automatically to `redactions.json`.

Check placement without rendering the whole video:

```bash
uvx vided contact-sheet my-video --overwrite
```

This writes `output/contact-sheet-trimmed.jpg`, a grid of frames with each
redaction outlined and overlays drawn.

### 4. Render

```bash
uvx vided render my-video --overwrite
```

This writes `output/final.mp4` with redactions and overlays applied. If there is
nothing to apply, it copies `work/trimmed.mp4`.

Common options:

- `--compress smart`: smaller screen recordings. Keeps native resolution for
  readable text, caps the frame rate at 30fps (`--max-fps 24` to go lower), keeps
  H.264, and test-encodes short samples to pick settings. Fails rather than
  producing a file larger than its source unless you pass `--allow-larger`.
- `--compression-priority size`: with smart compression, allows H.265 for smaller
  files that some players cannot open.
- `--audio-preset level` or `voice-safe`: see [Audio presets](#audio-presets). A
  full render saves it to `project.json`, so later renders reuse it.
- `--output my-video/output/custom.mp4`: write somewhere other than
  `output/final.mp4`.
- `--source original`: replay the saved trim on the original recording instead of
  using `work/trimmed.mp4`, including its speed indicator. Useful when you trimmed
  with `--compress smart` for a small review copy.
- `--sample-duration 10`: render a short sample (`output/final-sample-*.mp4`, or
  `--sample-output PATH`) without touching the final video; `--sample-start 60`
  picks where it starts in output time. Also works on `trim`.
- `--dry-run`: print the ffmpeg command without writing files.

Review the final video as a contact sheet (`output/contact-sheet-final.jpg`):

```bash
uvx vided contact-sheet my-video --source final --overwrite
```

Shortcuts: `trim --compress smart` makes a smaller `work/trimmed.mp4`, and
`trim --final` then renders `output/final.mp4` as `vided render` would.

### Re-trimming

Redactions are stored in source-video time, so they follow the same moments
after a re-trim. If a re-trim restores footage that was previously cut, Vided
warns you to review it in `vided ui`: that footage may need new redactions.

Transcripts, sections, and overlays use output time. After a re-trim, transcript
Markdown is refreshed automatically, but `sections.json` and `overlays.json` must
be reviewed and their `trim_id` updated (see below).

## Transcripts, Chapters, and Titles (optional)

### Transcribe

```bash
uvx --from 'vided[transcribe]' vided transcribe my-video
```

This writes `work/transcript.md` (output times, for reading) and
`work/transcript.json` (source times). The first run downloads
[NVIDIA parakeet-tdt-0.6b-v3](https://huggingface.co/nvidia/parakeet-tdt-0.6b-v3)
(CC BY 4.0, 25 European languages); later runs work offline. Audio stays local and
no LLM is called. Times are approximate (±0.2s). Use `--profile low-memory` on
machines with little RAM and `--overwrite` to transcribe again.

### Sections

Sections are the video's outline. They drive MP4 chapters, per-section files, and
on-screen topic banners. Create `my-video/sections.json` from the transcript:

```json
{
  "schema_version": 1,
  "times": "output",
  "trim_id": "0123456789ab",
  "sections": [
    {"title": "Introduction", "start": 0},
    {"title": "Demo", "start": 125.4}
  ]
}
```

Copy `trim_id` from the `Trim ID:` line in `work/transcript.md`; if
it doesn't match the current trim, `vided sections` reports the expected value. The
first section starts at `0`, starts increase, and each section ends where the
next begins. Starts are output times (see [Times](#times)).

```bash
uvx vided sections my-video                   # validate, print a table and warnings
uvx vided sections my-video --format youtube  # YouTube chapter list
uvx vided render my-video --chapters --overwrite        # embed MP4 chapters
uvx vided render my-video --section-titles --overwrite  # show titles on screen
uvx vided split my-video                      # one file per section
```

`split` re-encodes `output/final.mp4` (or `--final-video PATH`) into
`output/sections/01-introduction.mp4`, `02-demo.mp4`, and so on. Run `render`
first. Existing section files require `--overwrite`; files left over from an
earlier split are removed, and other files in the folder are kept.

### Titles and text overlays

Overlays add other on-screen text: an opening title, names, terms, or shortcuts.
Use `--section-titles` for topics rather than repeating them as overlays. Create
`my-video/overlays.json` with the same envelope as `sections.json`:

```json
{
  "schema_version": 1,
  "times": "output",
  "trim_id": "0123456789ab",
  "overlays": [
    {"type": "title", "text": "Exploring the Universe", "subtitle": "NASA · 1976", "start": 0, "duration": 3, "background": "dim"},
    {"type": "callout", "text": "Light-years", "start": 12, "corner": "bottom-left"}
  ]
}
```

| Field | Values |
| --- | --- |
| `type` | `title` or `callout` (required) |
| `text`, `start` | required; `start` in output time |
| `subtitle` | optional text |
| `duration` | default 3s for titles, 4s for callouts |
| `theme` | `dark` (default) or `light` |
| `background` | titles only: `solid` (default) or `dim` |
| `corner` | callouts only: `bottom-left` (default) or any other corner |

Overlays cover the video; they do not add time. `render` applies `overlays.json`
automatically when it exists. Check them first:

```bash
uvx vided overlays my-video                    # validate, print a table and warnings
uvx vided overlays my-video --preview --overwrite
uvx vided overlays my-video --section-titles --preview --overwrite
```

`--preview` writes one still per overlay to `output/overlay-previews/`. Add
`--section-titles` to include section banners exactly as `render --section-titles`
will show them; an opening title at `0` replaces the first banner.

## Audio Presets

Audio is copied unchanged unless you choose a preset:

```text
none        copy audio unchanged
level       normalize speech to a conservative -18 LUFS target
voice-safe  gentle voice cleanup plus the same conservative loudness target
```

Preview a preset on up to 15 seconds of the longest normal-speed stretch of
`work/trimmed.mp4`, or choose the snippet with `--sample-start` and
`--sample-duration`:

```bash
uvx vided audio-preview my-video --audio-preset voice-safe --overwrite
uvx vided audio-preview my-video --audio-preset level --sample-start 60 --sample-duration 15 --overwrite
uvx vided render my-video --audio-preset voice-safe --overwrite
```

## Project Files

```text
my-video/
  project.json             # probed video info, settings, and the current trim
  redactions.json          # blur rectangles, in source time and pixels
  sections.json            # optional outline, in output time
  overlays.json            # optional titles and callouts, in output time
  input/original.mp4
  work/trimmed.mp4
  work/transcript.md       # optional, output time
  work/transcript.json     # optional, source time
  output/final.mp4
  output/contact-sheet-trimmed.jpg
  output/contact-sheet-final.jpg
  output/sections/         # from `vided split`
```

`project.json` holds the defaults that `trim`, `render`, and `ui` use when no
option overrides them; `trim`, full renders, and `ui` save the options they ran
with. Some settings have no flag: `trim.vad.manual_keep_ranges` (source ranges
such as `{"source_start": 10, "source_end": 20}` that VAD always keeps) and the
ffmpeg settings under `encoding`. Unknown fields are errors in every project file;
`vided validate my-video` checks them all.

Each redaction in `redactions.json` has a unique `id`, `source_start` and
`source_end` in source seconds, and a `rect` (`x`, `y`, `w`, `h`) in source
pixels. Optional `style` is `{"type": "blur", "strength": "medium"}` (default;
`low`, `medium`, or `high`) or `{"type": "solid", "color": "black"}`, and optional
`buffer_pre` and `buffer_post` (seconds) override `defaults`.

### Times

Every time, in flags and in project files, is seconds (`12.5`), a duration with a
unit (`250ms`, `1.5s`), or `HH:MM:SS.sss`.

A plain `start` is output time: a time in the trimmed video. Source times, in the
original recording, are always named `source_start` and `source_end`. Files in
output time say `"times": "output"` and name the trim they match with `trim_id`.

Trim, render, and split validate each new file before replacing the previous
one, so a failed run keeps the last good output.

## Commands

```text
init            create a one-video project
trim            remove or speed up silence
transcribe      optionally transcribe audio locally
sections        validate sections and print them as text or YouTube chapters
overlays        validate overlays and optionally write preview stills
ui              open the local redaction UI
contact-sheet   render a trimmed or final contact sheet
render          render the final video
split           split the final video into one file per section
audio-presets   list audio presets
audio-preview   render a short audio preset preview
validate        validate every project file
doctor          check ffmpeg/ffprobe and optional onnx_asr availability
install-skill   install the packaged coding-agent skill
```

Run `uvx vided <command> --help` for every option.

## Limitations

- Rectangles are fixed. There is no object tracking.
- After a re-trim restores footage, review it: source-time redactions cannot
  cover content that was never reviewed.
- Thumbnails and contact sheets show the first frame at or after each timestamp.
  They are for review, not frame-accurate edits.
- Rotation metadata and unusual pixel aspect ratios are not normalized.
- The UI server binds to `127.0.0.1` by default. Do not expose it publicly.

## More Examples

These use `tests/fixtures/media/realistic-speech-gaps.mp4`. Regenerate them with
`scripts/generate_example_media.sh` (`--upload` to replace the
[release assets](https://github.com/pmbaumgartner/vided/releases/tag/examples)).

**Loudness detector trim, 83.1s**

https://github.com/user-attachments/assets/b3fa0e0c-a767-4ca6-a7eb-49278230bea1

**Audio preset preview: level, 12.5s**

https://github.com/user-attachments/assets/965bb188-f499-4c42-924c-1755b85d1a81

**Audio preset preview: voice-safe, 12.5s**

https://github.com/user-attachments/assets/388c075f-d94b-4cf2-bab8-cff070fc38b1

## Development

From a repo checkout, use `uv run` for contributor workflows:

```bash
uv sync
uv run vided doctor
```

Run tests:

```bash
uv run pytest
```

Format, lint, and type-check:

```bash
uv run ruff format src tests
uv run ruff check src tests
uv run ty check src tests
```

Install and run pre-commit hooks:

```bash
uv run prek install
uv run prek run --stage pre-commit
```

Run fixture e2e tests:

```bash
uv run pytest --run-e2e -m e2e
```

Install the Playwright browser before browser e2e tests:

```bash
uv run playwright install chromium
uv run pytest --run-e2e -m browser --browser chromium
```

The repo includes two Git LFS-tracked public-domain NASA fixtures:

- `tests/fixtures/media/realistic-speech-gaps.mp4`
- `tests/fixtures/media/realistic-speech-gaps-short.mp4`

Source and license notes live beside each fixture as `*.LICENSE.md`.

## Release Notes

Every commit with package source or release metadata changes must bump the
package version with zerover. Tests, workflows, docs, scripts, dev dependencies,
and `uv.lock`-only changes do not require a bump.

```bash
uv version --bump patch
git add pyproject.toml uv.lock
```

After committing, add the matching tag:

```bash
version="$(uv version --short)"
git tag -a "v$version" -m "v$version"
git push origin HEAD --tags
```

Publishing runs from `.github/workflows/publish.yml` when a `v*` tag is pushed.
