Motion Estimation Simulator
Simulate inter-frame motion estimation, block matching, search patterns, and compression residuals.
SAD & Search Inefficiencies 🖖
Motion estimation is the bottleneck of video compression. A macroblock of size 16x16 is matched against the reference frame in a search window to find the candidate with the lowest Sum of Absolute Differences (SAD). Exhaustive Full Search evaluates all (2r+1)² positions, which is slow. Fast algorithms like Diamond and Hexagon search evaluate only a fraction of points by moving the search center iteratively, terminating when the minimum is at the center of the pattern. Hover over any block to see its search window and candidate evaluations in real time.
Why send motion, not pixels 🖖
Consecutive video frames are almost identical, so instead of storing each frame in full, a codec describes the current frame as pieces of the previous one that have shifted. Each 16×16 block gets a motion vector pointing to its best match, plus a small residual holding whatever the shift couldn't explain. The takeaway: smooth camera pans compress beautifully, because a single vector replaces thousands of pixels.
Motion vectors aren't really motion 🖖
The encoder never asks what actually moved — it only hunts for the block that minimises SAD. So on flat or noisy regions the winning vector can point somewhere absurd, nothing like the true displacement. Raise the noise slider and watch the vector field scatter into nonsense. This is why motion vectors make a poor optical flow, yet perfect compression: they serve bitrate, not physics.
Example problems
- Slow Pan - Slow horizontal pan: near-zero residual, motion vectors point uniformly right
- Fast Pan - Fast pan: larger SAD at search boundary, high-energy border residuals
- Diverging zoom - Zoom-in motion: diverging vectors from centre, no single translation vector fits
- Noisy handheld camera - Noisy camera: high SAD despite correct vectors — noise energy dominates residual