Repository navigation
Conversation
…line The dynamic zoom was computed for the whole source clip, so shaky footage that was trimmed away on the timeline still increased the crop of the part that is actually visible. DaVinci Resolve doesn't provide the trim range through OpenFX (the clip frame range is always the whole media), so it's queried with fuscript, the same way as the current file path. One query returns all timeline items and is shared by all instances; it runs synchronously the first time (so the first rendered frames already use the right zoom) and then refreshes in the background at most every 2 seconds to pick up re-trims. When the same file is used multiple times, the item containing the rendered frame is used. The range is part of the manager cache key, because pieces of a blade-cut clip share the instance id. Only the zoom is fit to the range: smoothing still uses the whole clip (`trim_range_only` = 0), so the camera motion doesn't change and the option can only reduce the zoom. The new "Zoom only for used part" checkbox is enabled by default and requires Resolve Studio with external scripting set to Local. Without it, nothing changes.
Resolve runs the script on its main thread, so refresh the used ranges only after a pause in rendering (eg. after trimming a clip), and do it synchronously so the rendered frames always use the current range.
Resolve 21 answers scripting calls only after it gets the frame being rendered, so waiting for fuscript in render() deadlocks the playback. Query in a background thread, wait at most 300 ms, kill fuscript after 10 s.
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.
Problem
In DaVinci Resolve the dynamic zoom is computed for the whole source clip. If the end (or start) of a clip is shaky but trimmed away on the timeline, it still increases the crop of the visible part.
Why fuscript
Resolve doesn't expose the trim range through OpenFX. I logged everything available during render on the Edit page. For a clip that uses frames 230–525 of 708:
kOfxImageEffectPropFrameRangeon the source clip is0..707, the whole media.kOfxImageEffectInstancePropEffectDurationis708.0..0.kOfxImageEffectPropFrameRangeinBeginSequenceRenderholds just the current frame.So the range is queried with fuscript, the same way the plugin already queries the current file path.
TimelineItem:GetSourceStartFrame()andGetSourceEndFrame()give the used source range. If those methods aren't available, it falls back toGetLeftOffset()andGetDuration().How it works
render(), which deadlocked playback in Resolve 21.1: the clip froze and fuscript hung for minutes.StabilizationManagercache key, because pieces of a blade-cut clip share the instance id but use different parts of the clip.trim_range_only= 0 for the smoothing algorithm). The camera motion doesn't change, and limiting the range can only reduce the zoom: frames outside the range get the widest FOV before the rolling min.This differs from the After Effects path (
b3a0dc3), which also limits smoothing to the trim. I tried that too. With the default algorithm, dropping a shaky part lowers the max velocity, so smoothing gets stronger and the crop often grows instead of shrinking.Results
Maximum zoom within the used part, with default settings, on Sony A7 IV clips:
UI
There is a new "Zoom only for used part" checkbox, enabled by default:
Because it's on by default, the zoom of existing projects changes (only ever decreases) after updating. If you'd prefer it off by default, I'm happy to change that.
Testing
Tested on macOS (M3 Pro) with Resolve Studio 20.3 and 21.1:
cargo check).