“Top Gun: Maverick” filmmaker Joseph Kosinski came to Formula One like many Americans: “Drive to Survive.”

In that popular Netflix series, he saw the potential for a cinematic event, full of immersive thrills, the high stakes of the competitive racing world and the idea that your teammate could be your greatest rival.

“I don’t think there’s any other sport that’s quite like that,” Kosinski said. “It’s ripe for drama.”

The movies have loved car racing since their earliest days, and the popularity of F1 has exploded in recent years. Giving it the “Top Gun” treatment made sense. But it would take nearly four years for that dream to become “F1,” which is speeding into movie theaters June 27.

It was a complex operation that would involve unprecedented coordination with the league, groundbreaking innovation in camera technology, and letting one of the biggest stars in the world, Brad Pitt, drive a real race car at 180 miles an hour on film.

Getting F1 on board

By the time Kosinski and producer Jerry Bruckheimer approached the league, Pitt had already agreed to star, and they’d decided to go with Apple to help make the movie at the level they needed, with the guarantee of a robust theatrical release (which Warner Bros. is handling). Then came the Formula One meeting.

“When you come in, the first thing they think is you’re going to make them look bad,” Bruckheimer said. “I went through this when I went to the Navy the first time on ‘Top Gun.’ ”

There were many concerns: About anything going wrong, accidents and the question of the villain. But, the filmmakers explained, this story wasn’t about a villain. It’s a competition between two drivers — a younger driver (Damson Idris) and an older driver (Pitt) trying to make him better.

Bruckheimer said it took almost a year to get the league on board, and then they had to go around to the individual teams to explain it to them as well. But once everyone bought in, they committed and opened their world to the filmmakers.

“The amount of, let’s say, conversations regarding things not related to the actual filmmaking has been massive just from a coordination point of view,” Kosinski said. “But there’s no way we could have made this film without that partnership with Formula One.”

Among the things they got to do: Build a garage at the Grand Prix for their fictional team; Drive on the track during Grand Prix weekends in front of hundreds of thousands of spectators; Put Formula One cars on the track with the film’s cars (and drivers); Have Pitt and Idris stand at the end of the national anthem in both Silverstone and Abu Dhabi; And sit in on drivers meetings and technical briefings.

“It was full-on integration of these two worlds coming together,” Kosinski said. “There’s no way the film could have happened or look like it does without that partnership. I think you’ll see the result of that on screen because you couldn’t re-create what we were able to capture by doing it for real.”

‘We’re going to need a smaller camera’

In true “Top Gun” spirit, part of “doing it for real” meant trying to create the experience in the driver seat for the audience. Seven-time champion Lewis Hamilton, who was involved in the film from the earliest days, told Kosinski that he’d never seen a film that had really captured what it felt like to be in one of those cars.

“These Formula One cars, they deal in grams,” Kosinski said. “Adding 100 pounds of camera equipment works against the very thing you’re trying to capture. It became a technical engineering project for a year to figure out how to get very tiny cameras that are IMAX quality onto one of these cars.”

Engineers were able to slim Sony cameras down to about a 10x10 cm cube. Panavision also developed a remote control that allowed director of photography Claudio Miranda to pivot the cameras left and right, which they didn’t have on “Maverick.” They had 15 camera mounts built into the cars and were able to run up to four at a time keeping the weight penalty to a minimum, and the close-ups real.

“Every time you see Brad or Damson’s face, they’re really driving that car,” Kosinski said. “It’s not being driven for them.”

When Hamilton first saw some of their racing footage cut together, Kosinski got a confidence boost.

“He smiled and said, ‘It looks fast,’ ” Kosinski said. “I was like, ‘Oh, thank God,’ if Lewis says that we’re in a good place.”

The Pitt factor

“This movie needed an icon kind of at the center of it,” Kosinski said. “It’s a big, complicated, expensive film. And I needed one of our, you know, top, top movie stars.”

Kosinski knew Pitt liked cars. Plus, he said, “I just felt like it was a role that I always wanted to see him play.”

The character is fictional driver named Sonny Hayes who was “the greatest who never was.” A phenomenon in the 1990s, he was destined to be the next world champion before an accident at a Grand Prix ends his Formula One career.

“Now he drives in every type of racing league you could imagine, but not Formula One,” Kosinski said, from Le Mans to swamp trucks. “He likes to challenge himself to a new racing league and master it, but then he walks away.”

The audience meets him driving the midnight shift at the Daytona 24-hour race where he meets his old teammate and now Formula One team owner (Javier Bardem) who asks him to come back to help them win one race to save them from being sold.

“It’s a story about a last place team, a group of underdogs, and Sonny Hayes in his later years having one more chance to do something he was never able to, which is win a race in F1,” Kosinski said.

Pitt trained for three months before cameras started rolling to get used to the physical demands of the precision vehicles. He and his co-star really drove the cars at speeds up to 180 mph, and sometimes in front of a couple hundred thousand people.

The perfect summer blockbuster?

The film, everyone has acknowledged, was enormously expensive. They had the advantage of advertising on the cars, which helped offset some of the costs, but the operation was akin to building a real F1 team, Bruckheimer said.

They built six cars, which they transported all around the world along with production. But it was much less than the $300 million figure going around, both Kosinski and Bruckheimer said.

The biggest question is whether audiences will turn out in blockbuster numbers.

And the two men promise you don’t need to be an expert or even a fan of the sport to enjoy the film, which will teach you everything you need to know.

“It’s emotional, it’s exciting, it has humor. It’s got great music with a Hans Zimmer score and a bunch of phenomenal artists,” Bruckheimer said. “We hope it’s a perfect summer movie.”