You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Extract the edit-tool scaffold copied into ~36 tools #308
About 36 edit tools repeat the same scaffold: requireFfmpeg(), input-exists check (51 copies, 5 spellings), assertEditContainer, resolveOutput(... stamp()-rand() ...), runEditJob, okResponse/errorResponse. Copies have drifted (see the container-check regression filed separately).
Where
src/tools/trim.ts:46-77 and src/tools/crop.ts:112-138 (representative)
src/utils/media.ts:277-288 (assertEditContainer)
Impact
Every cross-cutting fix (#187 containers, #221 confinement, .partial cleanup) has to be applied N times; missed copies become latent bugs.
Suggested fix
Add utils/editTool.ts with requireInput(path, label?) and editOutput(args, tag, ext, { container }) bundling the container check, resolveOutput and naming
Migrate a few tools per commit
Optionally add runEditTool(handler) to absorb try/requireFfmpeg/errorResponse
Tests first: a table-driven tool-layer test calling every edit tool with a .webm output and a missing input.
41 tool modules now use them. Container behaviour is unchanged. Tools that write other formats or stream copies pass anyContainer: extract_audio, export_gif, transcribe, convert, chapters, the callout/redact stills, save_replay, screenshot, and the trim and concat copies.
editTool.test.ts tests both helpers. It also fails if any tool hand-writes the input check or builds a default edit name with resolveOutput(..., subdir("edits"), ...). The optional runEditTool wrapper is not included, because the handlers differ too much in what they return and clean up. The full suite passes (1115 tests).
Activity
TMHSDigital commentedon Nov 10, 2026
Fixed in 109197b.
src/utils/editTool.tsadds two helpers:requireInput(path, label?), which throws a single "not found" message.editOutput(output, tag, ext, { overwrite, dir, anyContainer }), which runs the Bug: edit tools fail on .webm input (libx264/AAC into WebM), and audio tools fail on audio-only outputs #187 container check and picks the default name.41 tool modules now use them. Container behaviour is unchanged. Tools that write other formats or stream copies pass
anyContainer: extract_audio, export_gif, transcribe, convert, chapters, the callout/redact stills, save_replay, screenshot, and the trim and concat copies.editTool.test.tstests both helpers. It also fails if any tool hand-writes the input check or builds a default edit name withresolveOutput(..., subdir("edits"), ...). The optionalrunEditToolwrapper is not included, because the handlers differ too much in what they return and clean up. The full suite passes (1115 tests).