Dorr: Video Themes That Cut on the Beat

Dorr is the photo and video editor I wrote about in October. Since then most of the work has gone into one part of it: Photos to video, where you pick a few photos and Dorr turns them into a short music video. The next iPhone update replaces the whole theme list. The new themes read the music first and cut on its beat, and the editor suggests the themes that suit the photos you just picked.

This note goes through how that works, from measuring a song’s tempo to deciding which photo lands on which beat. It also covers the rules I had to write after the first version looked fine on paper and boring on screen. All screens come from the current development build.

Not in the store yet. The App Store version is still 2.1.3 from October 12. Everything below is in the next iPhone update. The sample photos in these screens are generated images made for testing, not real people.

Sixteen Dorr video theme cards grouped as Beat, Collage, Cinematic, Retro and Mood, such as Beat Flash, Grid, Instant Prints and Golden Hour
The sixteen new templates in five groups, shown with the app’s own theme cards.

Why the old themes had to go

The store version has 26 video themes. Each one was a fixed recipe: a motion for the photo, a transition between photos and a tempo. The tempo was a number I typed in for the theme’s default track. It worked, but it had two weaknesses that got worse as the list grew.

First, the cuts only lined up with the music by luck. If the number was a little off, or if you picked a different track, the cuts drifted away from the beat. Second, many themes were near copies of each other. A video made with one looked like a video made with its neighbor in a different color.

The next version offers 18 themes: the two basic ones, Basic Fade and Slide, which still let you edit every clip, plus sixteen new templates in five groups: Beat, Collage, Cinematic, Retro and Mood. The older scene themes are no longer offered. Their renderers stay in the code for tests, but you can’t pick them for a new video.

The cut went further than that. Before release I also dropped seventeen template variants that only changed a color, a tint or a title, such as three neon colors, three dream tints, three print tones and three sticker colors. They moved exactly alike and looked like duplicates in the picker. The rule now is one theme per style. Two more pairs were merged for the same reason. A trio grid became part of Grid, and stacked strips became part of Strips, because they shared their layouts and differed only in one entry animation or orientation. Now each slot of the merged theme picks between those layouts.

Reading the music first

A theme can only cut on the beat if it knows where the beats are. All twenty bundled tracks are CC0 music from OpenGameArt. Until this month each had a tempo typed in by hand. Now each track carries a beat map measured from its own audio by a small analysis script that I rerun whenever a track is added or replaced.

The analysis is a classic onset-and-tempo method, and it is simpler than it sounds:

  1. Find onsets. The audio is cut into short overlapping windows of 2,048 samples, stepping 512 samples at a time. For each window the script measures how much new energy appeared compared with the window before, across all frequencies. This is called spectral flux. A drum hit or a new note shows up as a spike. The script subtracts a half-second running average so that loud passages don’t count as one long onset.
  2. Find the repeating interval. It compares the onset curve with shifted copies of itself, a method called autocorrelation. The shift where the curve best matches itself is the beat length. The search is weighted toward 120 BPM, a common tempo, and folded into the 70–160 BPM range. Otherwise a fast track can read as half speed, or a slow one as double.
  3. Fit the grid over the whole track. Tempo and the first beat are fitted together across the entire track, not only its opening bars. A tiny tempo error is invisible in the first second and obvious by the twentieth.
  4. Find the bars. Of the four beats in a bar, the one with the most energy below 150 Hz, usually the kick drum, is taken as the first.
  5. Keep the strongest hits. The strongest onsets are kept as hits, with a strength relative to the track’s loudest. They are spaced at least 0.35 seconds apart, so a drum fill doesn’t become ten hits.

There is also an honest failure case. If no grid explains a track’s onsets strongly enough, with a fit score of at least eight times their average strength, the track has no steady pulse and gets no map. Five of the twenty are like that. For those tracks a theme falls back to its own tempo rather than pretending to follow a beat that isn’t there.

The rerun also showed that several typed-in values were wrong. Hero Rush was entered as 138 BPM and measures 120. City Loop was 110 and measures 100. Sunny Trail was 120 and measures 123.06. That last one sounds close enough, but the error adds up with every beat:

Diagram of eight seconds of a music track: its waveform and strong hits, the measured beat grid, the drifting old 120 BPM grid, and photo slots cut on the beats
Real data from Sunny Trail. With the old value, the fifth bar line arrives 0.16 seconds late, which is already a third of a beat, and it keeps drifting from there.

Bundled tracks loop when the video is longer than the track, and you can start a track partway in. The beat grid follows both. It starts at the chosen offset, and it starts over each time the track loops, so the cuts after a loop stay on the beat too.

Cutting photos into slots

With a beat grid in hand, a template cuts the video’s length into slots. A slot is a stretch of time that shows one or more photos with one layout before cutting to the next. Slot boundaries always fall on a beat or exactly halfway between two beats.

Each theme has its own uneven rhythm, written as a short cycle of slot lengths. Instant Prints, for example, cycles through slots of two, two, two, three, one and two beats, and its fourth slot holds two photos instead of one. Beat Flash runs much faster in the middle of its cycle, down to half-beat slots, then settles back to two beats. An uneven cycle keeps a video from ticking like a metronome. A cycle that repeats every six slots also feels like a pattern the ear can follow.

