# Editing talking-head video

> Turn a walk-and-talk take into three edits — transcript captions, a cut on the beat of music chosen to fit the speaker's rhythm, and a calm edit with diagrams timed to the words.

A person talking to a camera is the most common footage there is, and it can be cut many ways. This guide
edits one real walk-and-talk vlog three ways, each built from the same parts: the take, a word-level
transcript, and (for the music cut) the beat of a track.

- [Captions](https://vidmake.app/docs/talking-head.md#1-captions-from-a-transcript) The first layout: the take as shot, with the transcript word by word.
- [Cut to the beat](https://vidmake.app/docs/talking-head.md#2-cut-to-the-beat) Pauses removed, every cut on a beat, keywords hit.
- [Diagrams on the words](https://vidmake.app/docs/talking-head.md#3-diagrams-on-the-words) A calm edit that illustrates what is being said.
- [The full example](https://vidmake.app/docs/talking-head.md#the-full-example) Vertical and horizontal, all three edits, from a script.

> [!AGENT]
> Work from the transcript, not the waveform. Put every time you derive from a word into the composition's
> `markers` (`"snow": "5.28s"`) and write `"@snow"` in the layers, so a retimed edit only changes the markers.

## 1. Captions from a transcript

Transcribe the take with word timestamps. [whisper](https://openai.com/index/whisper/) writes a JSON file that a
[`captions`](https://vidmake.app/docs/captions.md) layer reads as is:

```bash
whisper take.mp4 --model small.en --word_timestamps True --output_format json
```

**Demo: A walk-and-talk take with its whisper transcript as captions: each word lights up as it is spoken** (rendered video: https://vidmake.app/media/talking-captions.mp4)

```json
{
  "fonts": [
    { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" },
    { "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }
  ],
  "compositions": [{
    "id": "captions", "description": "A walk-and-talk take with its whisper transcript as captions: each word lights up as it is spoken",
    "width": 720, "height": 1280, "fps": 30, "duration": "8.3s", "background": "#161412",
    "layers": [
      { "id": "take", "type": "video", "src": "assets/talk-elephant.mp4", "width": "100%", "height": "100%" },
      { "id": "subs", "type": "captions", "src": "assets/talk-elephant.json", "y": "72%", "maxWidth": 600,
        "font": "Schibsted Grotesk", "fontSize": 54, "fontWeight": 850, "letterSpacing": -1.5, "lineHeight": 1.05,
        "fill": "#fbf9f4", "highlight": "#f05a4e", "stroke": "#161412", "strokeWidth": 9 },
      { "id": "credit", "type": "text", "text": "FOOTAGE: JACOB GRIBBIN, CC BY 4.0", "font": "JetBrains Mono", "fontSize": 15,
        "letterSpacing": 1.5, "fill": "#fbf9f4", "opacity": 0.7, "y": 1240 }
    ]
  }]
}
```

- `src` takes the whisper file directly; its times are seconds from the start of the clip. If you trim the
  clip, shift the times by the same amount.
- `highlight` colors the word being spoken ([line mode](https://vidmake.app/docs/captions.md#line-mode-and-highlight)).
- Check names and places in the transcript before you style it: whisper hears "Chiang Mai" as "chengmai".
  Fix the text in the file and keep the times.

## 2. Cut to the beat

A hype edit removes the pauses and cuts on the music. Start with what the track gives you:

```console
$ vidmake analyze assets/beat.mp3
7.00s at 30.0 fps (210 frames)
beats: 8, tempo ≈100 BPM
  0.60 1.17 1.77 2.43 3.67 4.83 5.37 5.97s
onsets: 21 (TIME  RISE  PEAK  BAND)
    0.070s  +10.2 dB   -4.8 dBFS  low
    0.609s  +12.2 dB   -8.3 dBFS  low
    1.167s  +10.3 dB   -7.2 dBFS  low
    1.596s  + 7.5 dB   -9.2 dBFS  mid
    1.766s  +16.3 dB   -4.9 dBFS  low
    1.846s  + 8.5 dB   -5.1 dBFS  low
    2.365s  +12.9 dB   -5.9 dBFS  low
    2.454s  +13.8 dB   -4.5 dBFS  low
    2.584s  +10.2 dB   -7.0 dBFS  low
    2.734s  + 8.1 dB   -6.7 dBFS  low
    3.023s  +10.5 dB   -5.8 dBFS  low
    3.662s  + 8.8 dB   -6.1 dBFS  low
    3.761s  + 7.0 dB   -6.0 dBFS  low
    4.071s  + 6.6 dB   -7.5 dBFS  mid
    4.230s  + 6.6 dB   -9.9 dBFS  low
    4.809s  +15.0 dB   -6.2 dBFS  mid
    5.198s  + 9.2 dB  -10.4 dBFS  mid
    5.378s  + 9.3 dB  -10.7 dBFS  mid
    5.976s  + 7.1 dB   -6.3 dBFS  mid
    6.096s  + 7.6 dB   -7.1 dBFS  low
    6.276s  + 7.1 dB  -10.1 dBFS  mid

        MEAN    P10 MEDIAN    P90 AT CEILING
amp     0.61   0.32   0.65   0.90         4%
bass    0.55   0.22   0.57   0.88         3%

   TIME  AMP mean/peak                   BASS mean/peak                  BEATS   (bar = mean, ▏ = peak)
  0.00s  0.61/1.00 ████████████       ▏ 0.50/0.93 ██████████        ▏    0
  0.50s  0.61/0.79 ████████████   ▏     0.54/0.69 ███████████  ▏         1
  1.00s  0.70/0.91 ██████████████   ▏   0.69/0.97 ██████████████    ▏    1
  1.50s  0.76/1.00 ███████████████    ▏ 0.74/1.00 ███████████████    ▏   1
  2.00s  0.72/1.00 ██████████████     ▏ 0.71/1.00 ██████████████     ▏   1
  2.50s  0.81/1.00 ████████████████   ▏ 0.82/1.00 ████████████████   ▏   0
  3.00s  0.73/0.98 ███████████████    ▏ 0.72/1.00 ██████████████     ▏   0
  3.50s  0.79/1.00 ████████████████   ▏ 0.74/0.99 ███████████████    ▏   1
  4.00s  0.57/0.81 ███████████    ▏     0.46/0.78 █████████      ▏       0
  4.50s  0.54/0.94 ███████████       ▏  0.37/0.73 ███████       ▏        1
  5.00s  0.50/0.65 ██████████  ▏        0.34/0.54 ███████   ▏            1
  5.50s  0.57/0.99 ███████████        ▏ 0.46/0.89 █████████        ▏     1
  6.00s  0.61/1.00 ████████████       ▏ 0.54/0.94 ███████████       ▏    0
  6.50s  0.11/0.31 ██   ▏               0.09/0.27 ██  ▏                  0
```

Beats are 0.6 s apart (100 BPM). Split the transcript into phrases wherever the speaker pauses, then place
each phrase so its cut lands on a beat. The pause after a phrase is silence the shot can run on into, so the cut
to the next phrase can sit anywhere inside that pause. Use a beat if one falls there. If not, use a half
or quarter beat, and if none fits, cut straight after the phrase. No word is clipped or heard twice, and nothing
freezes. Alternate the framing on each cut (a punch-in with `scale`), and let a big word take over the frame
on the hits:

**Demo: Cut to the beat: pauses removed, every cut lands on a beat (or half beat) of a 100 BPM track** (rendered video: https://vidmake.app/media/talking-beat.mp4)

```json
{
  "fonts": [
    { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" },
    { "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }
  ],
  "compositions": [{
    "id": "beat", "description": "Cut to the beat: pauses removed, every cut lands on a beat (or half beat) of a 100 BPM track",
    "width": 720, "height": 1280, "fps": 30, "duration": "4.2s", "background": "#161412",
    "markers": { "b1": "1.8s", "b2": "2.4s", "half": "2.7s", "quarter": "3.15s" },
    "layers": [
      { "id": "s1", "type": "video", "src": "assets/talk-verdict.mp4", "trimStart": "0.16s", "duration": "@b1", "width": "100%", "height": "100%" },
      { "id": "s2", "type": "video", "src": "assets/talk-verdict.mp4", "trimStart": "1.96s", "start": "@b1", "duration": "0.6s",
        "width": "100%", "height": "100%", "anchor": [0.5, 0.3], "y": "30%", "scale": 1.18 },
      { "id": "s3", "type": "video", "src": "assets/talk-verdict.mp4", "trimStart": "2.86s", "start": "@b2", "duration": "0.3s", "width": "100%", "height": "100%" },
      { "id": "s4", "type": "video", "src": "assets/talk-verdict.mp4", "trimStart": "3.22s", "start": "@half", "duration": "0.45s",
        "width": "100%", "height": "100%", "anchor": [0.5, 0.3], "y": "30%", "scale": 1.18 },
      { "id": "s5", "type": "video", "src": "assets/talk-verdict.mp4", "trimStart": "3.8s", "start": "@quarter", "width": "100%", "height": "100%" },
      { "id": "flash", "type": "rect", "fill": "#fbf9f4", "lint": false,
        "opacity": [[0, 0], ["@b2-1", 0], ["@b2", 0.6], ["@b2+4", 0], ["@quarter-1", 0], ["@quarter", 0.6], ["@quarter+4", 0]] },
      { "id": "lead", "type": "text", "text": "pretty much our trip has been", "duration": "1.55s", "y": "68%", "maxWidth": 560,
        "font": "Schibsted Grotesk", "fontSize": 50, "fontWeight": 850, "letterSpacing": -1.5, "fill": "#fbf9f4",
        "stroke": "#161412", "strokeWidth": 8, "enter": { "type": "fadeUp", "delay": "0.25s" }, "stagger": { "by": "word", "over": "1s" } },
      { "id": "hits", "type": "captions", "mode": "word", "uppercase": true, "y": "68%", "font": "Schibsted Grotesk",
        "fontSize": 120, "fontWeight": 900, "letterSpacing": -5, "fill": "#fbf9f4", "stroke": "#c92a26", "strokeWidth": 14,
        "items": [{ "text": "massage eat sleep massage eat sleep", "start": "1.58s", "end": "4.2s", "words": [
          { "text": "massage", "start": "1.58s", "end": "2.44s" }, { "text": "eat", "start": "2.44s", "end": "2.74s" },
          { "text": "sleep", "start": "2.74s", "end": "3.19s" }, { "text": "massage", "start": "3.19s", "end": "3.43s" },
          { "text": "eat", "start": "3.43s", "end": "3.75s" }, { "text": "sleep", "start": "3.75s", "end": "4.2s" }] }] },
      { "id": "music", "type": "audio", "src": "assets/beat.mp3", "volume": 0.45, "fadeOut": "0.3s" },
      { "id": "credit", "type": "text", "text": "FOOTAGE: JACOB GRIBBIN, CC BY 4.0 · MUSIC: LOYALTY FREAK MUSIC, CC0",
        "font": "JetBrains Mono", "fontSize": 13, "letterSpacing": 1, "fill": "#fbf9f4", "opacity": 0.7, "y": 1244 }
    ]
  }]
}
```

- Each shot is a `video` layer with its own `trimStart` and `duration`. Name the cut points as `markers` and
  start the shots on them (`"start": "@b2"`).
- A punch-in on a cut is `scale` around the face: set `anchor` to where the face is and `y` to the same
  fraction, so the zoom stays centred on them.
- [Word mode](https://vidmake.app/docs/captions.md#word-mode) with inline `items` shows one word at a time at the edited times.
- Keep the music under the voice: around 0.3–0.5 `volume` while someone talks, louder in the gaps.

To choose the track, compare candidate tracks with how the speaker talks: measure each word's onset from the
start of its phrase and count how many fall on each track's grid (within ±45 ms) at playback rates within ±4%.
`playbackRate` on an `audio` layer keeps the pitch. The full example does this for you and prints the result.

## 3. Diagrams on the words

The calm edit keeps the speaker's pace, trims only the long pauses, and illustrates the points they make. Mark
each word a graphic hangs on, and let the footage step aside while the graphic is up, so nothing covers a face:

**Demo: A diagram on the words it illustrates: the take steps aside, and each month's bar rises as she names it** (rendered video: https://vidmake.app/media/talking-story.mp4)

```json
{
  "fonts": [
    { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" },
    { "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }
  ],
  "compositions": [{
    "id": "story", "description": "A diagram on the words it illustrates: the take steps aside, and each month's bar rises as she names it",
    "width": 1280, "height": 720, "fps": 30, "duration": "8.8s", "background": "#f4f1ea",
    "markers": { "aside": "4.3s", "jan": "6.66s", "feb": "6.88s", "mar": "7.82s" },
    "layers": [
      { "id": "take", "type": "video", "src": "assets/talk-snow.mp4", "width": 1280, "height": 720, "clip": true,
        "x": [[0, 640], ["@aside", 640], ["@aside+0.6s", 420, "easeInOutCubic"]],
        "scale": [[0, 1], ["@aside", 1], ["@aside+0.6s", 0.58, "easeInOutCubic"]] },
      { "id": "chart", "type": "group", "start": "@aside+0.4s", "enter": { "type": "fadeLeft", "motion": "snap" }, "children": [
        { "id": "title", "type": "text", "text": "MOST OF THE SNOW", "font": "JetBrains Mono", "fontSize": 18, "letterSpacing": 3,
          "fill": "#4a4640", "x": 1030, "y": 150 },
        { "id": "jan", "type": "rect", "anchor": "bottom", "x": 930, "y": 520, "width": 76, "fill": "#161412",
          "height": [[0, 0], ["@jan", 0], ["@jan+0.45s", 300, "easeOutBack"]] },
        { "id": "feb", "type": "rect", "anchor": "bottom", "x": 1030, "y": 520, "width": 76, "fill": "#161412",
          "height": [[0, 0], ["@feb", 0], ["@feb+0.45s", 300, "easeOutBack"]] },
        { "id": "mar", "type": "rect", "anchor": "bottom", "x": 1130, "y": 520, "width": 76, "fill": null, "stroke": "#c92a26",
          "strokeWidth": 3, "dash": [10, 8], "height": [[0, 0], ["@mar", 0], ["@mar+0.45s", 140, "easeOutBack"]] },
        { "id": "months", "type": "text", "text": "JAN       FEB       MAR", "whiteSpace": "pre", "font": "JetBrains Mono",
          "fontSize": 18, "letterSpacing": 1.2, "fill": "#161412", "x": 1030, "y": 550 },
        { "id": "note", "type": "text", "text": "sometimes", "font": "Schibsted Grotesk", "italic": true, "fontSize": 24,
          "fill": "#c92a26", "x": 1130, "y": 350, "start": "@mar+0.3s", "enter": "fadeUp" }
      ] },
      { "id": "subs", "type": "captions", "src": "assets/talk-snow.json", "y": "90%", "maxWidth": 1100,
        "font": "Schibsted Grotesk", "fontSize": 32, "fontWeight": 700, "fill": "#161412", "highlight": "#c92a26",
        "background": "#fbf9f4", "padding": [8, 16] },
      { "id": "credit", "type": "text", "text": "FOOTAGE: WHEREVA, CC BY 4.0", "font": "JetBrains Mono", "fontSize": 12,
        "letterSpacing": 1, "fill": "#8a857a", "anchor": "right", "x": 1256, "y": 24 }
    ]
  }]
}
```

- The take shrinks and slides left with two keyframed properties (`x`, `scale`) that start at `@aside`.
- Each bar rises on its own month's marker (`["@feb+0.45s", 300]`). Markers convert to each layer's local time,
  so the bars work inside a group that starts later.
- She gives no amounts, so the bars carry none: the diagram shows only what was said.

## Reframing horizontal footage for vertical

A 4K take scaled to 1920 px high is 3414 px wide, so a 1080×1920 window can move across it at full
resolution. Give the `video` layer the full `width`/`height` and move `x` to follow the speaker. Ease between
positions, and only move when they drift well off-centre, as a camera operator would. The full example finds
the face with macOS Vision four times a second and smooths the path.

## The full example

`examples/talking-head`, in the `examples` folder of every vidmake release archive, builds all three edits in
vertical (9:16, from a 4K Chiang Mai travel vlog) and horizontal (16:9, from a Shepherdstown couple's vlog), each
60–110 s long, from committed transcripts, music analysis and face positions:

```bash
cd examples/talking-head
./fetch.sh                         # footage (CC BY 4.0) and music (CC0) from Wikimedia Commons
python3 build.py                   # writes vertical.json and horizontal.json
vidmake render vertical.json --comp beat -o out/vertical-beat.mp4
```

`build.py` is the editor: you name the takes, and it maps words through the cuts, fits the music, cuts on the
beat, places keyword hits and diagrams on markers, and follows the face. It prints how many cuts landed on a beat.

Footage: Jacob Gribbin and Whereva, CC BY 4.0 (credit them when you reuse it). Music: Loyalty Freak Music,
John Bartmann, Sonatema and Luisalvaz, CC0.
