Dramatic dashcam video posted online Wednesday shows a man opening fire on deputies responding to a call in Southern California last month.

On April 27, three deputies responded to reports of a suicidal man armed with a gun in San Juan Capistrano, according to the Orange County Sheriff's Department.

The video, posted on YouTube, shows the man coming out of his garage and firing several rounds with an automatic rifle at deputies standing by their patrol cars.

As deputies run to take cover, gunfire blows out the back window of a patrol car but no deputies are struck.

After firing dozens of rounds, the suspect came out of his garage, dropped his weapon and was taken into custody, authorities said.

Deputies did not return fire because they didn't have a clear view and were concerned someone else may have been inside the garage.

No one else was injured during the incident.

The video was posted to show the dangerous and unpredictable job deputies encounter, the Sheriff's Department stated.