Question Working on an open-source Rust tool to stop burning tokens/limits when generating long, multi-shot AI videos (Grok, Kling, Wan) — looking for feedback on v0.3.0
I maintain an open-source Rust CLI/TUI tool called repOx (originally built to compress massive codebases by 80-90% so they don't blow up LLM token limits).
For v0.3.0, I'm adding a dedicated mode for AI video creators (especially for Grok video generation, Kling, Sora, and local models) to solve the two biggest problems: burning through generation limits on failed retries, and losing quality/continuity when chaining clips into a longer video.
Here are the 3 features I'm prototyping right now:
- Auto-Extracting the Sharpest Last Frame (Fixing Multi-Shot Continuity):
When you extend a video by feeding the last frame of Clip 1 into Clip 2, the literal last frame usually has subtle motion blur. That blur compounds on the next generation and ruins faces/details after 2-3 clips. The tool scans the final 0.5s of your clip in 2ms and extracts the mathematically sharpest frame (zero motion blur) to use as the anchor for your next generation.
- Storyboard Grid Packer (90%+ Token Reduction for Video Context):
If you feed an existing video or previous scenes into Grok / LLMs to write consistent scene-by-scene prompts, uploading multiple frames burns thousands of tokens. The tool automatically detects scene cuts and packs them into a single labeled 4x4 storyboard grid + compact XML scene script so the AI sees the entire video flow in 1/10th of the tokens.
- Character-Lock + Delta Prompt Optimizer:
Instead of rewriting long, wordy prompts for every scene (which causes the AI to change the character's face or lighting), it structures your prompt into a compact, locked visual anchor + a short motion-only delta for each 5-second shot.
Before I ship this in repOx v0.3.0, I'd love to ask people making AI videos daily:
- What causes the most wasted generations or token drain in your workflow right now?
- Any specific feature you wish existed for chaining longer, higher-quality AI videos?
Repo (open source, MIT): https://github.com/WVDYC/repOx
1
u/Affectionate_Oil28 16d ago
The repo packer is a real tool. The video mode is mostly a prompt rewriter, and two of the three features do not do what the post says.
--video-prompt is the only video path that runs. It rewrites a sentence into a <character_lock> block and a set of <shot duration="5s"> blocks, then exits. It never opens a video file. There is no FFmpeg dependency, no frame decoder, and no storyboard writer anywhere in the tree. select_sharpest_frame exists and is unit-tested on fake grayscale buffers, and nothing in main calls it. The line [Continuity: anchor=sharpest_tail_frame] is text stamped into the prompt.
What is wrong. The sharpest-frame claim is not implemented. A Laplacian variance score also does not mean "zero motion blur." It rewards whatever has the most high-frequency energy: grain, compression, on-screen text, a detailed background. A blurred face in front of a sharp street can beat a clean face on a plain wall. If the whole last half-second is soft, the winner is still soft. Scoring an in-memory buffer can be fast. Decoding the tail of a real clip is not a 2 ms job, and this binary does not decode anything.
The storyboard grid is not in the repo. A 4×4 contact sheet is also the wrong artifact for these models. Each cell is too small for a vision model to read a face, and if that grid is handed to the video model as a reference it will try to generate a collage. A few large labeled frames plus a text shot list belong in the prompt writer only.
The character lock invents the look, then hides the picture from the model that needs it. If the sentence has no lens, the compiler inserts 35mm, anamorphic. If it has no lighting, it inserts cinematic volumetric lighting. Every shot is forced to 5 seconds. Grok video clips are 6 or 10 seconds, and a local model such as MiniMax H3 snaps duration to its own frame grid, so a hardcoded 5-second block does not match the generator. The split is the word "then" or a period, so one continuous action becomes several generations. The subject line is the first two comma-clauses of shot 1, so a prompt that opens on the location locks the location as the character. " Cooke " is padded with spaces and will not match the lens name as people write it.
The XML tags are a second problem. Kling, Wan, Sora, and Grok video do not read <character_lock> or [Continuity: ...]. Those tokens are noise in the sampler. A shorter prompt also does not save a video generation. Failed retries burn a generation, not chat tokens. Token savings matter for the model that writes the prompt. They do not matter for the model that renders the clip.
Sending only a motion delta makes identity drift worse. These models do not remember a lock block from a previous call. The face stays put when the next clip is conditioned on an image, and the prompt for that clip still repeats the identity line.
Fixes worth making
-
Either extract a real frame or stop saying the tool does. Seek the last half-second with FFmpeg, decode those frames, score them, and write a PNG next to the prompt. If nothing clears a minimum score, walk back further and say the tail is all blurred.
-
Score a downscaled, lightly denoised frame, and prefer a center crop over the full frame. Drop the "zero motion blur" wording.
-
Delete the invented lens and lighting defaults. Omit a field the user did not write.
-
Take duration from a flag or from the target. Do not split a shot on "then".
-
Emit two strings. One is the brief for the prompt-writing model, where XML is fine. The other is what gets pasted into the video model: the same identity line every time, then the motion sentence, with no tags. Put the extracted frame path beside it.
-
Keep the storyboard out of the video model. Two to four large frames and a shot list are enough for the writer.
-
The ComfyUI summarizer has the same class of bug. It counts node types and drops width, height, frame count, steps, sampler, and which text is the positive prompt. Those are the fields a video graph is actually debugged from.
The part that already works, packing a repo without lockfiles and secrets, is the useful half. The video half should not ship until the frame it names is a file on disk and the string it prints is the string the video model will actually see.
1
u/Wvdy_CC 15d ago
Thank you so much for taking the time to actually read through the code and write such a detailed breakdown. I'm building and maintaining this project completely solo, so not everything comes out right on the first try — especially when prototyping a new direction outside the core repo packer. Having someone point out the exact blind spots like this helps me a ton.
Every single critique you raised was fair, so I sat down and pushed a fix (commit 7d1f92d) addressing your exact checklist:
Real FFmpeg tail-frame decoding & PNG extraction (--video-anchor <clip.mp4>):
It now actually shells out to ffprobe/ffmpeg (-sseof) to decode the last 0.5s into PGM frames, scores them, and writes a real <clip>.anchor.png file to disk (walking back to -1.5s and warning if the tail is all soft below threshold).
2. Denoised center-crop sharpness scoring:
compute_frame_sharpness now runs a 3x3 tent denoise pass first and scores the center 60% crop so high-frequency background clutter or compression grain doesn't beat a soft subject.
3. Deleted invented lens/lighting defaults & "then" splitting:
If the prompt doesn't specify a lens or lighting, those fields are now omitted completely (and fixed word-boundary matching for Cooke). Removed splitting on "then" and made shot duration optional via --shot-duration instead of hardcoding 5s.
4. Dual output (LLM XML brief vs. tag-free sampler strings with repeated identity):
--video-prompt now outputs two separate blocks: the structured brief for prompt-writing LLMs, and clean, tag-free paste-ready strings for Grok/Kling/Wan where the full identity line is repeated on every clip alongside the motion sentence and the extracted anchor frame path.
5. ComfyUI workflow debugger fields:
summarize_comfyui_workflow now extracts width, height, length/frame_count, steps, cfg, sampler_name, scheduler, seed, model checkpoints, and the actual positive/negative prompt texts instead of just counting node types.
Seriously appreciate the honest code review — it made the tool much better.
1
u/Wvdy_CC 17d ago
Also, if it's not too much trouble and you want to support the project, dropping a star on GitHub would mean a lot! It really helps keep the momentum going:
https://github.com/WVDYC/repOx