A music teacher who rigged up a hidden camera to film himself sexually abusing boys has been jailed for three years and eight months.
Philip Evans, 38, committed the "disgusting" offences while also secretly capturing dozens of indecent images of pupils using changing rooms at one of the country's leading private schools.
Birmingham Crown Court heard Evans, who hid one of several cameras inside an electrical box, was arrested in August after an indecent photograph of a sleeping boy was found during a dawn raid on his home.
Follow-up inquiries uncovered around 350,000 indecent images on computers belonging to Evans, including more than 100 recordings of pupils using changing rooms and a storage area at King Edward's School in Edgbaston, Birmingham.
Some of the footage, found on a laptop and a desktop computer, showed the teacher committing sexual assaults as he pretended to measure seven teenage pupils.
Evans, of Warwards Lane, Stirchley, Birmingham, pleaded guilty to six counts of voyeurism, seven of sexual assault, and nine charges relating to indecent images.
Opening the facts of the offences, prosecutor Aliya Rashid said recording equipment, including a hi-tech security camera imported from America, had been used to film boys in various states of undress.
Evans, who acted as an RAF "leader" in the Combined Cadet Force at the school, captured some of the images on a camera he attached to a bench inside a shower block during a school trip.
Miss Rashid told the court: "The offending spanned four years and much of it was executed with covert recordings set up meticulously for the defendant's own sexual gratification."
On one occasion, Evans entered a shower area at 4am to set up equipment and could be seen testing that it was working, said Miss Rashid.
Passing sentence, Judge Peter Carr described the offences - except one committed at Evans' home - as a gross breach of trust.
As Evans remained composed in the dock, Judge Carr told him: "All of this behaviour by you was repulsive, disgusting and deceitful.
"Parents of pupils and pupils themselves should expect a school is a safe environment. You have made this environment unsafe."
The judge acknowledged that Evans' career was over and his reputation in ruins, but said it was "obvious" from the material recovered that the offences were carried out over a prolonged period of time.
Speaking after the case, Detective Chief Inspector Chris Hanson, head of the Child Online Safeguarding Team at West Midlands Police, said: "This was a distressing and incredibly complex case to investigate.
"Our absolute priority throughout all of it was protecting children at the school.
"Evans, who has no previous convictions, had amassed 350,000 indecent images of children over four years and my team had the deeply disturbing job of analysing those sickening images in a bid to identify the boys who had been abused, where the crimes took place and when."
Evans, who is known to have visited nudist camps before being arrested, is not thought to have distributed images captured at the school to other paedophiles.
Mr Hanson added: "Philip Evans is a cold, calculating and manipulative paedophile who went to great lengths to secure indecent images of children.
"He abused his position as a teacher and as a cadet leader, and grossly betrayed the trust boys in his care placed in him.
"I am satisfied with the sentenced passed by the courts today and I believe it will go some way to help the children he abused."
King Edward's, a fee-paying independent school, was founded in 1552 by Edward VI and boasts two Nobel Prize winners among its former pupils.
In a statement issued after Evans pleaded guilty last month, the school said it was shocked and saddened by the charges and was co-operating fully with the police.