Skip to content

feat: guard encoded true peak and add b-roll, contact sheets and storyboards - #10

Merged
jack-arturo merged 3 commits into
mainfrom
conventional-commit-prefix/broll-truepeak-contact-storyboard-b479
Nov 23, 2026
Merged

jack-arturo merged 3 commits into
mainfrom
conventional-commit-prefix/broll-truepeak-contact-storyboard-b479

Conversation

@jack-arturo

@jack-arturo jack-arturo commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Summary

Four additions from a music-video edit that had to script around vidtight. --render now measures the encoded file and re-encodes the audio until the true peak is at or under −1 dBTP. Silent footage can be kept as speech-free windows, contact sheets are labelled without ffmpeg drawtext, and --select writes a storyboard before the render.

Changes

  • --render runs the limiter at 4× (192 kHz), measures the encoded AAC with ebur128 (loudnorm JSON if that summary is missing), and re-encodes the audio only at a lower ceiling until the true peak is at or under −1 dBTP. The final LUFS and dBTP are printed. Integrated loudness is left alone (alimiter level=false).
  • --broll writes windows.json (start, end, duration) from the existing speech-block and gap logic, instead of pause-cutting. A clip with no speech is one window, the whole file. With --select, a moment keeps the silent window it falls in. The rendered edge stays on the usual pad. An empty moments file keeps nothing; omitting --select is what keeps every window.
  • --broll --render with no captions no longer fails the final mux. An empty SRT stays on disk and is left out of the ffmpeg inputs, instead of being mapped as a subtitle stream that is not there. A cut that still has speech or a caption keeps the soft subtitle track.
  • --contact N writes contact.png beside the analysis outputs: a frame every N seconds, scaled to one width, padded to one height, labelled with source timecode. Labels are drawn with Pillow. Paths passed to ffmpeg are absolute.
  • --select moments take optional section and note. The run writes storyboard.md and shots.json next to select.csv.
  • Pillow is a dependency, imported only when --contact runs.

Test plan

  • ruff check .
  • pytest (102 passed)
  • Manual check on macOS: vidtight clip.mov --render and confirm the printed line is at or under −1 dBTP. CI cannot run aac_at. The guard, the ebur128 summary parser, the loudnorm fallback, and the audio-only re-encode are unit-tested. Contact-sheet tiling is tested with mixed frame sizes; frame extraction is tested with absolute paths and stubbed ffmpeg.
  • Silent --broll --render omits the empty SRT from the mux; a cut that contains speech still maps -map 2:s.
  • --select with [] or moments: [] plus --broll keeps nothing. --broll alone still keeps every speech-free window.

Notes for reviewers

Please don't merge this. Jack merges.

The starting limiter ceiling is still 0.83. On the music-video master, 4× oversampling at 0.83 measured about −0.5 dBTP, and about 0.76 cleared −1 dBTP at the same LUFS. The guard steps the ceiling down from the measured overshoot and stops at 0.5 if it cannot get there.

Open in Web Open in Cursor 

…yboards

The render limiter now oversamples 4x and re-encodes audio until the encoded file is at or under -1 dBTP. --broll exports speech-free windows, --contact writes a PIL-labelled sheet, and --select writes a storyboard from optional section and note fields.

Co-authored-by: Jack Arturo <info@verygoodplugins.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T00:05:05.983533Z a6d2e32 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a6d2e32fb0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread vidtight.py
gaps = speech_gaps(blocks, a.dur, a.gap, max(a.min_gap, 0.12), min(max(a.pad, MINPAD), MAXPAD) + hf, MAXPAD, MINPAD + hf, max(a.air, 0.0))
clips, rows = select_moments(y.get("moments", []) if isinstance(y, dict) else y, gaps, blocks, a.dur, a.pre, a.post, a.max_clip, max(JOIN, 2 * a.air))
windows = windows_of(gaps, a.pause) if a.broll else None
if a.broll: clips, rows = select_broll(moments, windows, blocks, a.dur)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow b-roll rendering without a subtitle input

With --broll --render, no moment captions, and no music caption, the kept windows contain no speech, so write_srt() produces an empty file. The render path in main() nevertheless passes that file as -i str(srt) and requires -map 2:s, causing the final mux to fail instead of producing the b-roll video. FFmpeg documents that an optional map is needed to ignore a missing stream “instead of failing” (stream mapping documentation); an empty SRT should be omitted as an input altogether. Please handle caption-free output when routing these windows through rendering.

Useful? React with 👍 / 👎.

Comment thread vidtight.py Outdated
section and note are the caller's, and note on the row stays the reason an edge moved."""
said = lambda x0, x1: " ".join(b["w"] for b in blocks if x0 <= (b["s"] + b["e"]) / 2 <= x1) # speech a clip contains
usable = [w for w in windows if w["hi"] - w["lo"] > 0.05]
if not moments: return [[w["lo"], w["hi"]] for w in usable], []

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Distinguish an empty selection from an omitted selection

When --select moments.yaml --broll receives an empty list (or moments: []), this branch keeps every usable window rather than keeping nothing. select_edl() initializes moments to [] both when --select is absent and when its file contains no moments, so an automatically generated empty selection can unexpectedly render all b-roll and produce an empty shot list describing none of it. Preserve the distinction between no selection requested and an explicitly empty selection.

AGENTS.md reference: AGENTS.md:L9-L12

Useful? React with 👍 / 👎.

cursoragent and others added 2 commits November 23, 2026 00:06
A silent --broll window writes an empty SRT. Mapping that file as a subtitle stream made the final ffmpeg mux fail, so the caption input is left out when there are no cues.

Co-authored-by: Jack Arturo <info@verygoodplugins.com>
--broll without --select still keeps every speech-free window. --select with an empty list keeps nothing, instead of rendering all of them under a blank shot list.

Co-authored-by: Jack Arturo <info@verygoodplugins.com>
@jack-arturo
jack-arturo merged commit bed84ad into main Nov 23, 2026
10 checks passed
@jack-arturo
jack-arturo deleted the conventional-commit-prefix/broll-truepeak-contact-storyboard-b479 branch November 23, 2026 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants