Motion Detect

Motion Detect

Introduction

The Motion Detect operator compares each incoming frame against the one before it and reports where — and how much — the picture changed. Anything that stays still from frame to frame reads as "no motion"; anything that moves, appears, or disappears lights up as motion. Because the comparison is purely frame-to-frame, it needs no clean plate, no reference image, and no setup beyond dropping it into the operator chain.

That makes it a general-purpose activity detector: it can turn movement in the picture into a visible effect (heat maps, motion trails, highlighted regions) and into a value that scripts can react to (a presenter stepping into frame, a door opening, a static room suddenly becoming busy).

How it works

Every frame, the operator measures the per-pixel difference between the current picture and the previous one. The Method setting chooses how that difference is measured:

  • Luminance looks only at brightness changes. It is the least noisy option and ignores pure colour shifts — a good default for most footage.
  • Max Channel takes the strongest of the red, green, and blue differences, so it catches coloured movement even against a similarly-bright background.
  • RGB Magnitude combines all three channels into a single colour-distance measure. It is the most reactive and the most colour-sensitive.

Sensitivity then scales how strongly those raw differences register — raise it to surface subtle movement, lower it to stop sensor noise and grain from reading as motion.

Visualising motion

The Output mode decides how detected motion is drawn on the picture:

  • Motion Only — a greyscale map where brighter pixels mean more movement. The clearest view for tuning, and a clean source to feed a downstream keyer or compositor.
  • Threshold Mask — a hard black/white mask: white wherever motion exceeds the Threshold level, black everywhere else. Useful as a binary matte.
  • Motion as Alpha — the original picture preserved, with motion driving the alpha channel so moving regions become opaque and still regions transparent.
  • Overlay — the original picture with moving areas tinted in a chosen colour. The overlay's colour and strength are set in the Overlay Settings, and this is the mode that puts those controls to work.
  • Color Difference — visualises the direction of change rather than just its magnitude, useful for diagnosing what moved and which way.
  • Pass-through — the picture leaves the operator unchanged. Choose it when the operator is there only to detect motion and trigger scripts, so the layer keeps showing the original picture.

The Decay control adds persistence: at 0 only the current frame's motion is shown, while higher values let older motion fade out slowly, producing motion trails or an accumulating heat-map look. The Clear History command wipes that accumulation instantly — handy after a cut or a camera move, when stale trails are no longer wanted.

Triggering scripts

Beyond the visualisation, Motion Detect can act as a trigger. Detection works the same whichever Output is chosen, so with Pass-through the operator triggers without changing the picture. Turn on Enable detection and the operator continuously updates three read-only values:

  • Motion level — the strongest motion intensity in the current frame, on a 0–100 scale. Use it for proportional reactions, such as fading a graphic in as activity rises.
  • Motion detected — a true/false flag that flips on whenever the motion level crosses the Detection threshold. This is the main hook for automation.
  • Last detection age (s) — how many seconds have passed since motion was last detected. It drops back to 0 whenever motion is detected and counts up once a second while the picture stays still, so a script can act once a scene has been quiet for a set time.

Rather than checking those values on every frame, a script can have the operator call it. The Motion Toggle Event section names a script function that is called with true when motion starts, and with false once Last detection age (s) goes above Max detection age (s). A short pause in the middle of the action does not end the motion, so the script hears one start and one end for each burst of activity. Reacting from a script, further down this page, has an example.

Two further controls shape the trigger's cost and responsiveness. The Detection grid sets how densely the frame is sampled — a coarse grid is cheapest but can miss small movements, while a fine grid catches subtle motion at the cost of extra processing. Skip frames trades responsiveness for efficiency by checking only every Nth frame, which is ideal when motion only needs to be sampled occasionally (for example, watching an otherwise empty room).

Common use cases

  • Security and surveillance triggers — watch a static camera and raise Motion detected the moment something moves in an empty corridor, doorway, or room.
  • Automated production cues — start or stop a recording, cut a camera, or kick off a downstream effect when the talent moves into frame, and undo it once they have left and the picture has settled.
  • Heat-map and motion-trail graphics — use Decay to build a glowing accumulation of where the action has been, for sports analysis, music videos, or stings.
  • Activity-driven effects — drive an effect's intensity from the live Motion level so the look responds in real time to how busy the picture is.
  • Idle suppression — use the trigger to pause recording or processing while a scene is completely static, for example once Last detection age (s) passes a minute, saving storage and downstream work.

