A drug-affected man who masturbated in front of women at the Rainbow Serpent electronic music festival in country Victoria before spitting in the face of a female police officer has escaped conviction.

The 23-year-old Ivanhoe man, who Fairfax Media has chosen not to name, appeared before the Ballarat Magistrates Court this week and pleaded guilty to a string of serious charges including directing sexual activity towards another person and assaulting an emergency worker following the four-day ‘‘bush doof’’ event, held at Lexton last January.

The Rainbow Serpent Festival.

The court was told the man entered a tent with his pants pulled down to his ankles before he began to masturbate in front of a group of people, including three women, shouting out ‘‘suck it c--t’’.

Shocked witnesses called for help before security guards arrived on the scene, but the man quickly became aggressive, verbally abusing the guards and yelling ‘‘I’ll knock your f---ing teeth out’’.