Portraying N.W.A. in “Straight Outta Compton,” from left, are Aldis Hodge as MC Ren, Neil Brown Jr. as DJ Yella, Corey Hawkins as Dr. Dre, Jason Mitchell as Eazy-E and O’Shea Jackson Jr. as Ice Cube. (Jaimie Trueblood/Universal Pictures)

Movies are notoriously lagging indicators when it comes to social change. But every once in a while, a story that takes a generation to come to the big screen arrives like an urgent harbinger from the past, offering insight that feels both ancient and blisteringly new.

By rights, “Straight Outta Compton” should have arrived in theaters more than a decade ago, when the idea for a biopic about the influential late-’80s-early-’90s rap group N.W.A. first surfaced. The project has wended its way through the usual Hollywood development circles, eventually landing in the hands of director F. Gary Gray, with whom N.W.A. co-founder Ice Cube made his early music videos and the breakout comedy “Friday.”

“Straight Outta Compton,” which opens Aug. 14, benefits from Gray’s facility with keeping the action moving and from flawless casting, including the teenage Cube being played by his own son, O’Shea Jackson Jr. And, unsurprisingly for a film whose producers include band co-founders or their relatives (Cube, Dr. Dre and Eazy-E’s widow, Tomica Woods-Wright), the story engages in a fair amount of self-mythologizing and uncritically reproduces the mi sogyny for which N.W.A. was known.

But at its best and most timely, the film bristles with Gray’s personal knowledge of South Central Los Angeles, where he grew up at West 126th Street and Normandie Avenue; where N.W.A. and their peers came of age during the crack cocaine and gang violence epidemic; and where they were routinely harassed by Los Angeles police officers, who would aggressively patrol the community with helicopters, stop-and-frisks and vehicles outfitted with battering rams, with which they mowed down suspected crack dens.

“I remember thinking, ‘Wow, do these guys have a camera on our block?’ ” Gray said during a recent phone conversation, recalling the first time he heard N.W.A. “They were rapping about things that I experienced firsthand or witnessed firsthand, and I was shocked. I was also entertained. I thought it was funny and real and honest and refreshing.”

When N.W.A. released their debut album, “Straight Outta Compton,” they immediately became lightning rods for a full-scale moral panic: Their profane, belligerent lyrics to songs with such titles as “F--- tha Police” and “Gangsta Gangsta,” critics contended, fomented violence and antisocial behavior and were dangerously influential with young fans. N.W.A. records were slapped with parental warning stickers and banned in some venues; even sophisticated rap critics drew a line between the unfiltered animus of N.W.A. and the more explicitly political work of such contemporaries as Public Enemy and KRS-One.

“Straight Outta Compton” the movie questions such distinctions, with scenes that are painful to watch not only for the grim memories of the period they bring back, but also as reminders of what hasn’t changed. In one of the film’s most pivotal scenes, the band is taking a break outside during a recording session and are set upon — for no reason — by a particularly bullying cadre from the LAPD. Slammed to the sidewalk, their faces ground into the cement, they are released only when their white manager intercedes on their behalf. Shortly thereafter, N.W.A. records “F--- tha Police,” the song now contextualized not as an anthem of irrational violence, but as a raw, brutally honest expression of impotent rage.

Interestingly enough, “Straight Outta Compton” arrives in theaters on the heels of a movie that makes several of the same points, albeit in dramatically different ways. “The Stanford Prison Experiment” dramatizes a famous psychological study conducted by Stanford psychology professor Philip Zimbardo. In 1971, Zimbardo, played in the film by Billy Crudup, recruited 24 young men to play inmates and guards in a simulated prison he set up on the empty floor of a campus building.

Chosen at random, the men playing corrections officers were given sunglasses, uniforms and billy clubs, which they began to wield with macho force almost from the moment they put them on. The subjects playing prisoners were forced to wear dresslike gowns, hide their long hair under pantyhose caps and refer to themselves only by number.

Within days, the imitation jail had descended into a near-riotous squalor of mental and emotional disintegration. In fact, the subjects of the experiment were being so traumatized by their experience that Zimbardo called the study off a week early.

The community N.W.A. wrote about didn’t have that luxury.

The Stanford findings wound up contributing significantly to the understanding of the abuse of power and the fragility of identity. With “Straight Outta Compton,” N.W.A. simply gave voice to a collective sense of injustice and anger, amplifying it through their era’s most powerful cultural language.

Thirty years later, that language has changed. The gangsta rap that N.W.A. helped to create has become a commodified corporate product. And, in a fascinating evolution, outrage is increasingly being channeled through the technologically driven grammar of sound, image and movement. The realities once captured through rap — what Public Enemy’s Chuck D. called “the CNN of the ghetto” — are now being conveyed visually, by way of cameras mounted on dashboards and on police officers, or with iPhones carried by citizen documentarians.

“Straight Outta Compton” anticipates this trend as well when it revisits the case of Rodney King, whose beating at the hands of LAPD officers in 1991 was captured on a witness’s VHS camera. That video was eventually bookended by searing footage of the riots that engulfed South Central L.A. when the officers who beat King were found not guilty of assault.

Today, we’re awash in similarly galvanizing images, with every week seeming to produce a new outrage candidly filmed and instantly distributed and exhibited via social media. For a generation raised on the ragged, spontaneous aesthetic established by “The Blair Witch Project” and refined on YouTube, the images are entirely of a piece with their cultural lexicon. Whether it’s gratuitous rudeness during a routine traffic stop or an initially polite encounter that gives way to sudden, impulsive violence, these short narratives are propelled by fear, mistrust, structural racism and impunity that would surely be as familiar to the denizens of South Central, Ferguson and Cincinnati as to Zimbardo and his research subjects.

Gray, for one, welcomes the new technology-driven transparency. “I really am optimistic,” he said, adding that N.W.A. “had the courage to stand up and shine a light on excessive force and the relationship with law enforcement with their music. I think the [images] we’re experiencing week after week, month after month, are going to put so much pressure on our leaders [and] on law enforcement [that] it’s going to force change. . . . People are going to focus on real solutions, not just burn a city down, not just picket.”

If rap expressed long-simmering latent rage, today’s found-footage vernacular invites deeper understanding of why rage is justified. Catharsis and symbolic defiance have given way to hard evidence and insistence on substantive change. It’s as if the vivid, imagistic soundtrack that N.W.A. provided for life in South Central has a canon of real-time verite short films to go with it.

Perhaps Gray was prescient when he wondered whether N.W.A. had a camera on his block at West 126th and Normandie. Now there are millions of cameras, on millions of blocks, all over the country. The CNN of the ghetto has morphed into the urgent, radically decentralized cinema of the streets.