Much has been made of “Birdman” director/co-writer Alejandro G. Inarritu’s conceit of making a movie that seems to be one continuous, two-hour shot. The actual filming consisted of long takes edited to look seamless. Each sequence offered challenges, but the Times Square scene introduced special difficulties.

The scene: Actor Riggan (Michael Keaton), wearing only his underpants, gets locked out of Broadway’s St. James theater and has to walk past gawking fans in Times Square to get to the theater’s main entrance.

Logistical challenge: The production couldn’t afford to shut down Times Square or populate it with paid extras, so it risked filming with real onlookers. “We worried about security,” Inarritu says. Plus there was a fear someone would stare at the camera or walk into the scene. “There was no possibility to cut away if that happened” since it was one long take, the director notes. “If any scene in the film failed, I could not remove it or manipulate it. It had to be perfect.”

Creative challenge: The scene had to show Riggan’s emotional, manic state of mind, says the filmmaker. “It had to be intimate but spectacular — massive.” Inarritu and cinematographer Emmanuel Lubezki worked out the logistics of the scene, which takes place at night, and decided which angle of Times Square offered the best lighting. The camera starts with an over-the-shoulder shot, then moves laterally with Keaton, then moves in front of him, to show his reaction as people recognize him and want to take his picture.

Prep: A week before filming, Inarritu and Keaton walked through the scene. On the afternoon before the first take, a fully dressed Keaton walked through it with the director.

Filming: There were four takes, starting at 8:30 p.m. If the shot was too early, the lighting wouldn’t work; too late, the crowd would thin. Crew was kept to a minimum, to draw as little attention as possible. Keaton’s movements were accompanied by only four people: Lubezki; the focus puller; the boom operator; and the digital imaging technician. Eight production assistants worked on crowd control. Inarritu was close by; for two of the four takes, he shot Keaton with his smartphone for footage used in a subsequent scene in which Emma Stone watches the incident on YouTube.

Distraction: To divert attention from the camera, Inarritu hired a group of street drummers who danced and performed nearby. “All the tourists wanted to look at these drummers. A half-naked man in Times Square? They’ve seen that before.”

Discarded solution: “The Amazing Spider-Man 2” had built a set of Times Square. The “Birdman” team briefly debated using that and filling it with extras, or simulating a crowd via CGI. “But it would have looked terrible,” Inarritu says.

Post-filming challenge: Times Square is full of prominent brand advertising, usually in neon. The “Birdman” legal team had to get permission from each brand to be used onscreen.

The result: Eye-popping and emotionally like a Freudian nightmare.