Skip to content

transcode: --target size targeting with Custom size… menu row - #16885

Draft
ButtercupRobrts wants to merge 18 commits into
omacom:quattrofrom
ButtercupRobrts:feat/transcode-target-size-upstream
Draft

ButtercupRobrts wants to merge 18 commits into
omacom:quattrofrom
ButtercupRobrts:feat/transcode-target-size-upstream

Conversation

@ButtercupRobrts

Copy link
Copy Markdown

Stacked on #12135 — this branch builds on the quality-tier work; the diff includes those commits until it merges.

Summary

  • --target size (25M, 1.5G, bare MB) plans a two-pass encode to a size budget: derives video bitrate from target/duration with a ~2% container reserve minus audio, steps the requested rung down a locked floor ladder (4k/1080p/720p) until the budget fits, and refuses with the achievable minimum when it can't
  • Pass logs live in a per-run mktemp passdir with an EXIT-trap cleanup; overshoot triggers exactly one pass-2-only retry at a tightened bitrate, keeping the first playable output if the retry fails
  • A "Custom size…" row on the mp4 quality menu unwraps into the identical CLI path — byte-identical argv, toasts, and dedupe
  • Output names gain the target token (in-1080p-25M.mp4) and toasts disclose step-downs and the measured final size

Test plan

  • test/shell.d/transcode-quality-test.sh — stubbed ffmpeg/ffprobe/menu harness covers target parsing, planner math, pass argv, retries, refusals, menu parity, and no -y/-n pin: all green
  • ./test/cli green

Generated with Devin

ButtercupRobrts and others added 18 commits September 27, 2026 18:46
…load

- bin/omarchy-menu-select parses --default-index N after -- and emits an
  optional defaultIndex integer in the select-mode payload, only when passed
- MenuModel.dmenuDefaultIndex resolves the field into [0, count-1] as a
  node-testable helper; openDmenu initializes selectedIndex from it before
  rebuildDisplay(), so the existing clamp bounds out-of-range values
- typing in the filter still resets the highlight to row 0 (initial-only,
  documented in setFilter and docs/menu.md)
- test/shell.d/menu-select-test.sh proves the field reaches the payload end
  to end via a handshake-satisfying omarchy-shell stub
- perl int() numifies 1e1000/inf/nan to Inf/NaN, which encode_json emits as
  bare tokens — invalid JSON that wedged the CLI on the doneFile wait
- coerce non-finite results to 0, preserving the locked garbage→0 contract;
  regression test runs the real script under timeout so a recurrence fails
  fast instead of hanging
- 4th positional [quality] selects locked tiers: x264 crf 18/23/28,
  x265 crf 20/24/28, gif fps 15/10/5; medium/omitted byte-identical
- high/low append -high/-low to the output name
- output_path dedupes collisions to -2/-3 via [[ -e || -L ]] before
  the Transcoding notification -- no -y/-n, no stdin prompt
- pictures reject a 4th positional pre-notification; strict
  high|medium|low whitelist, empty behaves as omitted
- stub-bin e2e covers the full contract; usage/metadata/docs synced
The Phase-4 sweep pinned "no existing caller passes --default-index" as a
tripwire for the flag's first adoption; omarchy-transcode is that caller, so
the sweep now asserts it is the only one.
- Select quality menu after format+resolution on the interactive video
  path, rows passed as tab-joined label/subtext argv with medium
  pre-highlighted via -- --default-index 1
- mp4 rows carry "CRF N · ~N MB" estimates (ffprobe duration x locked
  resolution/tier bitrate midpoints + audio term, 1-2 sig figs); gif
  rows carry "N fps" subtexts and never probe
- Estimates degrade honestly: per-row "larger than source" past the
  input size, uniform qualitative fallback on probe N/A or failure
- The pick is stripped at the first tab and re-validated high|medium|low
  inside select_quality, before the notification boundary
- --target flag + parse_target_size normalization for free-text sizes
- plan_target: duration probe, bitrate math, floor-based resolution step-down
- transcode_video_target: two-pass encode, pass-scoped toast, one overshoot retry
- refusal matrix: conflicts, gif/picture, below-floor, audio-only, >=source, bad probes
- pass-aware ffmpeg stub + notification -p/-r id stub in shell harness
- select_quality appends an mp4-gated Custom size… sentinel row last,
  single-sourced via $custom_label with a mandatory subtext so
  --default-index 1 and uniform row heights survive
- post-strip sentinel branch mints target:<bytes> through the return
  channel; the tier whitelist keeps rejecting every other foreign label
- new prompt_target_size helper wraps parse_target_size in a bounded
  for-1-2 loop: Esc cancels, empty/unparseable buys one hinted re-prompt
- main() unwraps target:<bytes> inside the menu gate into
  target_bytes/target_token/quality="" -- the planner, output_path, and
  dispatch are byte-identical to a --target run
- plan_target floor case gains the IN-03 *) arm; --target reject loop
  gains the IN-01 empty-string token
- omarchy-menu-input stub (FAKE_INPUT/FAKE_INPUT$n knobs, unset = exit 1
  tripwire) ships in the same commit so the suite can never hang on the
  real binary's done_file spin-wait
--target, size estimates, refusal minimums, and the done notification
now all mean 1 MB = 1,000,000 bytes (numfmt --from/--to=si), matching
file managers and upload limits like Discord's 25 MB cap. Previously
IEC/MiB units made a 400M target budget ~419 MB, so outputs read ~16 MB
larger than asked in the Files app.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.

1 participant