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.

Add long clip temporal boost option

mrbizarrob91b5b4a170d
diff --git a/mlx_ltx_panel.py b/mlx_ltx_panel.py
index cfc2785..5b6de0b 100644
--- a/mlx_ltx_panel.py
+++ b/mlx_ltx_panel.py
@@ -2554,7 +2554,21 @@ def run_pipersr_tracked(source: Path, output: Path, mode: str, crf: str,
def video_duration(frames: int) -> float:
- return round(frames / FPS, 3)
+ # LTX 2.x uses frame counts shaped like 8k+1. The encoded file contains
+ # the intervals between those endpoints, so 121 means exactly 5.0s at
+ # 24fps, not 5.0417s.
+ return round(max(0.0, (max(1, int(frames)) - 1) / FPS), 3)
+
+
+def _frames_to_model_duration(frames: int, fps: float = FPS) -> float:
+ """LTX frame counts are 8k+1; the interval duration is (frames - 1) / fps."""
+ return max(0.0, (max(1, int(frames)) - 1) / float(fps))
+
+
+def _duration_to_8k_frames(duration_sec: float, fps: float) -> int:
+ """Nearest LTX-compatible frame count for a duration/fps pair."""
+ k = max(1, int(round(max(0.0, duration_sec) * float(fps) / 8.0)))
+ return k * 8 + 1
def stop_current_job(timeout: float = 5.0) -> None:
@@ -2614,6 +2628,9 @@ def make_job(form: dict[str, list[str]] | dict[str, str], *,
requested_upscale_method = "lanczos"
if requested_upscale_method not in ("lanczos", "pipersr"):
requested_upscale_method = "lanczos"
+ temporal_mode = f("temporal_mode", "native").strip().lower()
+ if temporal_mode not in ("native", "fps12_interp24"):
+ temporal_mode = "native"
return {
"id": _new_job_id(),
@@ -2649,6 +2666,7 @@ def make_job(form: dict[str, list[str]] | dict[str, str], *,
"label": f("preset_label", "") or None,
"quality": quality, # quick / balanced / standard / high
"accel": f("accel", "off"), # off / boost / turbo
+ "temporal_mode": temporal_mode, # native / fps12_interp24
"upscale": upscale, # off / fit_720p / x2
"upscale_method": requested_upscale_method, # lanczos / pipersr
# LoRAs the user has enabled for this job. The UI submits a
@@ -2907,6 +2925,33 @@ def run_job_inner(job: dict) -> None:
width, height = p["width"], p["height"]
frames = p["frames"]
quality = p.get("quality", "standard")
+ temporal_mode = (p.get("temporal_mode") or "native").strip().lower()
+ if temporal_mode not in ("native", "fps12_interp24"):
+ temporal_mode = "native"
+ temporal_supported = mode in ("t2v", "i2v") and quality != "high"
+ if temporal_mode != "native" and not temporal_supported:
+ push("Long Clip Boost is only available for Q4 Text/Image renders; using native 24fps.")
+ temporal_mode = "native"
+ p["temporal_mode"] = temporal_mode
+
+ delivery_fps = float(FPS)
+ model_fps = delivery_fps
+ model_frames = frames
+ temporal_plan = None
+ if temporal_mode == "fps12_interp24":
+ model_fps = 12.0
+ requested_duration = _frames_to_model_duration(frames, delivery_fps)
+ model_frames = _duration_to_8k_frames(requested_duration, model_fps)
+ temporal_plan = {
+ "mode": "fps12_interp24",
+ "label": "12 → 24 fps",
+ "model_fps": model_fps,
+ "delivery_fps": delivery_fps,
+ "source_frames": model_frames,
+ "delivery_frames": frames,
+ "requested_duration_sec": round(requested_duration, 3),
+ "method": "ffmpeg_minterpolate_mci",
+ }
# T2V/I2V resolution clamp — only applies on the base tier (< 48 GB).
# Standard / high / pro tiers pass full user-requested W×H through.
@@ -2934,6 +2979,9 @@ def run_job_inner(job: dict) -> None:
if needs_mux:
raw_out = OUTPUT / f"mlx_{tag}_{width}x{height}_{frames}f_{stamp}_raw.mp4"
final_out = OUTPUT / f"mlx_{tag}_{suffix}_{frames}f_{stamp}.mp4"
+ elif temporal_plan:
+ raw_out = OUTPUT / f"mlx_{tag}_{width}x{height}_{model_frames}f_12fps_{stamp}.mp4"
+ final_out = OUTPUT / f"mlx_{tag}_{width}x{height}_{frames}f_12to24_{stamp}.mp4"
else:
# Single file — name it as the final, no `_raw` suffix.
raw_out = OUTPUT / f"mlx_{tag}_{width}x{height}_{frames}f_{stamp}.mp4"
@@ -3009,7 +3057,8 @@ def run_job_inner(job: dict) -> None:
"output_path": str(raw_out),
"height": height,
"width": width,
- "frames": frames,
+ "frames": model_frames,
+ "frame_rate": model_fps,
"steps": p["steps"],
"seed": p["seed"],
"image": p["image"] if mode != "t2v" else None,
@@ -3022,14 +3071,20 @@ def run_job_inner(job: dict) -> None:
"upscale_method": "lanczos",
},
}
+ temporal_suffix = ""
+ if temporal_plan:
+ temporal_suffix = (
+ f" · Long Clip Boost {model_frames}f@{model_fps:g}fps"
+ f" → {frames}f@{delivery_fps:g}fps"
+ )
if loras:
push(f"Run via helper: id={job['id']} mode={mode} quality={quality} accel={p.get('accel', 'off')} "
- f"{width}x{height} {frames}f · {len(loras)} LoRA"
+ f"{width}x{height} {model_frames}f · {len(loras)} LoRA"
f"{'s' if len(loras) != 1 else ''}"
- f"{' (incl. HDR)' if p.get('hdr') else ''}")
+ f"{' (incl. HDR)' if p.get('hdr') else ''}{temporal_suffix}")
else:
push(f"Run via helper: id={job['id']} mode={mode} quality={quality} accel={p.get('accel', 'off')} "
- f"{width}x{height} {frames}f")
+ f"{width}x{height} {model_frames}f{temporal_suffix}")
result = HELPER.run(job_spec)
if "seed_used" in result:
@@ -3064,6 +3119,35 @@ def run_job_inner(job: dict) -> None:
run_ffmpeg_tracked(mux_cmd, "Mux")
final_target = final_out
+ if temporal_plan:
+ codec = output_codec_settings()
+ mux_pix_fmt = codec["pix_fmt"]
+ mux_crf = codec["crf"]
+ temporal_preset = os.environ.get("LTX_TEMPORAL_PRESET", "medium")
+ temporal_cmd = [
+ str(FFMPEG), "-y", "-i", str(final_target),
+ "-vf", f"minterpolate=fps={FPS}:mi_mode=mci:mc_mode=aobmc:vsbmc=1",
+ "-c:v", "libx264", "-pix_fmt", mux_pix_fmt, "-crf", mux_crf,
+ "-preset", temporal_preset,
+ "-movflags", "+faststart",
+ "-c:a", "copy",
+ "-t", f"{video_duration(frames)}",
+ str(final_out),
+ ]
+ run_ffmpeg_tracked(temporal_cmd, "Long Clip Boost")
+ temporal_plan |= {
+ "source": str(final_target),
+ "output": str(final_out),
+ "codec": output_codec_settings(),
+ "encode_preset": temporal_preset,
+ }
+ set_hidden(str(final_target), True)
+ push(
+ f"Long Clip Boost done → {final_out.name} "
+ f"({model_frames}f @ {model_fps:g}fps interpolated to {frames}f @ {FPS}fps)"
+ )
+ final_target = final_out
+
native_target = final_target
helper_did_model_upscale = (result.get("upscale_applied") == "model_x2")
if helper_did_model_upscale:
@@ -3119,6 +3203,9 @@ def run_job_inner(job: dict) -> None:
"params": {
**p,
"pad_w": pad_w, "pad_h": pad_h,
+ "model_frames": model_frames if temporal_plan else frames,
+ "model_fps": model_fps if temporal_plan else FPS,
+ "delivery_fps": delivery_fps if temporal_plan else FPS,
"image": p["image"] if mode != "t2v" else None,
"audio": p["audio"] if mode == "i2v_clean_audio" else None,
},
@@ -3132,6 +3219,8 @@ def run_job_inner(job: dict) -> None:
}
if result.get("accel_metrics"):
sidecar["accel_metrics"] = result["accel_metrics"]
+ if temporal_plan:
+ sidecar["temporal"] = temporal_plan
if upscale_plan:
sidecar["upscale"] = {
k: v for k, v in upscale_plan.items()
@@ -5901,6 +5990,7 @@ HTML = r"""<!doctype html>
</div>
<input type="hidden" name="quality" id="quality" value="balanced">
<input type="hidden" name="accel" id="accel" value="off">
+ <input type="hidden" name="temporal_mode" id="temporal_mode" value="native">
<input type="hidden" name="upscale" id="upscale" value="fit_720p">
<div id="warnBanner" class="warn-banner"></div>
@@ -6185,6 +6275,20 @@ HTML = r"""<!doctype html>
</div>
</div>
+ <!-- Long Clip Boost — asks LTX 2.3 to generate fewer semantic
+ frames at 12fps, then exports a normal 24fps file with
+ motion interpolation. This is explicit because dialogue,
+ lip-sync, and fast motion need user judgment. -->
+ <div class="cz-control" id="temporalRow">
+ <div class="cz-label">Long clips
+ <span class="cz-label-hint">experimental temporal interpolation</span>
+ </div>
+ <div class="pill-group cols-2" id="temporalGroup">
+ <button type="button" class="pill-btn active" data-temporal="native"><span>Native</span><span class="sub">24fps from LTX</span></button>
+ <button type="button" class="pill-btn" data-temporal="fps12_interp24"><span>12 → 24fps</span><span class="sub">half frames · interpolated</span></button>
+ </div>
+ </div>
+
<!-- Export upscale — target dims after render. "720p fit"
preserves aspect ratio (no crop, no distortion). 2× doubles
each side. Native skips the upscale entirely. The "Method"
@@ -6646,6 +6750,7 @@ function setMode(mode) {
setQuality('high');
}
updateAccelAvailability();
+ updateTemporalAvailability();
updateDerived();
// Refresh the inline models card immediately — switching to FFLF when
// Q8 is missing should surface the Download Q8 CTA without waiting for
@@ -6684,6 +6789,7 @@ function setQuality(q) {
if (aspectRow) aspectRow.style.display = (q === 'quick') ? 'none' : '';
applyQuality();
updateAccelAvailability();
+ updateTemporalAvailability();
updateCustomizeSummary();
if (LAST_STATUS) updateModelsCard(LAST_STATUS);
}
@@ -6695,6 +6801,19 @@ function setAccel(a) {
updateCustomizeSummary();
updateDerived();
}
+function temporalModeAllowed() {
+ const q = document.getElementById('quality').value;
+ const mode = document.getElementById('mode').value;
+ return q !== 'high' && currentMode !== 'extend' && currentMode !== 'keyframe' && (mode === 't2v' || mode === 'i2v');
+}
+function setTemporalMode(t) {
+ const allowed = temporalModeAllowed();
+ const v = (allowed && t === 'fps12_interp24') ? 'fps12_interp24' : 'native';
+ document.getElementById('temporal_mode').value = v;
+ document.querySelectorAll('#temporalGroup .pill-btn').forEach(b => b.classList.toggle('active', b.dataset.temporal === v));
+ updateCustomizeSummary();
+ updateDerived();
+}
function setUpscale(u) {
const v = ['off', 'fit_720p', 'x2'].includes(u) ? u : 'off';
document.getElementById('upscale').value = v;
@@ -6724,6 +6843,19 @@ function updateAccelAvailability() {
});
if (!allowed && document.getElementById('accel').value !== 'off') setAccel('off');
}
+function updateTemporalAvailability() {
+ const allowed = temporalModeAllowed();
+ document.querySelectorAll('#temporalGroup .pill-btn').forEach(b => {
+ const disabled = !allowed && b.dataset.temporal !== 'native';
+ b.classList.toggle('disabled', disabled);
+ if (b.dataset.temporal === 'fps12_interp24') {
+ b.title = allowed
+ ? 'Generate at 12fps, then interpolate to a normal 24fps export.'
+ : 'Available for Q4 Text/Image renders. Off for High, FFLF, Extend, and external-audio I2V.';
+ }
+ });
+ if (!allowed && document.getElementById('temporal_mode').value !== 'native') setTemporalMode('native');
+}
function setAspect(a) {
if (!ASPECTS[a]) return;
document.getElementById('aspect').value = a;
@@ -6756,6 +6888,9 @@ function updateCustomizeSummary() {
}
// Speed
parts.push(accel === 'off' ? 'exact speed' : (accel === 'boost' ? 'boost' : 'turbo'));
+ if ((document.getElementById('temporal_mode')?.value || 'native') === 'fps12_interp24') {
+ parts.push('12→24fps long clip');
+ }
const method = (document.getElementById('upscale_method')?.value || 'lanczos');
const methodTag = method === 'pipersr' || method === 'model' ? ' sharp' : '';
if (upscale === 'fit_720p') parts.push('720p export' + methodTag);
@@ -6777,6 +6912,7 @@ function setExtendMode(m) {
document.querySelectorAll('#modeGroup .pill-btn').forEach(b => b.onclick = () => setMode(b.dataset.mode));
document.querySelectorAll('#qualityGroup .pill-btn').forEach(b => b.onclick = () => { if (!b.classList.contains('disabled')) setQuality(b.dataset.quality); });
document.querySelectorAll('#accelGroup .pill-btn').forEach(b => b.onclick = () => { if (!b.classList.contains('disabled')) setAccel(b.dataset.accel); });
+document.querySelectorAll('#temporalGroup .pill-btn').forEach(b => b.onclick = () => { if (!b.classList.contains('disabled')) setTemporalMode(b.dataset.temporal); });
document.querySelectorAll('#upscaleGroup .pill-btn').forEach(b => b.onclick = () => { if (!b.classList.contains('disabled')) setUpscale(b.dataset.upscale); });
document.querySelectorAll('#upscaleMethodGroup .pill-btn').forEach(b => b.onclick = () => { if (!b.classList.contains('disabled')) setUpscaleMethod(b.dataset.method); });
document.querySelectorAll('#aspectGroup .pill-btn').forEach(b => b.onclick = () => setAspect(b.dataset.aspect));
@@ -6838,6 +6974,9 @@ syncExtendDuration(); // initialize on load
document.getElementById('i2vMode').addEventListener('change', () => {
document.getElementById('audioSection').classList.toggle('show', document.getElementById('i2vMode').value === 'i2v_clean_audio');
if (currentMode === 'i2v') document.getElementById('mode').value = document.getElementById('i2vMode').value;
+ updateTemporalAvailability();
+ updateCustomizeSummary();
+ updateDerived();
});
function applyAspect(key) {
@@ -6903,7 +7042,7 @@ function updateDerived() {
const w = parseInt(document.getElementById('width').value || 0);
const h = parseInt(document.getElementById('height').value || 0);
const f = parseInt(document.getElementById('frames').value || 0);
- const dur = (f / FPS).toFixed(2);
+ const dur = framesToDuration(f);
const upscale = document.getElementById('upscale')?.value || 'off';
let finalRes = `<strong>${w}×${h}</strong>`;
@@ -6922,8 +7061,15 @@ function updateDerived() {
}
const accel = document.getElementById('accel')?.value || 'off';
const accelText = accel === 'off' ? '' : ` · ${accel === 'turbo' ? 'Turbo' : 'Boost'}`;
+ const temporal = document.getElementById('temporal_mode')?.value || 'native';
+ let temporalText = '';
+ if (temporal === 'fps12_interp24') {
+ const intervalSec = Math.max(0, (f - 1) / FPS);
+ const sourceFrames = Math.max(1, Math.round(intervalSec * 12 / 8)) * 8 + 1;
+ temporalText = ` · LTX ${sourceFrames}f @ 12fps → ${FPS}fps`;
+ }
- document.getElementById('derived').innerHTML = `Duration <strong>${dur}s</strong> @ ${FPS}fps · ${finalRes} · Steps ${document.getElementById('steps').value}${accelText}`;
+ document.getElementById('derived').innerHTML = `Duration <strong>${dur}s</strong> @ ${FPS}fps${temporalText} · ${finalRes} · Steps ${document.getElementById('steps').value}${accelText}`;
const warns = [];
if (w % 32 !== 0) warns.push(`Width ${w} isn't a multiple of 32 (closest ${Math.round(w/32)*32})`);
@@ -6932,6 +7078,9 @@ function updateDerived() {
const closest = Math.max(1, Math.round((f - 1) / 8) * 8 + 1);
warns.push(`Frames work best as 8k+1 (closest ${closest})`);
}
+ if (temporal === 'fps12_interp24') {
+ warns.push('12→24fps is experimental; check dialogue lip-sync and fast motion');
+ }
const banner = document.getElementById('warnBanner');
if (warns.length) { banner.innerHTML = '⚠ ' + warns.join(' · '); banner.classList.add('show'); }
else banner.classList.remove('show');
@@ -7579,6 +7728,7 @@ async function loadParams() {
if (p.width) document.getElementById('width').value = p.width;
if (p.height) document.getElementById('height').value = p.height;
if (p.accel) setAccel(p.accel);
+ if (p.temporal_mode) setTemporalMode(p.temporal_mode);
if (p.upscale) setUpscale(p.upscale);
if (p.upscale_method) setUpscaleMethod(p.upscale_method);
document.getElementById('prompt').value = p.prompt || '';
@@ -7734,6 +7884,14 @@ function renderOutputInfoBody(path, data) {
const savingsText = savings != null ? ` · ~${escapeHtml(String(savings))}% denoise calls saved` : '';
genRows.push(`<dt>Accel metrics</dt><dd>${cachedCount}/${totalSteps} cached${savingsText}${cachedList}</dd>`);
}
+ if (p.temporal_mode === 'fps12_interp24' || data.temporal) {
+ const t = data.temporal || {};
+ const sourceFrames = t.source_frames || p.model_frames || '—';
+ const deliveryFrames = t.delivery_frames || p.frames || '—';
+ const sourceFps = t.model_fps || p.model_fps || 12;
+ const deliveryFps = t.delivery_fps || p.delivery_fps || 24;
+ genRows.push(`<dt>Long clips</dt><dd>12 → 24fps · LTX ${escapeHtml(String(sourceFrames))}f @ ${escapeHtml(String(sourceFps))}fps → ${escapeHtml(String(deliveryFrames))}f @ ${escapeHtml(String(deliveryFps))}fps</dd>`);
+ }
if (p.upscale && p.upscale !== 'off') {
const up = data.upscale || {};
const target = up.target_w && up.target_h ? ` → ${up.target_w} × ${up.target_h}` : '';
diff --git a/mlx_warm_helper.py b/mlx_warm_helper.py
index f7a598b..505aacd 100644
--- a/mlx_warm_helper.py
+++ b/mlx_warm_helper.py
@@ -578,6 +578,7 @@ def _generate_latents(pipe, *, needs_image: bool, kwargs: dict):
num_frames=kwargs["num_frames"],
seed=kwargs["seed"],
num_steps=kwargs["num_steps"],
+ frame_rate=kwargs.get("frame_rate", 24.0),
)
return pipe.generate(
prompt=kwargs["prompt"],
@@ -586,6 +587,7 @@ def _generate_latents(pipe, *, needs_image: bool, kwargs: dict):
num_frames=kwargs["num_frames"],
seed=kwargs["seed"],
num_steps=kwargs["num_steps"],
+ frame_rate=kwargs.get("frame_rate", 24.0),
)
@@ -1026,6 +1028,7 @@ for line in sys.__stdin__:
num_frames=int(p["frames"]),
seed=seed,
num_steps=int(p.get("steps", 8)),
+ frame_rate=float(p.get("frame_rate", 24.0)),
)
# Y1.037: short-clip VAE-streaming opt-out. Set the env var BEFORE
# generate() so it propagates through the whole chain (the patched
@@ -1072,7 +1075,7 @@ for line in sys.__stdin__:
emit({"event": "log", "line": "Sharper upscale requested but model weights missing — falling back to Lanczos."})
if use_model_upscale:
- emit({"event": "log", "line": f"step:generate mode={mode} {kwargs['width']}x{kwargs['height']} {kwargs['num_frames']}f steps={kwargs['num_steps']} accel={accel_mode} upscale=model"})
+ emit({"event": "log", "line": f"step:generate mode={mode} {kwargs['width']}x{kwargs['height']} {kwargs['num_frames']}f @{kwargs['frame_rate']:.1f}fps steps={kwargs['num_steps']} accel={accel_mode} upscale=model"})
# Step 1: generate latents (no save)
video_latent, audio_latent = _generate_latents(pipe, needs_image=needs_image, kwargs=kwargs)
emit({"event": "log", "line": "step:generate done"})
@@ -1087,17 +1090,17 @@ for line in sys.__stdin__:
# Free the upscaler before VAE decode (can be ~2-3 GB peak).
_free_upscaler()
# Step 3: VAE decode + save (decoder loads inside _decode_and_save_video).
- out_path = pipe._decode_and_save_video(video_latent, audio_latent, kwargs["output_path"])
+ out_path = pipe._decode_and_save_video(video_latent, audio_latent, kwargs["output_path"], fps=kwargs["frame_rate"])
emit({"event": "log", "line": "step:decode_and_save done"})
else:
- emit({"event": "log", "line": f"step:generate mode={mode} {kwargs['width']}x{kwargs['height']} {kwargs['num_frames']}f steps={kwargs['num_steps']} accel={accel_mode}"})
+ emit({"event": "log", "line": f"step:generate mode={mode} {kwargs['width']}x{kwargs['height']} {kwargs['num_frames']}f @{kwargs['frame_rate']:.1f}fps steps={kwargs['num_steps']} accel={accel_mode}"})
video_latent, audio_latent = _generate_latents(pipe, needs_image=needs_image, kwargs=kwargs)
emit({"event": "log", "line": "step:generate done"})
emit({"event": "log", "line": "step:free_generation_modules start"})
_free_pipe_for_decode(pipe)
emit({"event": "log", "line": "step:free_generation_modules done"})
emit({"event": "log", "line": "step:decode_and_save start"})
- out_path = pipe._decode_and_save_video(video_latent, audio_latent, kwargs["output_path"])
+ out_path = pipe._decode_and_save_video(video_latent, audio_latent, kwargs["output_path"], fps=kwargs["frame_rate"])
emit({"event": "log", "line": "step:decode_and_save done"})
elapsed = round(time.time() - t0, 2)
_last_activity = time.time()
diff --git a/patch_ltx_codec.py b/patch_ltx_codec.py
index 10851b5..2a27482 100644
--- a/patch_ltx_codec.py
+++ b/patch_ltx_codec.py
@@ -18,6 +18,11 @@ Upstream issues we patch around:
temporal tiled_decode() automatically for longer clips, with
LTX_VAE_STREAMING=0/1 override.
+4. TextToVideoPipeline / ImageToVideoPipeline have fps-aware position helpers
+ in ltx-core-mlx, but the one-stage pipeline hardcodes 24fps at the call
+ site. Patched to expose frame_rate so Phosphene can offer an explicit
+ "12 → 24fps" long-clip mode without desynchronizing generated audio.
+
Known unfixed: KeyframeInterpolationPipeline OOMs at the stage-1 → stage-2
transition on 64 GB Macs at full resolution. We tried freeing/reloading
the DiT around the upscale and it didn't help. Worked around in the panel
@@ -374,6 +379,90 @@ def apply_patch(target: Path, old: str, new: str, marker: str, label: str,
return OUTCOME_APPLIED
+def apply_one_stage_fps_patch(target: Path | None) -> str:
+ """Expose frame_rate on the one-stage T2V/I2V pipeline.
+
+ This is a multi-anchor patch because older installs may already have our
+ I2V memory patches applied, which changes the exact generate_and_save()
+ body. Keep it narrow and verify the final required markers instead of
+ replacing one large fragile block.
+ """
+ label = "one-stage frame_rate (12→24fps long clips)"
+ if target is None or not target.exists():
+ print(f" [{label}] MISSING — target file not found", file=sys.stderr)
+ return OUTCOME_MISSING
+ text = target.read_text()
+ required = (
+ "frame_rate: float = 24.0",
+ "compute_audio_token_count(num_frames, fps=frame_rate)",
+ "compute_video_positions(F, H, W, fps=frame_rate)",
+ "fps=frame_rate",
+ )
+ if all(marker in text for marker in required):
+ print(f" [{label}] already patched: {target}")
+ return OUTCOME_ALREADY
+
+ original = text
+ replacements = [
+ (
+ " num_steps: int | None = None,\n"
+ " ) -> tuple[mx.array, mx.array]:",
+ " num_steps: int | None = None,\n"
+ " frame_rate: float = 24.0,\n"
+ " ) -> tuple[mx.array, mx.array]:",
+ ),
+ (
+ " num_steps: int | None = None,\n"
+ " ) -> str:",
+ " num_steps: int | None = None,\n"
+ " frame_rate: float = 24.0,\n"
+ " ) -> str:",
+ ),
+ (
+ " audio_T = compute_audio_token_count(num_frames)",
+ " audio_T = compute_audio_token_count(num_frames, fps=frame_rate)",
+ ),
+ (
+ " video_positions = compute_video_positions(F, H, W)",
+ " video_positions = compute_video_positions(F, H, W, fps=frame_rate)",
+ ),
+ (
+ " num_steps=num_steps,\n"
+ " )",
+ " num_steps=num_steps,\n"
+ " frame_rate=frame_rate,\n"
+ " )",
+ ),
+ (
+ "return super().generate_and_save(prompt, output_path, height, width, num_frames, seed, num_steps)",
+ "return super().generate_and_save(prompt, output_path, height, width, num_frames, seed, num_steps, frame_rate)",
+ ),
+ (
+ "return self._decode_and_save_video(video_latent, audio_latent, output_path)",
+ "return self._decode_and_save_video(video_latent, audio_latent, output_path, fps=frame_rate)",
+ ),
+ ]
+ for old, new in replacements:
+ text = text.replace(old, new)
+
+ if text == original:
+ print(
+ f" [{label}] DRIFT — no fps anchors matched in {target}.",
+ file=sys.stderr,
+ )
+ return OUTCOME_DRIFT
+ if not all(marker in text for marker in required):
+ missing = [marker for marker in required if marker not in text]
+ print(
+ f" [{label}] DRIFT — patch incomplete in {target}; missing {missing}",
+ file=sys.stderr,
+ )
+ return OUTCOME_DRIFT
+ _atomic_write(target, text)
+ print(f" [{label}] patched {target}")
+ return OUTCOME_APPLIED
+
+
def main() -> int:
print("Applying LTX23MLX patches:")
outcomes: list[tuple[str, str]] = []
@@ -468,6 +557,13 @@ def main() -> int:
)
outcomes.append(("VAE temporal streaming decode", vae_stream_outcome))
+ # Patch 6: expose frame_rate in the one-stage T2V/I2V path. This is the
+ # shippable hook for the panel's explicit Long Clip Boost mode: generate
+ # fewer semantic frames at 12fps, keep LTX audio duration aligned, then
+ # interpolate the delivered export back to 24fps.
+ fps_outcome = apply_one_stage_fps_patch(i2v_target)
+ outcomes.append(("one-stage frame_rate (12→24fps long clips)", fps_outcome))
+
# (Keyframe OOM patch was removed — see NOTE in the patches block above.
# The fix is currently a panel-side resolution clamp, not a pipeline edit.)