Ansel Elgort as Baby in "Baby Driver." 

Wilson Webb

One of the best moments in “Baby Driver” came about because director Edgar Wright got something wrong.

The heist movie, which opens Wednesday, centers on Baby (Ansel Elgort), a getaway driver working for a crime boss (Kevin Spacey). To overcome his tinnitus, Baby is constantly plugged into music; his dangly white earbuds are as much a part of him as his ability to spin a car around a corner. Wright, the visionary behind “Scott Pilgrim vs. the World” and “Shaun of the Dead,” decided to set much of the movie to music—not just in the sense of a traditional soundtrack, but in that the visuals of the film would exactly match the beats of the songs pumping through Baby’s head.

That meant almost everything had to be painstakingly choreographed. Though sometimes even painstaking isn’t careful enough.

For the film’s second car chase, Wright storyboarded the scene and edited it to the frenzied rhythm of The Damned’s 1977 punk-rock blast “Neat Neat Neat”—all 2½ minutes of it.

“Once I’d cut the whole sequence, I remembered that my director of photography had said, ‘Oh, you haven’t left enough time for the action—you’re going to run out of song.’ I did not heed his advice, and of course he was 100 percent correct.”

So now Wright had too much movie, but he refused to substitute a longer song or give up his music-fueled idea.

Get news headlines sent daily to your inbox

“In that sequence, there was a moment where they have to abandon their car and get into a new one,” he says. “So on the last day of shooting, I added a shot where Ansel rewinds the song back to the last verse before playing it again. It was exactly what the character would do in that moment if his perfect getaway had been ruined—when he gets into a new car, he literally gets back on track by rewinding it.”

The ambitious syncing of soundtrack to action was tough, but it focused Wright’s direction—and gave him a concrete idea of when and how to end each scene. Knowing that no scene could be longer than its song kept things manageable.

“The opening sequence (a car chase set to The Jon Spencer Blues Explosion’s ‘Bellbottoms’) was extremely complicated,” Wright says, “but at least you knew at the end of the day it was going to be exactly five minutes long.”