ResearchOpen sourceDatasetsBlogEventsCareersTeamContactTry the moment search demo

Your timestamps are lying: aligning speech to shots within 25 ms

A third of the videos uploaded to VideoFinder have audio and video that disagree by more than one frame. Almost none of that is the speech model’s fault. This is the story of how we found out, and how sarana rebuilds the timeline a viewer actually sees.

Speech-grounded search sounds simple. Run a speech recogniser, get words with timestamps, index the words next to the visual segments, done. A query like “where she says the deadline moved” should land on the half-second where the words are spoken, and the result card should show the right frame.

For most of 2025 it didn’t. Results were nearly right: the thumbnail showed the speaker a beat before she started talking, or the moment preview started mid-word. Nobody filed a bug, because nothing was obviously broken. But when we measured it properly, the median offset between a word’s timestamp and the frame where a human said it began was 92 ms, and the tail was much worse.

Measuring the problem first

Before touching any model, we needed ground truth. We took 12,000 uploads with speech and asked annotators to mark, frame by frame, the onset of three distinct words per clip using vf-annotate. That gives us a human-perceived timeline: what a viewer sees and hears in a standards-compliant player.

Then we compared it with the timeline our pipeline believed in. The result:

Audio–video offsetShare of uploads
Within one frame (≤ 33 ms)69%
1–3 frames17%
3 frames – 120 ms7%
More than 120 ms7%

Thirty-one per cent of uploads had an offset larger than a frame. Seven per cent were off by more than 120 ms, which is where lip-sync errors become visible to most people. The speech recogniser was rarely the cause. When we re-ran recognition on audio extracted with correct offsets, its word boundaries were within 20 ms of the human marks almost every time.

Where the time goes

We grouped the misaligned files by cause. Four culprits explained nearly everything.

1. Encoder priming

AAC encoders emit a block of priming samples before the real audio starts: commonly 1,024 or 2,112 samples. At 48 kHz, 2,112 samples is 44 ms. Well-behaved files signal this delay, either in an edit list or in an iTunSMPB-style tag, and players skip it. Our decode step did not, so every word in those files was 44 ms late.

2. Edit lists

MP4 and MOV files can contain an edit list (elst) that says, in effect, “start presenting this track at media time X”. Editors use them for trims without re-encoding; phones use them to hide startup frames. If you decode the raw samples and ignore the edit list, you are watching a different video from the one the uploader exported. About 4% of our uploads had an edit list on at least one track, and roughly half of those shifted audio relative to video.

3. Variable frame rate

Phone footage is often variable frame rate: the camera delivers 29.6 frames per second in one second and 30.1 in the next. Our sampler assumed a constant rate and converted frame indices to seconds by division. Over a three-minute clip that drift reached 400 ms. The fix is boring and absolute: always use presentation timestamps, never frame counts.

$ ffprobe -v error -select_streams v:0 \
    -show_entries packet=pts_time -of csv=p=0 upload.mp4 | head -4
0.000000
0.033344
0.066700
0.100333        # 33.6 ms, not 33.3 — VFR

4. Re-timed exports

The last group is the hardest: footage that was slowed down or conformed between frame rates (for example 25 to 23.976) without the audio being processed in the same way. The container is consistent; the content isn’t. Here no amount of metadata parsing helps, and we have to fall back on the signal itself.

What sarana does

sarana (Finnish for “hinge”) is the tool we built to fix this. It runs in three stages, and the first two are pure bookkeeping.

Timeline reconstruction. We parse the container ourselves rather than trusting a decoder’s defaults: every track’s edit list, time base, composition offsets and priming signals. The output is a mapping from each track’s media time to presentation time, the same thing a compliant player computes. This stage alone fixed 82% of the misaligned files.

Forced alignment on the corrected audio. With the audio placed correctly, we align the transcript to it. For uploads with existing subtitles we align those; otherwise we use recogniser output. Alignment works on phonemes, which matters in Finnish, where long compound words would otherwise get a single, imprecise boundary.

Shot-aware snapping. This is the only part that is research rather than plumbing. Edited video tends to cut on speech: an editor starts a shot just before a sentence or ends it just after. When acoustic evidence for a word boundary is weak (music under the dialogue, a soft onset), we allow the boundary to move to a nearby shot cut detected by kehys, within a small window and only if the move improves the alignment likelihood. The constraint is deliberately conservative; snapping too eagerly makes things worse on documentary footage, where cuts and speech are independent.

Most “model errors” in our speech pipeline were container errors wearing a model’s clothes.

Results

On the 12,000-upload set, median alignment error dropped from 92 ms to 23 ms, and the share of uploads off by more than 120 ms fell from 7% to 0.6%. Speech-grounded retrieval on HETKI-Speech improved by 6.8 points R@1, simply because the right half-second now contains the right words. The details are in our NoViS 2025 paper.

The remaining errors are mostly re-timed exports. For those we now estimate a linear drift between the audio and the lip movements of on-screen speakers, but we only apply it when confidence is high. When it isn’t, we would rather be honest and mark the clip’s speech timing as approximate.

Things we would tell our past selves

  • Measure against what a viewer perceives, not against what your decoder returns. They are different timelines.
  • Never convert frame indices to seconds by division. Carry presentation timestamps through the whole pipeline.
  • Log the container facts (edit lists, priming, frame-rate variability) for every file. When something drifts, that log answers the question in minutes.
  • Test with ugly files. Our regression suite now includes 340 deliberately broken exports collected from real uploads, with consent.

sarana 0.9.4 is available under Apache-2.0. If you have a file that it gets wrong, we genuinely want it. Bring it to the January meetup, where speech and timing are the theme, or write to us through the contact form.

Jussi Pelkonen

Research Engineer, Speech & alignment. Maintains sarana, our speech-to-shot aligner. Has opinions about MP4 edit lists that he will share at length.