Straight Outta Compton cast
O'Shea Jackson Jr with Corey Hawkins and Jason Mitchell, who respectively play Dr Dre and Eazy-E in the biopic Kevin Winter/Getty Images

In an ironic turn of events, filming of the N.W.A biopic Straight Outta Compton was halted when gunfire erupted near the movie crew.

The camera crew were recently preparing to film scenes outside the Compton Courthouse in California when a drive-by-shooting, unrelated to the film, took place.

According to TMZ.com, eyewitnesses said the gunfire broke out outside the courthouse last week after a group of local men, not actors, flashed gang signs at a passing car.

The gunmen were not targeting the crew, but the bullets reportedly came dangerously close to where the crew was setting up, leaving the crew and cast members shaken.

One person, who was not involved in the movie, was hit and collapsed next to the set. They were taken to hospital and are now said to be in a stable condition.

The Los Angeles County Sheriff's department is investigating the incident and has not yet confirmed if it was gang related.

Filming of Universal's biopic about the pioneering gangster rap group's rise to fame in the 1980s, resumed this week, and will continue in the same area in Compton, despite the crew allegedly being worried about their safety.

Straight Outta Compton is being directed by F. Gary Gray (Friday, The Italian Job) and produced by Ice Cube, Dr Dre, Tomica Woods-Wright (Eazy-E's widow) and Matt Alvarez (Ride Along).

The title comes from N.W.A's debut album which burst onto the music scene in 1988 with a controversial view of the police and violence in gang-ridden South Los Angeles.

While N.W.A gained the reputation of being the "world's most dangerous group", the album sold more than 3 million copes and was certified double platinum in 1992.

The movie is set for release 14 August 2015.