Oscar and his friends have a run-in with Bay Area transit officers in a scene from “Fruitvale Station.”

You know how “Fruitvale Station” ends because of how it begins. Shaky cellphone footage from a Bay Area train station shows a group of black men sitting on the ground, surrounded by transit officers. One gets up. There’s a scuffle and he’s pushed back down. Another guy tries to get up and is pushed to the floor, facedown. There’s a lot of shouting. Then there’s a bang, and Oscar Grant is dead.

Oscar’s final day is the subject of the based-on-true-events “Fruitvale Station,” which opens Friday and was written and directed by 26-year-old first-timer Ryan Coogler.

The real-life Oscar Grant was fatally shot by a transit cop in 2009 at the age of 22, and the images that start the movie are from cellphone video of the actual shooting. Coogler had no problem giving away the ending right at the start.

“There are so many examples of stories that we know the endings to, and we’re still interested in watching,” he says. “Think of ‘Romeo and Juliet.’ How many times has that story been told? We know the ending and it’s always super interesting.”

Because the audience knows what’s in store for Oscar (played by Michael B. Jordan of TV’s “Friday Night Lights”), even the slightest interactions in his life take on new weight. In one scene, Oscar and his friends are riding a train into Oakland when another African-American man enters the car. He looks at Oscar’s group; they stare back at him. Both sides seem ready for a confrontation. The new guy opens his backpack, reaches inside — and pulls out a set of speakers.

“They’re not sure if he’s friend or foe, and they have to have their guard up,” Coogler says. “When you’re young and especially if you’re black, you have to constantly be on guard. The people most likely to hurt you are the people who look like you. The second most likely are those people paid to protect you.”

Still, there’s lots of love in the film. Oscar is constantly calling and texting his mother, his grandma and his girlfriend, and he’s especially affectionate with his young daughter.

“People ask why Oscar says he loves somebody [when] he gets off the phone,” Coogler says. “With a lot of young males in urban environments, you never know when your last moment is going to come. So when you’re telling the people you love goodbye, you tell them you love them. Because you never know.”