David Ayer's "End of Watch," in Los Angeles Grit LOS ANGELES - Turning left, David Ayer swings his black Lexus up Martin Luther King Boulevard, through the battered area that used to be known as South Central. One side is lined with the alleys and ratty bungalows in which, last July, Mr. Ayer shot a movie about the underside of Los Angeles - his third such effort as a director - called "End of Watch." On the other side is a liquor store, where, he mentions, his wife and her sister used to work and where the sister was robbed at gunpoint. There are easier places to film. But, Mr. Ayer said, "the street signs would be wrong." Getting it right has been a near-obsession both for Mr. Ayer, who grew up about two miles from here, on West Adams Boulevard, when it was discovering crack cocaine in the 1980s, and for a pair of actors, Jake Gyllenhaal and Michael Peña, who are not from the neighborhood but decided to learn it on a quest for purity in the dirtiest of film genres: the L.A. cop drama. Whether they have succeeded, the audience and critics will tell when Open Road Films releases the picture on Sept. Until then Mr. Ayer and his colleagues are still working through the emotional impact of their encounter with streets that have figured in hundreds of films: "Colors," "Heat," "Boyz N the Hood," "To Live and Die in L.A.," "Chinatown" and "The Long Goodbye," among a litany that stretches to Samuel Fuller's 1959 film "The Crimson Kimono," and beyond. But those settings are now seen less often, as local grit has given way to computer effects, and movies are increasingly set in states that pay subsidies larger than California does. For Mr. Ayer the streets of Los Angeles are something of an addiction. He lived on them for a time, having been thrown out of the house by his parents, he said. Later he began to write his experiences into stories during service on an attack submarine in the Navy. Back in Los Angeles by the 1990s, Mr. Ayer did some fix-up work on the home of a screenwriter, Wesley Strick, who encouraged him to write scripts - and he found his calling. Mr. Ayer was among the writers of "The Fast and the Furious," and he wrote "Training Day." Both were set here. He then directed two Los Angeles cop films, "Harsh Times" (2005), with Christian Bale, and "Street Kings" (2008), with Keanu Reeves. Neither was a hit. As Mr. Ayer looked for a next project, however, a friend advised him to stick with his roots and tell another cop story. "Explaining why I shouldn't, I realized why I should," Mr. Ayer said. He put aside his fear of being type-cast as the go-to guy for the Los Angeles police genre to pursue what he now calls "the ultimate cop movie." It aims to transcend clichés that have piled up over the years, he explained, by portraying a pair of local patrol officers, played by Mr. Gyllenhaal and Mr. Peña, who are not crazed or corrupt. Instead they bring fierce mutual loyalty and an unexpected sweetness to their pursuit of goodness in a bad world. The shock value in "End of Watch" lies as much in its intimacy as in its insider's look at Mr. Ayer's own streets. Those streets, he said, have become more stable through the years, as a cellphone culture took drug dealers off the corners, and the police force began to mirror the city's changing ethnic makeup, with more Hispanic and Asian officers. Even the term "South Central," stigmatized by crime, is now out of vogue; Mr. Ayer shot in a zone known as Newton. Point of view becomes especially important in "End of Watch." In effect, Mr. Gyllenhaal shot much of the film himself, through a specially constructed camera mounted on his chest. A conceit of the movie has him working on a film project as part of his continuing education. Other scenes find Mr. Gyllenhaal and Mr. Peña sharing endless banter - funny, sad, trivial, profound - that was shot, in the style of a stage play, in a single day. "End of Watch" was written and filmed with unusual speed. Mr. Ayer finished the script in just six days, late in 2010. It was based partly on stories told to him by a police officer friend, who, among other things, described a pact under which patrol partners each promised to kill the other and care for his family if either were left hopelessly incapacitated. The film was shot in about 22 days, though it has a large cast of supporting characters. It also includes action scenes that required John Lesher, one of its producers, to hoof through some of the city's less secure pathways in search of settings. "I walked every alley," Mr. Lesher said, referring especially to preparations for the chase scene that opens the film. Yet Mr. Peña and Mr. Gyllenhaal spent a long five months in training, assisted by the Los Angeles County Sheriff's Department, police departments in Los Angeles and Inglewood, and others. On the first of his many police ride-alongs, Mr. Gyllenhaal said in a telephone interview, the squad car arrived on the scene of a drug dealer's murder. Later Mr. Gyllenhaal and Mr. Peña endured a controlled burn by fire officials in Orange County, in order to acquire what Mr. Ayer calls "muscle memory" that would help them to play a scene in a flaming house. In an unusual exercise with live ammunition, the actors learned to shoot past each other in what proved to be a lesson less in police tactics than in bonding. "This guy has my life in his hands for real," Mr. Gyllenaal recalled thinking. I realized, I finally knew what we were dealing with. Mr. Ayer said the actors were "safe all the time" during the exercise at a training ground in Burbank. Mr. Ayer, of course, is now dealing with the trepidation of a filmmaker who has again reached deep into a genre that twice has left him without an audience. After making "Harsh Times," which had just $3.4 million in domestic box office receipts after its release by MGM in 2006, Mr. Ayer was stuck with a $2 million loan for production costs, secured by his home in the Los Feliz area of Los Angeles. Mr. Ayer saved his home by taking studio writing jobs, he said. And now, similarly, he is working on the screenplay for a remake of "Scarface," which is being developed by Universal Pictures. Mr. Ayer is also expected to direct "Ten," to be distributed by Open Road and starring Arnold Schwarzenegger in a story about corrupt federal anti-drug agents. But it is "End of Watch" that will have to settle Mr. Ayer's personal score with the L.A. cop film, a cinematic form that is fading from studio schedules but still fascinates those who know the city and its ways. "I wanted to nail this genre," Mr. Ayer said as he swung through Vernon, an industrial zone, and across the Los Angeles River, back toward downtown, on a circuit he has ridden since his teens. I wanted to nail it.