Skip to content

Free, open-source AI video generator for Mac. Run LTX-2.5 and MiniMax H3 (Hailuo) locally on Apple Silicon: text-to-video and image-to-video with sound, lip-sync, character LoRA training, songs from lyrics (YuE2) and image editing (Qwen-Image-Edit). One-click install via Pinokio. Offline: no cloud, no API key, no NVIDIA GPU.

release(v4.16.1): 720p and 1080p exports fill the frame instead of adding black bars

mrbizarro4a8d62ccb674
diff --git a/README.md b/README.md
index 725b5a9..f636536 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@
</p>
-> **Current release: v4.16.0.** **The Music Studio, and more than 70 fixes.** A song is now something you keep working on: every song keeps what made it, so you can make a new take, re-roll the sound, put a new style on the same score, cover it or edit the score; a Song card shows the sheet music and lyrics; the Audio view is a song list with a player bar; the composer writes lyrics, edits them section by section, and turns one description into a song (Simple mode); a Voice & style LoRA picker and a music-video planner come with it. The same release fixes more than 70 bugs, most of them found by a review of seven user flows: Editor saves that dropped transitions, LoRAs that Extend, FFLF and Q4 Audio to Video ignored, Stop that did not stop, downloads that Cancel restarted, an Update that could not rebuild an empty engine, and more. Hailuo H3 decodes video in FP16 by default (same picture, about 14% faster decode). Press Update in Pinokio, then restart. Full notes on the [releases page](https://github.com/mrbizarro/Phosphene/releases).
+> **Current release: v4.16.1.** **No more black bars on a 720p or 1080p export.** Hailuo H3's Draft and Standard canvases (and LTX's Standard) are close to 16:9 but not exactly, and the export used to pad the difference with black: 40 px down each side of a Draft clip at 720p. Now the picture fills the frame and a few pixels are trimmed at the edges instead; canvases far from 16:9 (square, 4:3) still get bars. 4.16.0 brought the Music Studio and more than 70 fixes. Full notes on the [releases page](https://github.com/mrbizarro/Phosphene/releases).
## Overview
diff --git a/VERSION b/VERSION
index ecbc3b0..27593c8 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-4.16.0
+4.16.1
diff --git a/docs/H3_ENGINE.md b/docs/H3_ENGINE.md
index ae2baea..e1ef830 100644
--- a/docs/H3_ENGINE.md
+++ b/docs/H3_ENGINE.md
@@ -36,6 +36,19 @@ at 1024×576 / 124f (27.3 GiB Q8, 42.8 GiB bf16). On the staged loader at
10 s one, so a length-aware gate could open short H3 renders to smaller Macs.
That gate does **not** exist; the floors are deliberately one number per lane.
+**Field data — 48 GB really runs it.** A user report (X, 2026-09-24, v4.15.3,
+M5 Pro 48 GB, the compact Q8 engine, Image mode, 3 s clips). Peak is the
+system memory the user read while rendering, not an MLX-internal number:
+
+| Tier | Clip | Peak memory | Wall |
+|---|---|---|---|
+| Draft (640×384) | 3 s | 37 GB | 2 m 32 s |
+| Standard (768×448) | 3 s | 36 GB | 3 m 53 s |
+| High (1024×576) | 3 s | 39 GB | 13 m 27 s |
+
+Consistent with the Q8 lane's 25.63 GiB run peak plus macOS and the panel, and
+with the 36 GB floor leaving headroom on a 48 GB Mac.
+
---
## How it plugs in
@@ -318,12 +331,29 @@ appended, and a fallback nobody asked for has to be the cheap one.
### Export pass — the same post-process LTX renders get
-Most tiers write 768×448 (12:7), which is neither 720p nor 1080p. The panel runs
-the identical ffmpeg recipe an LTX render gets: lanczos fit inside the canvas +
-pad the remainder + `libx264` with the user's codec settings (`yuv420p crf 18`
-by default) + `+faststart`, audio copied through untouched. Bars on 12:7 content
-are correct — no crop, no distortion — and they land at the **sides**
-(pillarbox: 23 px at 720p, 34 px at 1080p), because 12:7 is *taller* than 16:9.
+Draft writes 640×384 (5:3) and Standard 768×448 (12:7), neither of them 720p
+nor 1080p. The panel runs the identical ffmpeg recipe an LTX render gets:
+lanczos scale + `libx264` with the user's codec settings (`yuv420p crf 18` by
+default) + `+faststart`, audio copied through untouched.
+
+**Since 4.16.1 a near-16:9 canvas FILLS the frame instead of getting bars.**
+Until then a non-matching source was fitted inside the canvas and padded:
+Draft → 720p had **40 px of black on each side**, Standard 23 px (luma-scanned
+on real exports). A 48 GB user on X asked whether that was a bug (2026-09-24),
+and for a file whose job is to be 720p it was. Now a source within
+`EXPORT_FILL_MAX_TRIM` (8%) of the target aspect is scaled to **cover** the
+canvas and centre-cropped: 5:3 → 720p trims 24 px top and bottom, 12:7 13 px,
+Native 7:4 → 1080p 8 px. The same rule applies to LTX exports (1280×704 → 720p
+trims 14 px left and right instead of 8 px bars) and to the Sharp (PiperSR)
+path, which carries its own copy of the constant. A source further off —
+square, 4:3 — still pads: cutting a third of the picture is worse than bars.
+The plan reports `fill: True` plus `trim_w`/`trim_h`.
+
+The picture was never the problem: an Image-mode reference is already
+cover-cropped onto the tier canvas before conditioning (`_h3_fit_first_frame`,
+centre crop — no face detection ships with the base install), so the bars came
+only from this export pass. The High tier (1024×576) is exact 16:9 and gets
+neither a crop nor a pad.
**A source that already matches the target aspect takes a pure-scale path**
(2026-08-06). `compute_upscale_plan` compares `w·target_h == h·target_w`; on a match
@@ -331,12 +361,12 @@ it emits `scale=W:H:flags=lanczos` with **no pad filter at all** and reports
`pad: False` on the plan (plus `fit_w`/`fit_h`, the content size inside the
canvas, so a sidecar reader can tell bars from picture). `wide_5s` → 720p is a
pure 1.25× and → 1080p a pure 1.875×. Everything that does not match keeps the
-fit-and-pad filtergraph byte-for-byte.
+fill-or-pad rule above.
The panel says which one you are about to get: `_h3_export_notes()` generates one
sentence per export mode **from `compute_upscale_plan` itself** — "720p: pure
-1.25× scale to 1280×720 — no bars, no padding." vs "720p: 12:7 fits to 1234×720
-inside 1280×720 — 23 px bars left and right." — ships it on each tier as
+1.25× scale to 1280×720 — no bars, no padding." vs "720p: 12:7 fills 1280×720 —
+13 px trimmed top and bottom, no bars." — ships it on each tier as
`export_note`, and `_h3SyncExportNote()` prints it under the Export row. The copy
can never disagree with the ffmpeg command because it is generated from it.
diff --git a/docs/STATE.md b/docs/STATE.md
index c9eeda5..2220696 100644
--- a/docs/STATE.md
+++ b/docs/STATE.md
@@ -1,3 +1,5 @@
+> **🎞 2026-09-24 — v4.16.1: 720p/1080p exports fill the frame instead of padding black bars.** Same X user as 4.15.3 (M5 Pro 48 GB, on 4.15.3), after posting H3 numbers (Draft 3 s 37 GB 2m32s, Standard 36 GB 3m53s, High 39 GB 13m27s — recorded in docs/H3_ENGINE.md as field data): "Is it a bug that black bars appear on the left and right when the resolution is set to 720p?" (H3 Image→Video from a photo). **Cause:** not the reference fit — `_h3_fit_first_frame` already cover-crops the reference onto the tier canvas — but the export pass: `compute_upscale_plan` fitted any non-16:9 source INSIDE 1280×720 and padded. H3 Draft is 640×384 (5:3) → **40 px black each side**, Standard 768×448 (12:7) → 23 px; luma-scanned on two real exports in the owner's outputs (L=40/R=40 and L=22/R=26) and reproduced with a portrait and a 16:9 reference through the real `_h3_fit_first_frame` + both filtergraphs (4.16.0 bars, 4.16.1 none). LTX had the same shape on 1280×704 (8 px top/bottom); LTX i2v otherwise snaps its canvas to the image's orientation and Balanced is exact 16:9. The 2026-08-06 entry called the pillarbox "correct — no crop, no distortion"; for a file whose job is to be 720p it wasn't, and the app already crops rather than pads elsewhere (reference fit, Extend's downscale ≤31 px). **Fix:** `EXPORT_FILL_MAX_TRIM = 0.08` — a source within 8% of the target aspect is scaled to cover + centre-cropped (`scale=…:force_original_aspect_ratio=increase,crop=W:H`); plan gains `fill`, `trim_w`, `trim_h`. 5:3→720p trims 24 px top/bottom, 12:7 13 px, 1280×704 14 px left/right, Native 7:4→1080p 8 px. Square/4:3 keep bars. The Sharp (PiperSR) script carries the same constant (a test holds them equal) and now gets the source dims. Export notes, tier blurbs, the pill sub-labels ("scale to fill"), H3/LTX log lines and webapp/docs/video.md updated. No face detection ships with the base install (cv2 is not in a fresh venv), so the crop is centred; the trims are ≤ 3.4% per edge. One Codex pass (codex-cli 0.155.1, read-only): P2 — LTX `i2v_clean_audio` pads 1280×704→1280×720 at the mux BEFORE the export, so the fill cropped a frame that already had bars and the plan lied (fixed: the mux skips its pad when the export will fill; with export off the pad stays); P3 — "no crop" still promised in two Export hints and the clip-details rows (fixed: the rows read the sidecar plan — "filled, edges trimmed" / "bars added" / "no crop"). New `test_export_fill_no_bars.py` (12; the 10 original ones all fail on 4.16.0; one encodes a real 640×384 clip through both targets and checks the edge columns/rows are not black). Not changed: storyboard film assembly still pads mixed-aspect clips on purpose (`test_storyboard_assembly` pins "bars, never crop").
+
> **🎼 2026-09-24 — v4.16.0: the Music Studio line goes public, with the 4.16.0 review fixes.** Codex reviewed seven flows of beta `cdca462` (install, jobs, LTX, H3, storyboard/editor, music, UI): 69 findings, fixed on three branches (`fix416-jobs` 17, `fix416-editor` 25 incl. one extra editor bug, `fix416-install` 27 + the FP16 flag; JOB-05 = INST-07), each with a test that fails before its fix. Integrated as `int-4160` on beta `33dd394` (after the 4.15.4 merge-back). **Conflicts:** only the UI-01 pair (`panel/routes_files.py`, `test_image_route_scope.py`), resolved to the 4.15.4 version (wider raster allowlist, never svg) keeping fix416-install's trash (UI-05) change; mlx_ltx_panel.py, queue.js, characters.js and image_engine.py auto-merged. **One Codex pass on the combined diff** (gpt-6-astra, high, read-only): 2×P2, both fixed — Load Params on a pre-4.15.2 a2v clip restored the legacy float 1.0 as an explicit "1" (audio guidance off on Q8; now reopens as Auto, `test_review_416_ltx.py`), and an incomplete FLAT H3 weights tree (LTX_H3_MODELS) was skipped by Install/Repair forever (now `h3_fetch_weights` in `h3_roots.sh` stops with an `error:` naming the missing parts; install_h3.js dispatch 16 chars). **Fleet fix:** "The reference image can't be read (ModuleNotFoundError)" was a half-installed engine venv (panel cannot import PIL), not a bad picture — 6 H3 i2v failures, one 4.15.2 install; `h3_reference_image_error()` now gives ENGINE_ENV_REPAIR (venv_broken). **H3 FP16 decode ON by default** after the release A/B through the panel (High 5 s Turbo, seed 42, runner 7919020): decode 90.1 → 77.4 s, peak 10.7 → 9.5 GiB, no visible difference (RGB PSNR 42 dB through the h264 exports; mean |Δ| 1.4/255). **LTX-03 verified on the GPU:** FFLF (Q8 dev, 768×384/49f) and Q4 A2V (Compact tier, 512×256/49f) with Pixar_Toon attach 576/576 modules and change the clip (PSNR vs no-LoRA 30.3 / 25.4 dB); a repeat no-LoRA A2V is bit-identical (inf), so the LoRA cache key releases the adapter. **Tests:** full root pytest in one process = the same suite-order pollution as beta/main (route tests pass alone, fail after an earlier test rebinds panel globals; beta/main shows it on test_routes/test_uploads/test_room_tone, int adds test_trash_collisions/test_version_pull_route — all pass per file); `release_gates.sh --fast` int 143/4/2 vs beta/main 119/4/2 with the identical 4 environmental FAILs (assert_registry 152/17 and assert_schedules 40/5 need packs + the bizarrotrn character, test_yue2_train_voice needs yue2 weights, scripts/test_pack_release no-mirror case). PostHog: the 403 a fixer saw was an endpoint the query key has no scope for; HogQL queries with it return 200. **Skipped-by-fast gates run separately:** test_storyboard_editor_ui 466 passed; check_output_codec PASS on the FFLF render. **From zero:** fresh clone of the release commit + install.js code steps in a Pinokio-shaped env (miniforge PATH, MPS fallback + fast-math set, no SSL/SSH/PYTHONPATH), booted the start.js way → /version 4.16.0 not dirty, UI 200, no traceback, /image refuses the settings file, a render with no weights fails naming the missing pack. **Update path:** a 4.15.4 install cloned from a local stand-in for public main, then 4.16.0 published there and update.js run → fast-forward, 4 steps rc 0, no `error:` line, VERSION 4.16.0, /status integrity OK. **INST-03:** env replaced by an empty `uv venv --seed` (boot WARNs "has a Python but no packages"); Update again → post_update rebuilt it, `import ltx_core_mlx, ltx_pipelines_mlx, mlx, mlx_arsenal` OK, boot clean; Repair (install.js code steps) rebuilds it too. **Found on the way, NOT fixed (mirror, not code):** the weights-ltx25-v1 release asset `LICENSE-LTX-2.x-Community-License.md` was overwritten on 2026-09-06 by the ic_upscale_x2 publish (34545 B, sha a6622b0e…); q4_25/q8_25/hq_25/gemma4_25 manifests expect 30938 B (4e7dd26d…), so every mirror fetch of those packs ends "1 file FAILED" + a WARN, though every weight file verifies and the pack reads ready.
> **🔒 2026-09-24 — v4.15.4: /image serves images only (security hotfix, Codex UI-01).** `panel/routes_files.py get_image` resolved the path and checked it sat under OUTPUT / UPLOADS / STATE_DIR — and served ANY file there. STATE_DIR holds `panel_settings.json` (HF token, CivitAI key, PostHog keys, which `/settings` never returns), so a local process, another local user, or anyone reaching a LAN-exposed/proxied panel could read them with one GET. A cross-origin web page could trigger the request but not read the response (no CORS headers). Fix: `IMAGE_ROUTE_EXTS` (png/jpg/jpeg/jpe/jfif/webp/gif + bmp/tif/tiff/avif/heic/heif, because the pickers accept `image/*`; **never svg** — same-origin script) checked right after the root check, before the file is opened, so the thumbnail path (w=) cannot fall back to serving the original either. Fixed first on beta branch fix416-install (f0a380a, image set widened here), ported alone onto public 4.15.3. Test `test_image_route_scope.py` (settings/queue/fleet/no-extension files 403 with and without w=, sidecar JSON in outputs/uploads 403, png/JPG/bmp/tiff still 200 from every root, svg 403, /etc/hosts 403); fails 3/6 on 4.15.3. Other path routes re-checked: /file is OUTPUT-only, /sidecar is media-suffix-gated OUTPUT/UPLOADS, /loras/download is .safetensors under the loras dir. One Codex pass (gpt-6-astra, read-only): leak closed (symlink/case/trailing-dot/double-ext/thumbnail fallback all checked); P3 .jfif/.jpe uploads would have 403d -> added; 2xP2 need a planted symlink in the thumb cache or next to an output (attacker already has file write as the user) -> not a boundary, left.
diff --git a/mlx_ltx_panel.py b/mlx_ltx_panel.py
index 5382747..51dad76 100644
--- a/mlx_ltx_panel.py
+++ b/mlx_ltx_panel.py
@@ -8827,7 +8827,7 @@ def _h3_qualities() -> dict[str, dict]:
"width": 768, "height": 448,
"blurb": "The workhorse canvas — every chained-window measurement "
"on this Mac was taken here. 12:7, so a 720p/1080p export "
- "pads bars at the sides.",
+ "trims a few pixels top and bottom to fill 16:9.",
"offered": True,
},
# The only true-16:9 delivery canvas H3 can serve (see the block comment
@@ -8847,7 +8847,7 @@ def _h3_qualities() -> dict[str, dict]:
"key": "high", "label": "High", "order": 2,
"width": 1024, "height": 576,
"blurb": "True 16:9 — the only canvas that exports to 720p as a "
- "pure 1.25× scale with no bars, and it resolves face "
+ "pure 1.25× scale with nothing trimmed, and it resolves face "
"detail 768×448 cannot. Auto runs 15 forwards here, not 8: "
"at 8 faces in motion come out soft. The recommended "
"delivery canvas.",
@@ -8867,8 +8867,8 @@ def _h3_qualities() -> dict[str, dict]:
"key": "native", "label": "Native", "order": 3,
"width": 1344, "height": 768,
"blurb": "The model's own canvas at its 1.03 MP ceiling — the most "
- "detail H3 can produce. 7:4, so an export adds thin bars "
- "top and bottom. Worth it with Turbo on; a long wait "
+ "detail H3 can produce. 7:4, so a 1080p export trims a "
+ "few pixels to fill 16:9. Worth it with Turbo on; a long wait "
"without.",
"steps": H3_NATIVE_STEPS,
"offered": True,
@@ -12959,7 +12959,13 @@ def _h3_export_notes(w: int, h: int) -> dict[str, str]:
continue
tw, th = int(plan["target_w"]), int(plan["target_h"])
name = "1080p" if str(plan["tag"]).endswith("1080p") else "720p"
- if not plan.get("pad"):
+ if plan.get("fill"):
+ cut = (f"{int(plan['trim_h']) // 2} px trimmed top and bottom"
+ if int(plan["trim_h"]) >= int(plan["trim_w"]) else
+ f"{int(plan['trim_w']) // 2} px trimmed left and right")
+ out[mode] = (f"{name}: {_h3_aspect(w, h)} fills {tw}×{th} — "
+ f"{cut}, no bars.")
+ elif not plan.get("pad"):
out[mode] = (f"{name}: pure {tw / float(w):g}× scale to {tw}×{th} — "
f"no bars, no padding.")
else:
@@ -18537,6 +18543,30 @@ def bt709_vf(vf: str | None = None) -> str:
return f"{vf},{BT709_SETPARAMS}" if vf else BT709_SETPARAMS
+# FILL, DON'T PAD, WHEN THE MISMATCH IS SMALL. A 720p/1080p export used to fit
+# every non-16:9 render inside the canvas and pad the rest with black. For H3's
+# Draft (640x384, 5:3) that is 40 px of black on each side of a 1280x720 file,
+# for Standard (768x448, 12:7) 23 px — measured on real exports with a luma
+# scan — and a user with a 48 GB Mac asked on X whether the bars were a bug
+# (2026-09-24). They were the design ("no crop, no distortion"), and the
+# design was wrong for a file whose job is to BE 720p: the same app already
+# cover-crops the H3 reference (_h3_fit_first_frame) and Extend's downscale
+# (≤31 px) rather than show bars, and LTX's default canvas is exact 16:9.
+# So a source whose aspect is within this fraction of the target's is scaled
+# to COVER the canvas and centre-cropped: 5:3 loses 6.25% of its height, 12:7
+# 3.6%, LTX's 1280x704 2.2% of its width. Anything further off (square, 4:3,
+# a portrait source into a landscape canvas) still pads — cropping a third of
+# the picture away is worse than bars.
+EXPORT_FILL_MAX_TRIM = 0.08
+
+
+def _export_trim_fraction(w: int, h: int, target_w: int, target_h: int) -> float:
+ """How much of the picture a cover-crop onto target_w x target_h would cut,
+ as a fraction of the cropped axis (0 = same aspect)."""
+ a, b = w / float(h), target_w / float(target_h)
+ return 1.0 - min(a, b) / max(a, b)
+
+
def _fit_inside(w: int, h: int, target_w: int, target_h: int) -> tuple[int, int]:
"""The content size ffmpeg's `force_original_aspect_ratio=decrease` lands on
— the source scaled to touch the canvas on its tighter axis. Used to say how
@@ -18598,9 +18628,25 @@ def compute_upscale_plan(w: int, h: int, mode: str | None,
if eff_w >= target_w and eff_h >= target_h:
return None
exact_aspect = (eff_w * target_h == eff_h * target_w)
+ fill = False
+ trim_w = trim_h = 0
if exact_aspect:
fit_w, fit_h = target_w, target_h
vf = f"scale={target_w}:{target_h}:flags=lanczos"
+ elif _export_trim_fraction(eff_w, eff_h, target_w, target_h) <= EXPORT_FILL_MAX_TRIM:
+ # Cover + centre-crop (see EXPORT_FILL_MAX_TRIM). The picture fills
+ # the whole canvas; `trim_w`/`trim_h` are the pixels cut in total
+ # at output scale, so the export note and the sidecar can say so.
+ s = max(target_w / float(eff_w), target_h / float(eff_h))
+ trim_w = max(0, int(round(eff_w * s)) - target_w)
+ trim_h = max(0, int(round(eff_h * s)) - target_h)
+ fit_w, fit_h = target_w, target_h
+ fill = True
+ vf = (
+ f"scale={target_w}:{target_h}:"
+ "force_original_aspect_ratio=increase:flags=lanczos,"
+ f"crop={target_w}:{target_h}"
+ )
else:
fit_w, fit_h = _fit_inside(eff_w, eff_h, target_w, target_h)
vf = (
@@ -18608,7 +18654,7 @@ def compute_upscale_plan(w: int, h: int, mode: str | None,
"force_original_aspect_ratio=decrease:flags=lanczos,"
f"pad={target_w}:{target_h}:(ow-iw)/2:(oh-ih)/2:color=black"
)
- pad = not exact_aspect
+ pad = not (exact_aspect or fill)
method = "ffmpeg_lanczos_downscale" if helper_did_model_upscale else "ffmpeg_lanczos"
elif mode == "x2":
# If the helper already did model x2, the file is already at the
@@ -18617,6 +18663,7 @@ def compute_upscale_plan(w: int, h: int, mode: str | None,
return None
target_w, target_h, tag = w * 2, h * 2, "up2x"
fit_w, fit_h, pad = target_w, target_h, False
+ fill, trim_w, trim_h = False, 0, 0
vf = f"scale={target_w}:{target_h}:flags=lanczos"
method = "ffmpeg_lanczos"
else:
@@ -18630,6 +18677,10 @@ def compute_upscale_plan(w: int, h: int, mode: str | None,
# a pure scale; `fit_w`/`fit_h` are the content size inside the canvas,
# so a sidecar reader can tell bars from picture without re-deriving it.
"pad": pad,
+ # `fill` True: cover + centre-crop, `trim_w`/`trim_h` pixels cut.
+ "fill": fill,
+ "trim_w": trim_w,
+ "trim_h": trim_h,
"fit_w": fit_w,
"fit_h": fit_h,
"tag": tag,
@@ -29262,11 +29313,11 @@ def run_h3_job_inner(job: dict) -> None:
# ---- export pass: the SAME post-process an LTX render gets ------------
# Most tiers write 768×448 (12:7), which is neither 720p nor 1080p and looks
# like a bug next to LTX output in the gallery. Run the identical ffmpeg
- # recipe: lanczos fit inside the canvas, pad the remainder, re-encode with
- # the user's codec settings, audio copied through untouched. Pillarboxing
- # 12:7 into 16:9 is the correct answer — no crop, no distortion. The
- # `wide_5s` tier renders 1024×576, which IS 16:9, so the same call comes
- # back with a pure-scale plan and no pad filter at all. The native file
+ # recipe: re-encode with the user's codec settings, audio copied through
+ # untouched. Since 4.16.1 a near-16:9 canvas (Draft 5:3, Standard 12:7)
+ # FILLS the frame with a small centre crop instead of pillarboxing — see
+ # EXPORT_FILL_MAX_TRIM. High (1024×576) IS 16:9, so the same call comes
+ # back with a pure-scale plan and neither a crop nor a pad. The native file
# stays on disk but hidden from the gallery, exactly like the LTX path.
native_path = out_path
final_target = out_path
@@ -29300,8 +29351,10 @@ def run_h3_job_inner(job: dict) -> None:
upscale_plan["method"] = "ffmpeg_lanczos"
final_target = upscaled_out
push(f"[h3] export done → {upscaled_out.name} "
- f"({upscale_plan['target_w']}×{upscale_plan['target_h']}, no crop, "
- + ("no bars — pure scale, " if not upscale_plan.get("pad") else
+ f"({upscale_plan['target_w']}×{upscale_plan['target_h']}, "
+ + (f"filled, {upscale_plan['trim_w'] or upscale_plan['trim_h']} px "
+ f"cropped at the edges, no bars, " if upscale_plan.get("fill") else
+ "no bars — pure scale, " if not upscale_plan.get("pad") else
f"{upscale_plan['fit_w']}×{upscale_plan['fit_h']} of picture "
f"+ bars, ")
+ f"{codec['pix_fmt']} crf {codec['crf']}, preset={export_preset})")
@@ -31509,6 +31562,18 @@ def run_job_inner(job: dict) -> None:
p["width"], p["height"] = width, height
pad_w, pad_h, pad_filter = compute_pad(width, height)
+ # The clean-audio mux pads 1280x704 to 1280x720 with 8 px of black. When
+ # the export will FILL that canvas (4.16.1, EXPORT_FILL_MAX_TRIM) the mux
+ # must not pad first: the export would then cover-crop a frame that
+ # already carries the bars, and the plan would report a fill that left
+ # them in place (Codex review, 4.16.1). With the export off, the pad stays.
+ if pad_filter and mode == "i2v_clean_audio":
+ try:
+ _fill_plan = compute_upscale_plan(width, height, p.get("upscale", "off"))
+ except RuntimeError:
+ _fill_plan = None
+ if _fill_plan and _fill_plan.get("fill"):
+ pad_w, pad_h, pad_filter = width, height, None
suffix = f"{pad_w}x{pad_h}" if mode == "i2v_clean_audio" and pad_filter else f"{width}x{height}"
tag = f"{mode}_hq" if ltx_quality_uses_hq(quality) else mode
# Only `i2v_clean_audio` runs a panel-side mux (raw → final). For T2V / I2V /
@@ -31995,8 +32060,11 @@ def run_job_inner(job: dict) -> None:
final_target = upscaled_out
push(
f"Upscale done → {upscaled_out.name} "
- f"({upscale_plan['target_w']}×{upscale_plan['target_h']}, no crop, "
- f"{upscale_plan['method']}, {mux_pix_fmt} crf {mux_crf}, preset={upscale_preset})"
+ f"({upscale_plan['target_w']}×{upscale_plan['target_h']}, "
+ + (f"filled, {upscale_plan.get('trim_w') or upscale_plan.get('trim_h')} px "
+ f"cropped at the edges, " if upscale_plan.get("fill") else
+ "no crop, ")
+ + f"{upscale_plan['method']}, {mux_pix_fmt} crf {mux_crf}, preset={upscale_preset})"
)
set_hidden(str(native_target), True)
push(f"Native source kept but hidden from gallery → {native_target.name}")
diff --git a/scripts/upscale_compare_pipersr.py b/scripts/upscale_compare_pipersr.py
index 0f97227..21a88e5 100755
--- a/scripts/upscale_compare_pipersr.py
+++ b/scripts/upscale_compare_pipersr.py
@@ -90,7 +90,24 @@ BT709_FLAGS = ["-color_primaries", "bt709", "-color_trc", "bt709",
"-colorspace", "bt709"]
-def fit_filter(target_w: int, target_h: int) -> str:
+# Same rule, same number as EXPORT_FILL_MAX_TRIM in mlx_ltx_panel.py (this
+# script runs standalone, so it carries its own copy; a test holds the two
+# equal): a source within 8% of the target aspect is scaled to COVER the
+# canvas and centre-cropped instead of padded with black bars.
+EXPORT_FILL_MAX_TRIM = 0.08
+
+
+def fit_filter(target_w: int, target_h: int,
+ src_w: int | None = None, src_h: int | None = None) -> str:
+ if src_w and src_h:
+ a, b = src_w / float(src_h), target_w / float(target_h)
+ if 1.0 - min(a, b) / max(a, b) <= EXPORT_FILL_MAX_TRIM:
+ return (
+ f"scale={target_w}:{target_h}:"
+ "force_original_aspect_ratio=increase:flags=lanczos,"
+ f"crop={target_w}:{target_h},"
+ f"{BT709_SETPARAMS}"
+ )
return (
f"scale={target_w}:{target_h}:"
"force_original_aspect_ratio=decrease:flags=lanczos,"
@@ -106,7 +123,7 @@ def make_lanczos(input_mp4: Path, output_mp4: Path, crf: str, pix_fmt: str, pres
run([
str(ffmpeg_path()), "-hide_banner", "-y",
"-i", str(input_mp4),
- "-vf", fit_filter(target_w, target_h),
+ "-vf", fit_filter(target_w, target_h, int(info["width"]), int(info["height"])),
"-c:v", "libx264", "-pix_fmt", pix_fmt, "-crf", crf, "-preset", preset,
*BT709_FLAGS,
"-movflags", "+faststart",
@@ -211,7 +228,7 @@ def make_pipersr(input_mp4: Path, output_mp4: Path, crf: str, pix_fmt: str, pres
"-i", str(frames_2x / "frame_%06d.png"),
"-i", str(input_mp4),
"-map", "0:v:0", "-map", "1:a?",
- "-vf", fit_filter(target_w, target_h),
+ "-vf", fit_filter(target_w, target_h, int(info["width"]), int(info["height"])),
"-c:v", "libx264", "-pix_fmt", pix_fmt, "-crf", crf, "-preset", preset,
*BT709_FLAGS,
"-movflags", "+faststart",
diff --git a/test_export_fill_no_bars.py b/test_export_fill_no_bars.py
new file mode 100644
index 0000000..73842fc
--- /dev/null
+++ b/test_export_fill_no_bars.py
@@ -0,0 +1,181 @@
+"""A 720p / 1080p export of a near-16:9 render fills the frame — no black bars.
+
+THE REPORT (X, 2026-09-24, v4.15.3, M5 Pro 48 GB): "Is it a bug that black
+bars appear on the left and right when the resolution is set to 720p?" H3
+Image->Video from a photo. H3's Draft canvas is 640x384 (5:3) and Standard
+768x448 (12:7); neither is 16:9, and `compute_upscale_plan` fitted them INSIDE
+1280x720 and padded the rest: 40 px of black each side on Draft, 23 on
+Standard — measured with a luma scan on real exports from this Mac. LTX's
+Standard (1280x704) got 8 px bars top and bottom the same way.
+
+Since 4.16.1 a source within EXPORT_FILL_MAX_TRIM (8%) of the target aspect is
+scaled to cover the canvas and centre-cropped. Anything further off (square,
+4:3) keeps its bars — cutting a third of the picture is worse.
+
+The ffmpeg case runs the REAL filtergraph on a real clip and scans the output's
+columns, so it proves the pixels, not the string.
+"""
+from __future__ import annotations
+
+import os
+import shutil
+import subprocess
+import sys
+import tempfile
+import unittest
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parent
+STATE = Path(tempfile.mkdtemp(prefix="phos-fill-"))
+os.environ["LTX_STATE_DIR"] = str(STATE)
+os.environ["PHOSPHENE_ANALYTICS_DISABLED"] = "1"
+os.environ["PHOSPHENE_DISABLE_VERSION_CHECK"] = "1"
+sys.path.insert(0, str(ROOT))
+sys.path.insert(0, str(ROOT / "scripts"))
+
+import mlx_ltx_panel as P # noqa: E402
+
+
+class TestPlanFillsNearSixteenNine(unittest.TestCase):
+ def test_h3_draft_and_standard_fill_720p_and_1080p(self):
+ for w, h in ((640, 384), (768, 448)):
+ for mode, tw, th in (("fit_720p", 1280, 720), ("fit_1080p", 1920, 1080)):
+ plan = P.compute_upscale_plan(w, h, mode)
+ self.assertEqual((plan["target_w"], plan["target_h"]), (tw, th))
+ self.assertTrue(plan["fill"], (w, h, mode))
+ self.assertFalse(plan["pad"], (w, h, mode))
+ self.assertNotIn("pad=", plan["vf"])
+ self.assertIn("force_original_aspect_ratio=increase", plan["vf"])
+ self.assertIn(f"crop={tw}:{th}", plan["vf"])
+ self.assertEqual((plan["fit_w"], plan["fit_h"]), (tw, th))
+ self.assertGreater(plan["trim_h"], 0)
+ self.assertEqual(plan["trim_w"], 0)
+
+ def test_ltx_standard_and_its_portrait_twin_fill_too(self):
+ for w, h in ((1280, 704), (704, 1280)):
+ plan = P.compute_upscale_plan(w, h, "fit_720p")
+ self.assertTrue(plan["fill"])
+ self.assertLessEqual(max(plan["trim_w"], plan["trim_h"]), 31)
+
+ def test_exact_16x9_is_still_a_pure_scale(self):
+ for w, h in ((1024, 576), (576, 1024)):
+ plan = P.compute_upscale_plan(w, h, "fit_720p")
+ self.assertFalse(plan["fill"])
+ self.assertFalse(plan["pad"])
+ self.assertEqual(plan["vf"], f"scale={plan['target_w']}:{plan['target_h']}:flags=lanczos")
+
+ def test_far_from_16x9_keeps_its_bars(self):
+ for w, h in ((768, 768), (640, 480)):
+ plan = P.compute_upscale_plan(w, h, "fit_720p")
+ self.assertTrue(plan["pad"])
+ self.assertFalse(plan["fill"])
+ self.assertIn("pad=1280:720", plan["vf"])
+
+ def test_the_trim_cap_is_what_separates_them(self):
+ self.assertLessEqual(P._export_trim_fraction(640, 384, 1280, 720), P.EXPORT_FILL_MAX_TRIM)
+ self.assertGreater(P._export_trim_fraction(640, 480, 1280, 720), P.EXPORT_FILL_MAX_TRIM)
+
+ def test_native_never_shrinks_and_x2_is_untouched(self):
+ self.assertIsNone(P.compute_upscale_plan(1344, 768, "fit_720p"))
+ x2 = P.compute_upscale_plan(768, 448, "x2")
+ self.assertFalse(x2["fill"])
+ self.assertEqual(x2["vf"], "scale=1536:896:flags=lanczos")
+
+ def test_export_note_says_trimmed_not_bars(self):
+ notes = P._h3_export_notes(768, 448)
+ self.assertIn("fills 1280×720", notes["fit_720p"])
+ self.assertIn("no bars", notes["fit_720p"])
+ self.assertNotIn("px bars", notes["fit_720p"])
+ self.assertNotIn("px bars", P._h3_export_notes(640, 384)["fit_1080p"])
+
+ def test_tier_blurbs_no_longer_promise_bars(self):
+ for q in P.H3_QUALITIES.values():
+ self.assertNotIn("pads bars", q.get("blurb", ""))
+ self.assertNotIn("adds thin bars", q.get("blurb", ""))
+
+
+class TestCodexReviewFindings(unittest.TestCase):
+ """One Codex pass on 4.16.1: two places still promised or produced bars."""
+
+ SRC = (ROOT / "mlx_ltx_panel.py").read_text()
+
+ def test_clean_audio_mux_does_not_pad_before_a_fill(self):
+ # i2v_clean_audio pads 1280x704 -> 1280x720 at the mux; the export
+ # then cover-cropped a frame that already had the bars in it.
+ self.assertEqual(P.compute_pad(1280, 704)[2], "pad=1280:720:0:8:color=black")
+ block = self.SRC.split("pad_w, pad_h, pad_filter = compute_pad(width, height)")[1][:1200]
+ self.assertIn('mode == "i2v_clean_audio"', block)
+ self.assertIn('_fill_plan.get("fill")', block)
+ self.assertIn("pad_w, pad_h, pad_filter = width, height, None", block)
+ self.assertTrue(P.compute_upscale_plan(1280, 704, "fit_720p")["fill"])
+ self.assertIsNone(P.compute_upscale_plan(1280, 704, "off"))
+
+ def test_ui_no_longer_promises_no_crop_on_a_fill(self):
+ js = (ROOT / "webapp/js/queue.js").read_text()
+ html = (ROOT / "webapp/index.html").read_text()
+ self.assertNotIn("'720p fit (no crop)'", js)
+ self.assertNotIn("'1080p fit (no crop)'", js)
+ self.assertIn("up.fill ? 'filled, edges trimmed'", js)
+ self.assertNotIn("post-render, no crop", html)
+ self.assertNotIn("after the render · no crop", html)
+ self.assertNotIn('class="sub">scale + pad<', html)
+
+
+class TestSharpPathUsesTheSameRule(unittest.TestCase):
+ """The Sharp (PiperSR) export runs a standalone script with its own copy."""
+
+ def test_same_cap_and_same_decision(self):
+ import upscale_compare_pipersr as S
+ self.assertEqual(S.EXPORT_FILL_MAX_TRIM, P.EXPORT_FILL_MAX_TRIM)
+ self.assertIn("crop=1280:720", S.fit_filter(1280, 720, 1536, 896))
+ self.assertIn("pad=1280:720", S.fit_filter(1280, 720, 768, 768))
+ self.assertIn("pad=1280:720", S.fit_filter(1280, 720)) # unknown source: old behaviour
+ src = (ROOT / "scripts" / "upscale_compare_pipersr.py").read_text()
+ self.assertEqual(src.count('fit_filter(target_w, target_h, int(info["width"]), int(info["height"]))'), 2)
+
+
+def _ffmpeg() -> str | None:
+ f = Path(str(P.FFMPEG))
+ return str(f) if f.is_file() else shutil.which("ffmpeg")
+
+
[email protected](_ffmpeg(), "ffmpeg not available")
+class TestRealPixelsHaveNoBlackColumns(unittest.TestCase):
+ def _edge_luma(self, path: Path, w: int, h: int) -> tuple[float, float, float, float]:
+ raw = subprocess.run([_ffmpeg(), "-v", "error", "-i", str(path), "-frames:v", "1",
+ "-vf", "format=gray", "-f", "rawvideo", "-"],
+ capture_output=True, timeout=60).stdout
+ self.assertEqual(len(raw), w * h)
+ col = lambda x: sum(raw[y * w + x] for y in range(h)) / h
+ row = lambda y: sum(raw[y * w:(y + 1) * w]) / w
+ return col(0), col(w - 1), row(0), row(h - 1)
+
+ def test_h3_draft_canvas_exports_edge_to_edge(self):
+ d = Path(tempfile.mkdtemp(prefix="phos-fill-ff-"))
+ try:
+ src = d / "draft.mp4"
+ # A flat mid-grey 640x384 clip stands in for an H3 Draft render.
+ subprocess.run([_ffmpeg(), "-v", "error", "-y", "-f", "lavfi", "-i",
+ "color=c=0x808080:s=640x384:d=0.5:r=24",
+ "-pix_fmt", "yuv420p", "-c:v", "libx264", str(src)],
+ check=True, timeout=60)
+ for mode, (tw, th) in (("fit_720p", (1280, 720)), ("fit_1080p", (1920, 1080))):
+ plan = P.compute_upscale_plan(640, 384, mode)
+ out = d / f"out_{mode}.mp4"
+ subprocess.run([_ffmpeg(), "-v", "error", "-y", "-i", str(src),
+ "-vf", plan["vf"], "-pix_fmt", "yuv420p",
+ "-c:v", "libx264", str(out)], check=True, timeout=60)
+ probe = subprocess.run([_ffmpeg().replace("ffmpeg", "ffprobe"), "-v", "error",
+ "-select_streams", "v:0", "-show_entries",
+ "stream=width,height", "-of", "csv=p=0", str(out)],
+ capture_output=True, text=True, timeout=30)
+ if probe.returncode == 0 and probe.stdout.strip():
+ self.assertEqual(probe.stdout.strip(), f"{tw},{th}")
+ for edge in self._edge_luma(out, tw, th):
+ self.assertGreater(edge, 100, f"{mode}: a black edge survived ({edge})")
+ finally:
+ shutil.rmtree(d, ignore_errors=True)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/webapp/docs/video.md b/webapp/docs/video.md
index 3922a73..f660c32 100644
--- a/webapp/docs/video.md
+++ b/webapp/docs/video.md
@@ -121,7 +121,7 @@ After the render, the clip can be resized without cropping.
**On Hailuo H3** (under Customize → **Upscale**):
- **Native** — as rendered.
-- **720p fit** / **1080p fit** — scaled and padded to fit. 720p fit is the default.
+- **720p fit** / **1080p fit** — scaled to fill the frame. A canvas close to 16:9 (H3 Draft and Standard, LTX Standard) loses a few pixels at the edges instead of getting black bars; one far from it (square, portrait into landscape) is still padded. 720p fit is the default.
Below the sizes, **Also run Upscale & Face Fix after the draft** is optional and off by default. When it is ticked, the draft ships as rendered and a second job re-renders it at twice the size with LTX-2.5, keeping the face and the sound; the fixed clip lands next to the draft. It needs the 0.3 GB Upscale adapter, downloaded from the Models window, and takes about the draft's time again.
**On LTX** (under Customize → **Export**): **Native** (default), **720p fit**, or **2×**. When it is not Native, **Method** chooses **Fast** (instant) or **Sharp** (a sharper upscaler, +30–90 s).
diff --git a/webapp/index.html b/webapp/index.html
index 5b1f802..6acb453 100644
--- a/webapp/index.html
+++ b/webapp/index.html
@@ -1531,9 +1531,10 @@
<!-- H3 export canvas. Most tiers render 12:7 (768×448), which is
neither 720p nor 1080p; this runs the SAME lanczos-fit + pad +
libx264 pass an LTX render gets, keeping the native file on
- disk but hidden from the gallery. Bars on 12:7 content are
- correct — no crop, no distortion — and the Wide tier
- (1024×576) is exactly 16:9, so it scales with no bars at all.
+ disk but hidden from the gallery. Since 4.16.1 near-16:9
+ content (12:7, 5:3) fills the frame with a small centre crop
+ instead of black bars (EXPORT_FILL_MAX_TRIM), and the High
+ tier (1024×576) is exactly 16:9, so it scales with neither.
Separate from the LTX Export control below so one pill never
means two things. -->
<div class="cz-control" id="h3ExportRow" data-h3-only>
@@ -1543,7 +1544,7 @@
key and the sidecar all stay `h3_upscale`; only the human
label changed. -->
<div class="cz-label">Upscale
- <span class="cz-label-hint">after the render · no crop</span>
+ <span class="cz-label-hint">after the render · no bars</span>
</div>
<div class="pill-group cols-3" id="h3UpscaleGroup">
<button type="button" class="pill-btn" data-h3-upscale="off"
@@ -1551,17 +1552,17 @@
<span>Native</span><span class="sub">as rendered</span>
</button>
<button type="button" class="pill-btn active" data-h3-upscale="fit_720p"
- title="Scale to 1280×720 — no crop, no distortion. A 16:9 tier scales clean; anything else is padded.">
- <span>720p fit</span><span class="sub">scale + pad</span>
+ title="Scale to 1280×720 — no bars, no distortion. A 16:9 tier scales clean; 12:7 and 5:3 fill the frame with a few pixels trimmed at the edges.">
+ <span>720p fit</span><span class="sub">scale to fill</span>
</button>
<button type="button" class="pill-btn" data-h3-upscale="fit_1080p"
- title="Scale to 1920×1080 — no crop, no distortion. A 16:9 tier scales clean; anything else is padded.">
- <span>1080p fit</span><span class="sub">scale + pad</span>
+ title="Scale to 1920×1080 — no bars, no distortion. A 16:9 tier scales clean; 12:7 and 5:3 fill the frame with a few pixels trimmed at the edges.">
+ <span>1080p fit</span><span class="sub">scale to fill</span>
</button>
</div>
<!-- What THIS tier + THIS export target will actually do: "pure
- 1.25× scale, no bars" or "12:7 fits to 1234×720 — 23 px bars
- left and right". The string is built server-side by
+ 1.25× scale, no bars" or "12:7 fills 1280×720 — 13 px trimmed
+ top and bottom, no bars". The string is built server-side by
_h3_export_notes() from compute_upscale_plan itself, so the
sentence can never disagree with the ffmpeg command that
runs. Sits UNDER the control it describes now, instead of
@@ -1580,16 +1581,16 @@
</label>
</div>
<!-- Export upscale — target dims after render. "720p fit"
- preserves aspect ratio (no crop, no distortion). 2× doubles
+ preserves aspect ratio (no distortion; a near-16:9 canvas fills the frame with a few px trimmed, 4.16.1). 2× doubles
each side. Native skips the upscale entirely. The "Method"
row below picks how the upscaling is done. -->
<div class="cz-control" data-ltx-only>
<div class="cz-label">Export
- <span class="cz-label-hint">post-render, no crop</span>
+ <span class="cz-label-hint">post-render, no bars</span>
</div>
<div class="pill-group cols-3" id="upscaleGroup">
<button type="button" class="pill-btn active" data-upscale="off"><span>Native</span><span class="sub">as generated</span></button>
- <button type="button" class="pill-btn" data-upscale="fit_720p"><span>720p fit</span><span class="sub">scale + pad</span></button>
+ <button type="button" class="pill-btn" data-upscale="fit_720p"><span>720p fit</span><span class="sub">scale to fill</span></button>
<button type="button" class="pill-btn" data-upscale="x2"><span>2×</span><span class="sub">same ratio</span></button>
</div>
</div>
diff --git a/webapp/js/queue.js b/webapp/js/queue.js
index 891e4a4..d897bc7 100644
--- a/webapp/js/queue.js
+++ b/webapp/js/queue.js
@@ -4499,7 +4499,11 @@ function renderOutputInfoBody(path, data) {
const up = data.upscale || {};
const target = up.target_w && up.target_h ? ` → ${up.target_w} × ${up.target_h}` : '';
const isSharp = p.upscale_method === 'pipersr' || p.upscale_method === 'model' || (data.upscale && (data.upscale.method === 'pipersr_coreml' || data.upscale.pre_pass === 'pipersr_x2' || data.upscale.method === 'ltx_latent_x2' || data.upscale.pre_pass === 'ltx_latent_x2'));
- const baseLabel = p.upscale === 'fit_720p' ? '720p fit (no crop)' : (p.upscale === 'x2' ? '2×' : p.upscale);
+ // What the export DID, from the sidecar's plan: since 4.16.1 a near-16:9
+ // source fills the canvas with a small trim, so "(no crop)" is only true
+ // for a pure scale or a padded one.
+ const fitHow = up.fill ? 'filled, edges trimmed' : (up.pad ? 'bars added' : 'no crop');
+ const baseLabel = p.upscale === 'fit_720p' ? `720p fit (${fitHow})` : (p.upscale === 'x2' ? '2×' : p.upscale);
const label = isSharp ? `${baseLabel} · Sharp (PiperSR)` : `${baseLabel} · Fast (Lanczos)`;
genRows.push(`<dt>Upscale</dt><dd>${escapeHtml(label + target)}</dd>`);
}
@@ -4509,7 +4513,8 @@ function renderOutputInfoBody(path, data) {
if (p.h3_upscale && p.h3_upscale !== 'off') {
const up = data.upscale || {};
const target = up.target_w && up.target_h ? ` → ${up.target_w} × ${up.target_h}` : '';
- const base = p.h3_upscale === 'fit_1080p' ? '1080p fit (no crop)' : '720p fit (no crop)';
+ const fitHow = up.fill ? 'filled, edges trimmed' : (up.pad ? 'bars added' : 'no crop');
+ const base = (p.h3_upscale === 'fit_1080p' ? '1080p fit' : '720p fit') + ` (${fitHow})`;
genRows.push(`<dt>Export</dt><dd>${escapeHtml(base + ' · Fast (Lanczos)' + target)}</dd>`);
}
// Chained windows — the honest shape of a 10 s / 15 s H3 clip.