A US Marine Corps veteran has opened fire on a crowd of students dancing at a country and western bar in a suburb of Los Angeles, using a handgun and a smoke device to kill 12 people and wounding many more.

Terrified revellers used bar stools to break second-floor windows and jump to safety to escape the dance bar, where the gunman was later found dead. Those killed in the shooting on Wednesday local time (Thursday evening in Australia) included 11 people inside the bar and a sheriff's sergeant who was the first officer in the door, Ventura County Sheriff Geoff Dean said.

Survivors of the shooting at Borderline Bar and Grill in Southern California said the gunman, a 28-year-old US Marine Corps veteran, started shooting at the dance floor with "perfect form".

"It's a horrific scene in there," Dean told a news conference in the parking lot of the Borderline Bar & Grill. "There's blood everywhere."

He named the gunman as 28-year-old Ian David Long, and said Long had likely shot himself.

Dean said Long was an army veteran who had served in the US Marine Corps.

Police named the gunman as Ian David Long. AP

He said Long appeared to have shot at random inside the club, and had used a smoke device and a .45-calibre handgun. There was no known motive, Dean said.

The massacre was the deadliest mass shooting in the United States since 17 classmates and teachers were gunned down at a Parkland, Florida school nine months ago. It also came less than two weeks after a gunman killed 11 people at a synagogue in Pittsburgh. That, in turn, closely followed the series of pipe bombs mailed to prominent Democrats, CNN and former officials critical of President Donald Trump.

Trump said on Thursday on Twitter that he had been "fully briefed on the terrible shooting". He praised law enforcement, saying "Great bravery shown by police" and said "God bless all of the victims and families of the victims."

People walk away from the scene in Thousand Oaks. AP

The gunman at the bar was tall and wearing all black with a hood and his face partly covered, witnesses told TV stations at the scene. He first fired on a person working the door, then appeared to open fire at random at the people inside, they said.

Many more people had minor injuries, including some that came from their attempt to flee, Dean said.

People comfort each other as they stand near the scene in Thousand Oaks, California, where a gunman opened fire inside a country dance bar crowded with hundreds of people on "college night". AP

Sheriff's Sgt. Ron Helus and a passing highway patrolman were responding to several emergency calls when they arrived at the Borderline Bar & Grill in Thousand Oaks at about 11.20pm, the sheriff said. They heard gunfire and went inside.

Helus was immediately hit with multiple gunshots, Dean said. The highway patrolman cleared the perimeter and pulled Helus out, and then waited as a SWAT team and scores more officers arrived. Helus died early on Thursday local time at a hospital.

By the time the SWAT team entered the bar, the gunfire had stopped. They found 12 people dead inside, including the gunman.

The shooting happened on a university night. Two-step lessons in country dancing were being offered on Wednesday at the Borderline, according to its website.

The scene of the shooting. KABC

The bar, which includes a large dance hall with a stage and a pool room along with several smaller areas for eating and drinking, is a popular hangout for students from nearby California Lutheran University who enjoy country music. It's also close to several other universities including California State University Channel Islands in Camarillo, Pepperdine University in Malibu and Moorpark College in Moorpark.

Officers around a Police SUV in the vicinity of a shooting in Thousand Oaks, California. KABC via AP

When the gunman entered, people screamed and fled to all corners of the bar, while a few people threw bar stools through the windows and helped dozens to escape, witnesses said.

Video from the scene is punctuated by several rounds of gunfire, a terrified witness runs out and police cars are seen arriving as an armed officer takes up position outside the bar. Three men rush out carrying a bloodied fourth individual and they try to stem the bleeding of what appears to be a gunshot wound.

Cole Knapp, a freshman at Moorpark College, said he was inside the bar when the shooting began but thought at first that it was "just someone with an M-80, just kind of playing a prank".

Then he said he saw the shooter, wearing a black beanie and black hoodie and holding a small handgun.

"I tried to get as many people to cover as I could," Knapp said. "There was an exit right next to me, so I went through that. That exit leads to a patio where people smoke. People out there didn't really know what was going on. There's a fence right there so I said, 'Everyone get over the fence as quickly as you can, and I followed them over."

He said a highway patrol officer who just happened to be pulling someone over was nearby.

"I screamed to him, 'There's a shooter in there!' He was kind of in disbelief, then saw that I was serious."

Knapp said he had friends who hadn't been accounted for.

Tayler Whitler, 19, said she was on the dance floor with her friends nearby when she saw the gunman shooting and heard screams to "get down."

"It was really, really, really shocking," Whitler told KABC-TV as she stood with her father in the Borderline parking lot. "It looked like he knew what he was doing."

Sarah Rose DeSon told ABC's Good Morning America that she saw the shooter draw his gun.

"I dropped to the floor," she said. "A friend yelled 'Everybody down!' We were hiding behind tables trying to keep ourselves covered."

Chandler Gunn, 23, of Newbury Park said his mum came to his room and told him about the shooting.

He rushed to the bar and called a friend who works there. The friend was also at the Route 91 Harvest music festival in Las Vegas when a gunman opened fire last year killing 58 people and wounding hundreds.

Gunn said his friend had again survived, adding that Wednesday nights were college country nights at the bar, and open to people 18 and over for line dancing lessons.

"A lot of people in the Route 91 situation go here," he said. "There's people that live a whole lifetime without seeing this, and then there's people that have seen it twice."

Shootings of any kind are very rare in Thousand Oaks, a city of about 130,000 people about 64 kilometres west of Los Angeles, just across the county line.

Helus was a 29-year veteran of the force with a wife and son and planned to retire in the coming year, said the sheriff, who choked back tears several times as he talked about the sergeant, who he said was also his longtime friend.

"Ron was a hardworking, dedicated sheriff's sergeant who was totally committed," Dean said, "and tonight, as I told his wife, he died a hero because he went in to save lives."

AP, McClatchy