How I reverse-engineer a viral video edit into code, cut by cut

By · · 4 min read

Short answer

Video Reverse Engineer (editast) is an open-source Python tool that reads a finished video and writes down how it was edited. It produces an Edit AST: every cut, transition, zoom, speed ramp and caption, with timestamps, aligned to the music’s beats and drop. It runs offline on a CPU (a 52-second trailer takes about 25 seconds) and scores 0.994 overall on its held-out benchmark. The same AST then works as a template: point it at your own clips and song and it renders a new edit with the cuts landing on the beat.

What does it actually produce?

Short-form edits follow patterns: a hook, a build, a drop, cuts on the beat, a zoom on the bass hit. I wanted to see those patterns as data, not guess them frame by frame. So editast turns a video into an Edit AST, an abstract syntax tree of the edit, like a compiler does for code:

  • media: size, frame rate, duration and aspect ratio
  • music: BPM, beat grid, downbeats, drops, energy and sections
  • timeline: sections (hook, build, drop, outro) made of shots, each with its timing, length in beats, whether it lands on a beat, and its effects and transition
  • overlays: burned-in captions, with timing for each word
  • patterns: editing rules it infers, such as “cut on every beat during the drop”
  • stats: pacing, shot lengths, the share of cuts on the beat, and the mix of effects

You get it as JSON (with a JSON Schema), as a readable .edit script that converts back to JSON without losing anything, and as an interactive HTML timeline.

How does the analysis pipeline work?

Frames are decoded with a 320-pixel long side at a constant frame rate, alongside mono audio. Then six analysers run:

AnalyserWhat it findsHow
shotsCuts, flashes, fades, dissolvesFrame differences with adaptive thresholds
motionZoom, pan, rotation, shakeFeature tracking plus RANSAC similarity transforms, with fitted easing curves
timefxSpeed ramps, slow motion, freezesHow fast the motion changes over time
lookColour grade, black and white, blur, invert, RGB split, letterboxPer-frame image statistics
textCaptions and burned-in textOffline OCR with RapidOCR, tracked across frames
audioTempo, beats, downbeats, drops, sectionsDynamic-programming beat tracking with numpy and scipy

A build step then puts it together: it groups shots into sections, lines cuts up with beats, finds the repeated patterns and computes the stats.

How accurate is it?

Checking an edit by hand is slow, so the tool tests itself. The bench command creates synthetic edits from a known AST, renders them, analyses the result and scores the match:

BenchmarkOverallCuts F1Effects F1Beats FText F1
Held-out seeds 100 to 1070.9940.9950.9820.9881.000
Seeds 0 to 30.9991.0001.0000.9931.000

On real footage, the 52-second Sintel trailer, shot boundaries scored 0.95 precision and 1.00 recall against hand labels. Across 10 car-edit YouTube Shorts with 1.1 to 9.4 million views, 73% to 97% of cuts landed on a beat, and the drop came 35% to 61% of the way into the video.

How do you reuse an edit on your own footage?

The AST works as a template. fit stretches it to a new song so the cuts land on that song’s beats and the template’s drop lines up with the song’s drop. Give it several templates and it ranks them by how little each has to change. render then builds the video from your clips:

pip install editast

editast analyze https://youtube.com/shorts/…        # JSON, .edit script and HTML report
editast show edit.json --format summary
editast render edit.json --clips ./my-clips --music song.mp3 --fit -o out.mp4

The full loop (analyse, re-time, render, analyse again) is tested end to end, so a rendered edit can be checked against the template it came from.

What doesn’t it get right yet?

  • About a quarter of speed ramps are missed on the benchmark, because speed detection is tuned to avoid false positives.
  • Long dissolves are found, but their start time is often placed a little late.
  • A dissolve into a title card is reported as a hard cut.
  • On real car edits, static-noise glitch transitions split into many tiny shots, the beat tracker can lock onto off-beats, and number plates can show up as captions.

Frequently asked questions

Can I find out which effects and transitions a TikTok or Reel uses?
Yes. Run editast analyze on the file or its URL. The report lists every cut, transition (flash, fade, dissolve, whip, zoom, spin, glitch), zoom, shake, speed ramp and caption with timestamps.
Can it copy an edit onto my own clips and music?
Yes. editast render takes the analysed edit, your clips folder and a song. With --fit it moves the cuts onto the new song’s beats and lines up the drop.
Does it need a GPU or an API key?
No. It runs offline on a normal laptop CPU; a 52-second trailer takes about 25 seconds to analyse.
How accurate is the cut detection?
On held-out synthetic edits, cut detection scores 0.995 F1, and on the real Sintel trailer it found every shot boundary (recall 1.00) at 0.95 precision.

Read the code on GitHub ↗

More articles