A few small rules handle the edges, and each one fixes something that went wrong in testing:

  • If a track’s first beat comes a moment after the video starts, the first slot simply runs a little longer, so every later cut still lands on the beat.
  • Where a looping track meets its own start, a computed halfway point can land right next to a real beat. In that case the real beat wins, and the other point is dropped.
  • If the last slot would be shorter than 0.3 seconds, it joins the one before. A flash of a photo that short reads as a glitch.
  • A slot never shows the same photo twice, even when you picked fewer photos than the slot has cells.
  • A template’s automatic length is always long enough to show every photo once, plus a spare beat, so no photo is silently left out.

The music also decides how big each move is. Each slot remembers whether it opens on the first beat of a bar and whether a strong hit falls at its start. Those slots get the bigger moves, such as a shake, a color split or a hard cut. Quiet beats get the soft ones. Change the track, and the cuts and big moves move with it.

The same grid drives editing by hand. Clip lengths on the timeline, and the end of a video clip’s selected range, snap to the selected track’s beats. A manual edit stays in time without any extra effort.

How a slot is drawn

The old themes each had their own renderer. The new templates share one compositor that draws a slot as a stack of layers. A theme is then mostly data: which layers, which variants, which colors and which rhythm.

Diagram of the six layers a Dorr template frame is drawn from: background, media cells, cutout, overlays, camera move and screen chrome
The six kinds of layers every template frame is built from, bottom to top.

Positions and sizes are stored as shares of the frame, not pixels. The same stack draws a 9:16 story, a square post and a 16:9 landscape video without separate layouts. Every animated value is a keyframe track over the slot’s progress, from 0 at the cut to 1 at the next cut. Flashes and drops are the exception: they are timed in seconds, because a flash stretched over a long slot stops being a flash.

Two layers matter more than they look. Media cells crop each photo around the subject found on the device, so a face doesn’t end up cut off at the edge of a polaroid. Cutouts take the person from a photo and draw them over the frame, so they can step out of a print or over a neighboring cell. A person mask costs a model run per video frame, so the compositor only asks for one while a cutout is actually on screen.

The camera layer moves the finished frame for punches, shakes and the cut itself. That move would show empty edges, so the frame is scaled up just enough to stay covered after the turn and offset. Screen chrome, such as letterbox bars, a camcorder’s REC mark and its date, is drawn after the move, so it holds still while the picture moves.

No two slots alike

The first versions of these templates used one recipe for every slot. On paper that looked consistent. In a real 12-second video it looked like a loop within a few seconds. So on November 2, after watching those first renders, I wrote down a set of rules that every template must follow. The most important ones:

  • A theme is a grammar, not a recipe. The identity holds for the whole video: colors, tone and materials such as the letterbox, the paper or the scanlines. What each slot does with them changes.
  • Deal variants, don’t alternate them. Each choice a slot makes, such as layout, position, size, angle, entry direction or camera move, is dealt from a handful of variants like cards from a shuffled deck. Every variant shows once per round, in a new order each round, and never twice in a row. Alternating two values, or stepping through them by slot number, reads as a loop within seconds. The shuffle is seeded per theme, so the preview and the exported video always match.
  • One effect, many ways. A move counts as new when its direction or composition changes, for example a whip from any of four sides, a spin either way, or a light leak from a dealt corner. I try a new direction before I add a new effect.
  • Photos don’t crawl. A photo never slowly zooms or drifts inside a frame that holds still, like a print or a grid cell. Against still edges that reads as the picture creeping. Zoom and motion go to the frame and its photo together.
  • A video has an arc. It opens with the style’s own entrance, may turn in the middle, for example when Into Color drops the color, and closes with the style’s own exit, which runs longer than the cuts in between.
  • No empty first frame. The first frame is also the thumbnail and the first thing the preview shows, so a photo is already in place. Later slots may build in. The first may not start blank.
Six frames from one Instant Prints video, with photo prints landing at different angles and positions in each slot
Six moments from one Instant Prints preview. The prints land at a different angle and from a different side each time, and sometimes two share a slot.

Some rules came from specific mistakes. In Grid, I first moved all the cells as one block at each cut, so the gutters between them always stayed even. It looked tidy, but every collage then had exactly the same zoom, and the theme felt mechanical. Now each cell arrives on its own, in a quick cascade, from the edge it sits against, so no cell ever covers another. Grid also used to clear to its background and flash at each cut. On a light grid that read as the whole frame blinking, so collages no longer flash at all. That effect belongs to Beat Flash. In Beat Flash itself, one slot variant showed the same photo three times across the frame. Viewers read it as one picture cut into pieces, not as a deliberate effect, so each photo now appears once per slot.

Glossy Grid shows how far a single idea can go. It starts with one photo filling the frame. Each new slot splits the biggest cell in half along its long side. The new photo pushes in from beyond the frame’s edge while the cell it splits gives way on the same curve, so the gutter keeps its width and nothing overlaps. After four, three, four and two photos, a fresh board pushes the old one out.

