The thin blue line welcomes its newest members.

It’s not that Michael Peña wants to see flashing blue lights in his rearview mirror, but after filming “End of Watch” — in which he plays a Los Angeles police officer — he’s a little more sympathetic to the cop carrying that ticket book.

“Nine times out of 10, it’s my fault,” he says. After making the film, “one, my viewpoint changed, and I was able to take responsibility for all the times I screwed up. Two, they’re trying to help out.”

Possibly the most realistic cop film ever, “End of Watch,” which opens Friday, is filmed in a documentary style (similar to “The Blair Witch Project” but without the motion sickness). Peña plays Mike Zavala, whose partner, Brian Taylor (Jake Gyllenhaal), is constantly filming their activities, either with a handheld camera or tiny ones clipped to their uniforms. (The conceit doesn’t work out entirely; there are times when the images clearly come from a camera outside the story space.) For the audience, the found-footage style lends a sense of realism and gives the dialogue an improvisational feel; for the actors, it meant there was no time to slack off.

“I didn’t know when I was getting shot, so I had to be in character the entire time,” Peña says.

That meant being very detail-oriented: Cops everywhere would sneer if Peña and Gyllenhaal, say, pulled their weapons with their fingers on the triggers (they’re supposed to be alongside the trigger until you actually want to shoot something). Writer-director David Ayer (who also wrote “Training Day”) had the pair go through five months of rehearsal, which included interviews, weapons training and ride-alongs with real officers, along with the character work that’s more typical of the rehearsal period.

“I actually got a couple of cops drunk,” Peña says. “Well, they weren’t drunk, it was just two or three beers. But what I learned was, when they think of a neighborhood, they think of the good parts. Then they can really see the [people] who are bad, and those are the ones they want to keep away.”

So Peña won’t complain the next time he gets a speeding ticket — and, after the film comes out, he’ll probably be able to drink for free in any police bar in the country. Assuming he still has the cop skills.

“I can still clear a room,” he says. “I still know how to do the handcuffs.”