The tricked out red Subaru WRX weaves in and out of lanes, shifts gears, bursts through imperceptible gaps between bumper-to-bumper traffic, jumps barriers, and skids around obstacles like a lucky drunk on ice. The opening chase sequence of Edgar Wright’s new film, Baby Driver, would be a masterclass in stunt choreography even if it weren’t set to music. But every tight turn and spin-out is timed to the beats and rhythm of The Jon Spencer Blues Explosion’s song “Bellbottoms,” an incredible feat of action planning that began six years before the cameras ever rolled.

“The first thing I did when I was writing back in 2010 was start plotting out the car chase to the track, literally mapping out and using the music as the guideline,” Wright, who first conceived the movie back in the mid-‘90s, tells Inverse. “You start mapping it out based on the song: Okay, here’s where they take off. Here’s where they do a big turn. Here’s where other cars crash. Here’s where they go into this alley. Here’s where they run into six police. Here’s where they get onto the freeway. Here’s where a helicopter starts chasing them.”

Wright’s movie stars Ansel Elgort as the titular Baby, a music-obsessed getaway driver who possesses savant-like skills behind the wheel that he’s forced to pay off a considerable debt. There are five main car stunt sequences, with two especially elaborate and extensive chases across the city of Atlanta and its surrounding network of highways. With the music selected and sequences outlined on paper, Wright then began drawing out storyboards to help visualize each and every stunt, and then “edited those storyboards to the song,” to create what’s known as an animatic.

Only when he completed that painstaking task did Wright begin to congregate with the stunt coordinators and other crew members. The filmmaker brought together a team of disparate experts to plot out the complicated, precision-timed chases that he was determined to shoot on location in Atlanta. Wright estimates that 95 percent of the movie was shot in-camera, with CGI utilized for just a few touch-ups and quick shots.

“He was so prepped; he had so much of the film already boarded through animatics and knew every aspect of the film so well,” Darrin Prescott, the film’s second unit director and car action expert, says. “I love to do things in-camera as much as possible, and that was a big ask from Edgar.”

During pre-production, Wright also consulted with a modern master of practical automotive action: director George Miller, whose 2015 film Mad Max: Fury Road took on-location car chases to a bonkers level of visceral thrills. The two filmmakers met during Miller’s promotional tour for Fury Road, and after a screening and Wright-hosted Q&A, they had dinner. Wright and Miller stayed in touch afterward, and the elder writer/director offered up some insight that helped shape the production of Baby Driver.

“He recommended the particular rig that we used — it’s called the Pursuit Crane, which is a camera crane on a car for shooting car chases,” Wright says. “It’s rigged on a smallish car, and it can weave in the traffic with the other stunt cars, and you get these amazing shots. A lot of those shots in the movie, where you’re really low to the ground and close to the cars as they’re coming ‘round corners and weaving in between, that’s all from that same arm, and that’s the same one they used on Fury Road.

Miller and Wright stayed in touch, too. “In fact, actually, after I finished the first edit of the movie I showed it to George,” Wright said. “I’ve been very lucky to get George Miller’s input.”

Lily James, Edgar Wright, and Ansel Elgort prep on the set of 'Baby Driver.' Sony Pictures

Practically speaking, the first task was actually getting the clearance to shoot the chases both downtown and on the highway. The first chase takes Baby — along with co-conspirators played by Jon Hamm, Jon Bernthal, and Eiza González — in and out of the city. “You go through about 20 city blocks, then the freeway, and then back into the city again,” Wright recalls. “It’s a Herculean task to clear all those locations.”

Prescott and his team had to fan out across Atlanta to scout out locations that matched Wright’s vision and could feasibly host the stunts. The booming downtown didn’t exactly make for a viable rehearsal space, so the second unit director’s crew would measure out the locations and perform the stunts on the Atlanta Motor Speedway, filming them on a camera attached to Prescott’s rental car. Paul Machliss, one of the editors on the movie, then cut that footage into the updated animatics, which helped to further time out the action.

“We could see how the stunts would flow with the music and where they fit and where they didn’t,” Prescott explains. “In an animatic, you can drift a turn in a car and it could take 4 seconds, but the reality with a real car on a real street is maybe 15 seconds. So because you’re choreographing to the music, you have to make that time up somewhere else.”

Knowing precisely which shots they needed to get was critical for a film being shot in a busy city instead of a Hollywood backlot.

“The stuff in the city was an enormous task. It’s like having a traveling circus because we haven’t got Michael Bay money to shut down entire freeways or city centers,” Wright says, laughing. “With the city center stuff, you’d be doing it two or three blocks at a time, so that whole first sequence you’re basically moving through the passage of the chase and the police are opening and closing things as you go around.”