The automated tests can catch a repeated layout, a cell covering another or a frame left bare at a cut. They can’t catch a boring one. So the last check for each theme is visual. I render its first twelve seconds as a contact sheet, read the frames, and only then regenerate its theme card. The cards themselves are frames rendered by the same production renderer from one shared set of generated sample photos, so every card shows its theme at its clearest and the set still looks like one shoot.

A frame budget, measured on a phone

All of this has to preview smoothly on the phone while you edit. The rule is that a preview frame stays under 33 milliseconds, which is 30 frames per second, on an iPhone with an A15 chip. Performance tests measure that on a real device for every style. If a variant costs too much, it shows less, for example fewer prints or one cutout on screen at a time, rather than dropping frames.

One example: Photo Book draws its pages on a scanned paper texture, with the paper’s grain multiplied over the page color. Drawn fresh every frame, that cost an album preview frame up to 58 milliseconds on an A15. Drawing the paper once per color and size and reusing it brought the same frame down to 31. Blurs now run at half size when the output is large. At export resolution the result looks the same and costs about half.

Themes that fit your photos

With sixteen templates, the next question is which one to try first. When you pick your photos, Dorr reads each one once on the device, using Apple’s Vision framework on a 512-pixel copy. For a video it reads the cover frame. It notes three things:

  • People: faces that take up at least 0.4% of the frame, so a crowd far in the background doesn’t count as a portrait.
  • Darkness: the average brightness of a 16 × 16 copy of the photo. Under a fixed threshold, the photo counts as dark.
  • Scene: nature, beach, city, food, celebration or pets, taken from Vision’s scene labels when it is reasonably confident.

Each template has a fit that describes what it is good at: a range of photo counts, whether it suits people-led sets, dark or video footage, and which scenes. The selection’s traits become shares, for example how many of the photos show people, and each fit scores them. The six best appear in a For You group right after the two basic themes, which have no fit and are never recommended. Ties keep the catalog order, and a recommended theme moves out of its own category, so every theme still appears exactly once. Nothing is uploaded for any of this.

Two Dorr editor screens: a For You group of suggested video themes, and the Instant Prints theme playing in the preview
Left: For You for a set of beach, pool and picnic photos, with Strips, Instant Prints, Photo Book and Pink Dream first. Right: Instant Prints playing in the preview.

One timing detail mattered more than the scoring. The first version ranked the themes after the editor had opened, so the theme row reshuffled while you were looking at it. Now the photos are read while the import progress is still on screen. The editor opens with its final order. If you later swap a photo, only that photo is read again, and the order changes only once every photo has been read.

One source for transitions

Many template cuts, and the transitions you pick by hand, use shader transitions from the open-source GL Transitions collection, which is MIT licensed. The picker now offers all 149 of them, grouped by family. Within each family the broadly usable, clean transitions come first, and the noisy or extreme ones come last.

The interesting part is how they get into an iPhone app. The originals are written in GLSL for WebGL. Dorr renders with Core Image and Metal. Porting 149 shaders by hand would mean 149 chances for small mistakes, so a generator reads each original shader byte for byte and produces the Metal version. The originals now come from one shared effects library, which is also the reference for the Android and web versions.

Moving to that shared snapshot on November 4 was a useful audit in itself. Of the 149 shaders, 80 differed from Dorr’s earlier copy only in comments, and 43 had real code changes, mostly safer math and transparency that follows the inputs. Twenty-six were new to Dorr.

The app keeps two versions of every transition. A byte-exact version exists only for tests, where its output is compared with real WebGL frames. A fast version uses the same math with the phone’s normal texture sampling and runs in the preview and the export. Tests keep the two within a strict similarity threshold. After the move, a visual audit rendered all 149 against WebGL and found the typical frame differing by a tiny fraction of one color level. The largest differences came from shaders that make noise with a sine-based hash, whose values differ between GPUs. They produce the same kind of grain, just in different places. When you pick a transition in the editor, the preview plays the moment around that cut once, so you see it in place instead of in a thumbnail.

Smaller changes in the same update

  • Videos in every theme. Video clips now play in all themes, not only some. Themes that show several cards at once play two videos at a time and show the others as stills.
  • Music that makes room. Background music already dipped under a video clip’s own sound. It now also stays down across back-to-back clips, with short fades between levels instead of jumps.
  • Browse all. Themes, music, filters and effects each get a full grid view grouped by category, not only a single row.
  • Text and filters. Photo text gets 17 styles and 10 bundled Korean and Latin fonts. Three new filters arrive too: palette-knife oil paint, Roman mosaic and thread embroidery.

What I took from it

Three things from this month apply well beyond video editing. Measure instead of typing numbers in: a tempo that was “about 120” was wrong by enough to matter, and so were others. Treat variety as a rule you can test, such as never the same variant twice in a row, instead of hoping a recipe stays interesting. And look at the output the way a viewer will, frame by frame, because the tests only know what they were told to check.

Where it is now

Dorr is on the App Store and Google Play, and the browser editor is free at dorr.app. The beat-based themes come to the iPhone app first, in its next update. The shared effects library is meant to bring the same transitions to Android and the web.