Repository navigation
Add Stash Video Editor plugin - #822
Open
speckofthecosmos wants to merge 2 commits into
Open
speckofthecosmos wants to merge 2 commits into
speckofthecosmos wants to merge 2 commits into
Conversation
Crop, stretch or trim a scene's video from the scene page; crop and stretch image clips from the image page. The edit becomes the primary file and the original is kept. An optional encode hook hands the re-encodes to another program, with a local encode as the fallback. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I was jumping through lots of hoops to edit videos in my library and thought it should be doable right through the interface. Here’s the result. You can crop and trim videos. It lets you remove black bars and cut out title screens for example. Keeps the old version as a second file on the same listing (like a merge). Has the option to use remote encoding for faster processing. Details below.
Claude Fable 5.2 (medium) and Claude Opus 5.5 (encode hook)
Adds
plugins/StashVideoEditor: crop, stretch or trim a scene's video from the scene page, and crop or stretch image clips from the image page. The backend is Python (standard library only) and runs ffmpeg with Stash's own transcode settings.Behavior (what this adds for users)
.vclip). The cropped file replaces the clip in place and the original is kept beside it as<name>.sve-bak. Cropping again leaves that backup as the first original.How the swap works
Stash's job queue is serial, so a task cannot wait for a scan it queued. The work is split in two:
sve-pending.jsonin the plugin folder, encodes to<name>.edited.<ext>(or.edited-2,.edited-3when the name is taken), queues a scan of that file, and exits.Scene.Create.Posthook merges it into the source scene withsceneMerge, sets the edited file as primary withsceneUpdate, moves the markers after a trim, removes the record, and queuesmetadataGeneratewith overwrite.The hook acts only on recorded paths, so a file a user named
something.edited.mp4is left alone. With no records the hook makes no GraphQL calls. A Merge edited scenes task finishes any recorded edit the hook did not, and does nothing when run again.Images have no
imageAssignFileorimageMerge, so the image-clip crop encodes to a sibling file, moves the original to.sve-bak, moves the edit onto the clip's path (rolling back if that fails), then queues a scan and a generate.Encode hook (optional)
A setting, Encode hook (executable path), hands the re-encodes to another program, for example to use another machine's GPU or a cloud encoder. Blank, the default, means Stash's ffmpeg does them, as before.
.sve-partialname a local encode uses (the job names its muxer), so a scan never sees a half-written file, even when the task is cancelled while the hook runs. Exit 0 means the hook wrote it. The plugin checks that the file exists and is not empty, moves it into place and carries on as after a local encode.exec_command); Tdarr and Jellyfin's rffmpeg replace the ffmpeg binary instead. None defines a job format a Stash plugin could reuse, so the names here follow the plugin's own (src,dst).Implementation notes (open to revision)
ffmpegPath,transcodeInputArgsandtranscodeOutputArgsfrom Stash's configuration. With no output arguments set it useslibx264 -crf 18 -preset slow..mp4,.m4v,.movor.mkvsource keeps its container and its audio is copied. Any other source is written as.mp4with AAC audio.*.sve-partial, which Stash does not scan, and renamed when ffmpeg succeeds.<base href>.cropMath.jsadapts coordinate helpers from react-easy-crop (MIT). The licence notice is in the file.StashVideoEditor; happy to rename to the repository's preferred style.url:points at this folder; I can change it to a forum topic.Testing
node --test), all passing.development): crop, precision and lossless trim with marker remap, a user's own.editedfile left alone, WebM, a MOV with a timecode track, a second edit from the original, image-clip crop twice with the backup checksum unchanged, tasks run with no arguments, an out-of-bounds crop, and the hook with nothing pending.latest) and v0.31.1: crop, both trims and the second edit. The image-clip crop was also run on v0.31.1.validator/validate.js --cipasses.Limits
coverswithoverwrite).*.sve-partialfile. It is safe to delete.<name>.edited.edited.<ext>.LLM-assisted contribution
Written with Claude Code (an LLM) under the author's direction, per this repository's rule for LLM-assisted contributions. An LLM code review was run over the whole plugin; its ten findings are fixed in this version, apart from what is listed under Limits. A second LLM review covered the encode hook; its four findings are fixed. The tests above were run after those fixes.
The author specified the behaviour, looked over the code and tested it on their own library, and takes responsibility for the code.
🤖 Generated with Claude Code