And even when streets were closed, performing high-speed stunts on historic streets posed particular risks for the crew.

“There’s a shot in the trailer, we call it a ‘180 in and 180 out,’ where Baby comes down an alley and [drifts around] trucks, and we did it in a practical location,” Prescott says. “The Georgia State Bar building was on one side, and another building was on the other side. It’s nerve-wracking, because if the stunt driver loses it and stacks it into the building, we have major issues. A different movie would make it on green screen and add the buildings in later.”

Wright initially wrote the movie to take place in Los Angeles, a massive freeway system with small buildings and strip malls peppered in between on-ramps. The decision to set it in Atlanta meant adjusting to the Fulton County infrastructure. “The first chase is on the I-85, which is the main freeway in Atlanta, and you cannot shut down the I-85,” Wright says with a laugh. “That’s impossible, but what you can do is have a police motorcade, which is miles wide.”

The production was given a very limited time to nail the intricate, high-stakes stunts on the I-85, which sees about 200,000 drivers per day in the Atlanta area. “We were given a Sunday that didn’t have any ball games, and they said, ‘we’ve got 6 a.m. until 2 p.m. and then that’s it’ — 2 p.m. was a hard kick-off.”

And so the production had just eight hours to nail a sequence that includes high-speed jumps, risky drifts, and barrier jumps into heavy traffic.

“We didn’t have time to rehearse on the freeway, so at five in the morning, we’re in the parking lot at base camp with little Matchbox cars with all the stunt guys,” Prescott remembers. “We basically do a Matchbox car pattern of what we want to do out on the street, and then everyone stands up and walks as if they’re in their car, and we weave through them.”

Jon Hamm and Edgar Wright get focused on the set of 'Baby Driver.' Sony Pictures

When it was time to shoot, Atlanta’s police department went all-out to help make the most of the tight window.

“We had police cars on all lanes of the freeway, 50 stunts cars, actors and the camera cars, all in the middle of what is called The Bubble,” Wright recalls, marveling at the scope of the production. “This big flotilla of cars is going down the freeway at 70 miles an hour shooting, and sometimes the actors are in the car as well, and it’s insane.”

Prescott was charged with making sure the precision stunts went off without a hitch, a high-stakes task given that each shot set up, on what he called the “armageddon, post-apocalyptic interstate,” took about an hour to reset.

“The stunt driver for Baby is waiting way up ahead on another exit, and as we come into view, he’s got to come down and slide into traffic. And then we had to choreograph the entire traffic pattern in one move, because once we traveled the extra three miles, we all had to exit off the freeway,” he recalls. “You’d see as we’d get toward the end of our chase the wave of public traffic just gaining on us like a tidal wave. If we had crashed a bunch of cars on that freeway, it would have been a massive mess.”

Baby's Subaru WRX is chased by the cops. Sony Pictures

The other big freeway scene, with Jamie Foxx and the actor/musician Flea as Baby’s passengers, was a little bit less of a time crunch, as Atlanta shut down a segment of the freeway called the Buford-Spring Connector. But the stunts themselves were no less challenging, with one in particular proving hard to crack.

Baby drives a black Avalanche SUV down a crowded highway, which is bashed into by a pursuing Dodge RAM. The Avalanche skids into a massive truck, with the hood of the SUV getting stuck beneath a semi’s haul. The SUV is dragged down the road, providing a terrifying sight for audiences and anyone that’s ever been stuck behind a massive long-haul rig.

To pull that off, Wright turned to an effects wizard named Mark Byers, who created a device that connected the two SUVs together and then, when triggered, flipped Baby’s Avalanche on its side so that it would slide beneath the truck.

“When it gets pushed underneath the truck, it’s actually on a rig,” Wright explains. “When you see that shot, when they’re going underneath the car, the Ram and the Avalanche are linked together, and it’s this amazing feat of a hydraulic rig. You’re literally slamming one thing under another, but it’s all connected, which is crazy.”

The actors spent plenty of time in the passenger’s seat during these stunts, so that Wright could film their reactions. It was all safe, but still a bit terrifying for the performers, which Wright used to maximum effect.

“There’s something about those sequences that it’s like, ‘Why does it feel more exciting? It’s only one car and some police cars, so why does it feel more exciting than some other films?’” he asks rhetorically. “It’s because you can just tell on the actors’ faces. You can see their hair moving and their bodies moving, and you can see them sliding around on their feet. It feels real because it is real.”

Baby Driver is out in theaters on Wednesday.