Motion Detect - Settings

Detection Settings

Detection Settings — how aggressively motion is detected and how the difference is measured.

Detection Settings
Property Description
Sensitivity Overall sensitivity to motion. [min=1, max=20, default=5]. Higher values amplify small frame-to-frame differences so subtler movements register. Increase if the operator misses real motion; decrease if it picks up camera noise or sensor grain.
Threshold Cutoff level used by the threshold-mask visualisation. [min=0, max=100, default=10]. Only motion above this level appears as white in Threshold Mask mode. Lower means more permissive.
Method How motion strength is measured. [default=Luminance]. Luminance reacts to brightness changes only and is least noisy. Max Channel takes the strongest of the red/green/blue differences — good for catching coloured movement on a similarly-bright background. RGB Magnitude is the most colour-sensitive and the most reactive overall.

Temporal

Temporal — how long motion lingers in the visualisation.

Temporal
Property Description
Decay How long motion persists in the visualisation, as a percentage. [min=0, max=100, default=0]. 0 shows only the current frame's motion. Higher values fade older motion out slowly, producing trails or a heat-map look.

Output

Output — how the detected motion is shown on the output image.

Output
Property Description
Output Visualisation mode for the output image. [default=Motion Only]. Motion Only shows greyscale motion strength. Threshold Mask shows a hard black/white mask using Threshold. Motion as Alpha keeps the original picture but ties opacity to motion. Overlay tints moving areas with the configured overlay colour. Color Difference shows the direction of change. Pass-through leaves the picture unchanged, for an operator that is there only to detect motion; detection works the same in every mode.

Overlay Settings

Overlay Settings — colour and opacity used in Overlay output mode.

Overlay Settings
Property Description
Overlay Red (advanced) Red component of the overlay tint. [min=0, max=255, default=0]. Only used when Output is set to Overlay.
Overlay Green (advanced) Green component of the overlay tint. [min=0, max=255, default=255]. Only used when Output is set to Overlay.
Overlay Blue (advanced) Blue component of the overlay tint. [min=0, max=255, default=0]. Only used when Output is set to Overlay.
Overlay Opacity (advanced) Strength of the overlay tint. [min=0, max=100, default=80]. 0 hides the overlay entirely; 100 paints moving regions with full overlay colour.

Motion Detection

Motion Detection — turn on the trigger logic that drives MotionDetected and MotionLevel.

Motion Detection
Property Description
Enable detection Turn the detection trigger on or off. [default=false]. When on, MotionDetected and MotionLevel update each frame so scripts can react. When off, both stay at zero/false.
Detection threshold Motion level (0–100) required for MotionDetected to become true. [min=1, max=100, default=20]. Lower for more sensitive triggers (good in low-action settings); higher to ignore minor activity.
Detection grid How densely the image is sampled when checking for motion. [default=Normal (16x16)]. Fast (8x8) is cheapest and may miss small movements. Normal balances cost and coverage. Accurate (32x32) and Precise (64x64) catch finer motion at the cost of extra processing.
Skip frames Frames skipped between detection checks. [min=0, max=30, default=0]. 0 checks every frame and is the most responsive. Higher values reduce processing cost when motion only needs to be sampled occasionally (for example, monitoring an empty room).
Motion detected True when current motion exceeds DetectionThreshold (read-only). The main trigger flag for scripts. Stays false when EnableDetection is off.
Motion level Current motion intensity, 0–100 (read-only). The strongest motion strength found in the current frame. Use this for proportional reactions, for example fading a graphic in based on activity level.
Last detection age (s) Whole seconds since motion was last detected (read-only). Goes back to 0 each time motion is detected and counts up by one every second after that, so 5 means no motion for the last 5 seconds. Until the first motion it counts from when detection started running. Stays 0 when EnableDetection is off.

Motion Toggle Event

Motion Toggle Event — call a script function when motion starts and when it has ended. Needs EnableDetection.

