kinetograph.

Motion tracking

Pin text, pictures or effects to something that moves in a video, with Blender's tracker.

Kinetograph tracks points through a video with Blender's tracker (libmv). You run it once, before rendering. It writes a small JSON file of positions, and your composition reads it with useTrack(). Rendering never tracks, so every render comes out the same.

Track a point

Find the point in a still of the first frame. Then run:

npx kinetograph track public/video/clip.mp4 --point 980,800

This writes public/video/clip.mp4.track.json. Repeat --point for more points. Use name=x,y to name one:

npx kinetograph track public/video/clip.mp4 --point anvil=980,800 --point sign=1690,640

Points are in the video's own pixels. x goes right, y goes down, and 0,0 is the top-left corner.

Use it in a composition

useTrack and usePlaneTrack are for TypeScript projects.

src/scenes/Label.tsx
import { useTrack } from '@kinetographdev/core';

const Label = () => {
  const { x, y, rotation, scale } = useTrack('video/clip.mp4.track.json', 'sign');
  return (
    <div style={{ position: 'absolute', left: x, top: y, transform: `translate(-50%, -50%) rotate(${rotation}deg) scale(${scale})` }}>
      Look here
    </div>
  );
};

Draw <Label /> over your <OffthreadVideo>. useTrack returns x, y, rotation (degrees), scale and corners (for a corner pin). Before the first tracked frame the first position is used, and after the last frame, or after a track is lost, the last position holds. If you draw the video smaller, larger or moved, apply the same scale and offset to the positions.

Options

The defaults are Blender's. --model sets what the pattern may do (loc, locrot, locscale, locrotscale, affine or perspective): pick one with rotation or scale if you want rotation and scale to change. --pattern and --search set the pattern and search sizes in pixels, and fast motion needs a bigger search area. --min-correlation (0.75) stops a track on a worse match, so lower it for grainy footage. --from and --to pick the frames. The CLI reference lists the rest.

Find points automatically

--detect finds corners with plenty of texture, at least 120 pixels apart, on the first frame tracked. Then it tracks them all, as Blender's Detect Features does.

npx kinetograph track public/video/clip.mp4 --detect

The points are named p1, p2 and so on. The defaults find only the strongest few corners; --detect-threshold 0.05 finds many more.

Pin a picture to a surface

A plane track follows a flat surface, such as a screen, a sign or a wall. You make one from four or more tracked points on that surface, as Blender's Create Plane Track does:

npx kinetograph track public/video/clip.mp4 --point 820,540 --point 1250,430 --point 820,360 --point 200,600 \
  --plane screen=p1,p2,p3,p4 --plane-corners screen=700,300,1300,320,1280,700,720,680

--plane-corners sets the plane's corners on the first frame tracked, as x,y pairs from top-left clockwise. Pick points that are on the surface and spread out, not three on one line.

In the composition, usePlaneTrack() gives the corners for the current frame, ready for the cornerPin effect:

src/scenes/Screen.tsx
import { Image, cornerPin, usePlaneTrack } from '@kinetographdev/core';

const Screen = () => {
  const { pin } = usePlaneTrack('video/clip.mp4.track.json', 'screen');
  return <Image src={staticFile('images/poster.png')} width={1280} height={720} effects={[cornerPin(pin)]} />;
};

Draw <Screen /> in a full-frame layer over the video.

When a track is lost

A track stops where Blender's would. That is when the best match is below the minimum correlation, falls outside the search area, or reaches the frame edge. The command prints the frame, the file lists it in lost, and the position holds from there.

To track further, try a bigger pattern, a bigger search area, a lower --min-correlation, or a point with more texture.

On this page