Motion Toggle Event
Property Description
Max detection age (s) Seconds without motion that still count as motion. [min=1, default=2]. Motion has ended once LastDetectionAgeSeconds is above this, so at the default 2 the function named in MotionToggleCallback is called with false when Last detection age (s) reaches 3.
On motion toggle Name of a script function to call when motion starts and when it has ended. [default=empty]. It is given one boolean, true or false, so if (isMotion) works: true at the first motion detected, and false once LastDetectionAgeSeconds is above MaxDetectionAgeSeconds, or when EnableDetection is turned off while motion is on, so while the project runs a true is followed by a false. Nothing is called while the operator is off or its layer is not rendered, nor when the project stops. Each run starts with no motion, and a change made while the script is still loading is given to the function once the script runs. It is called while the frame renders, so keep it short. Leave empty to call nothing.

Commands

Commands — actions that can be triggered by scripts or the UI.

Commands
Property Description
Clear History Clear the motion history/heat-map so the next frame starts fresh. Useful after a cut, a camera move, or any time accumulated trails are no longer wanted.
Reset Reset all settings to their defaults (sensitivity, thresholds, output mode, overlay colour, detection options).

Status

Status — diagnostic message about the operator state.

Status
Property Description
Message Diagnostic message from the operator (read-only). Reports info, warnings and errors such as detection failures or output-mode changes from keyboard shortcuts.

Inherits from: AbstractOperator, AbstractAudioMetering, NamedModel.

See also: Motion Detect in Script Engine Objects.

Reacting from a script

A Script Engine script can follow motion in two ways:

  • The operator calls your script. Turn on Enable detection, open the Motion Toggle Event section and name a function in On motion toggle. The operator calls it when motion starts and when motion has ended. Nothing is called on the frames in between.
  • Your script reads the operator. Look the operator up by scene, layer and name, and read MotionDetected, MotionLevel or LastDetectionAgeSeconds whenever you need them.

The operator calls your script

Set On motion toggle to OnMotionToggle, and add this function to the project's script:

// Called by the Motion Detect operator when motion starts and when it has ended.
function OnMotionToggle(isMotion) {
    if (isMotion) {
        Logger.Info('Motion started');
    } else {
        Logger.Info('Motion has ended');
    }
}

The function receives one argument, true or false, as a JavaScript boolean, so it can be tested directly as above.

It is called with:

  • true the first time motion is detected, after a time without motion.
  • false once Last detection age (s) goes above Max detection age (s). Last detection age counts whole seconds, so at the default of 2 the call comes when it reaches 3, three seconds after the last motion. Motion detected before then keeps the motion going, and the count starts again from it.
  • false when Enable detection is turned off while motion is on. So while the project runs, a true is followed by a false, and a script that starts something on true can stop it on false.

Things to know:

  • Turning Enable detection off ends any motion in progress, with the false above. After that nothing is called until it is turned on again.
  • The operator calls the function as it processes frames. While the operator is switched off, or its layer is not rendered, motion neither starts nor ends and nothing is called.
  • Stopping the project calls nothing, even when motion is on. A script that must clean up when the project stops does it in OnProjectStop.
  • Each time the project starts, motion starts off. The script loads a moment after the picture starts, and motion detected in that moment is given to the function as soon as the script is running. So motion that is already in the picture when the project starts is reported too. Motion that starts and ends again before the script is running calls nothing.
  • With Skip frames above 0, only the frames that are checked can start the motion, so true can come up to that many frames late.
  • With Enable auto reload of script on, Composer loads the script again when you edit it while the project runs. The reloaded script hears about the next change, not about whether there is motion at that moment.
  • It runs as part of rendering the frame, so keep it short. Slow script code slows the output.
  • In a module script, export the function, or the operator can't find it.

Your script reads the operator

Look the operator up by the names shown in the project: the scene, the layer, and the operator's name on that layer. The names must match exactly, including upper and lower case.

var VindralEngine = importNamespace('VindralEngine');
var Project = VindralEngine.Project.RunningInstance;

function SceneHasBeenStill(seconds) {
    const motion = Project.GetLayerOperatorByName('Scene', 'Camera', 'Motion Detect');
    return motion != null && Project.GetObjectProperty(motion, 'LastDetectionAgeSeconds') >= seconds;
}

Call it from wherever the script needs the answer, for example from a connector's function.