A rapist who filmed himself abusing children and uploaded the footage to the internet could face a life sentence.

Robert McGregor was caught with a hoard of child abuse images at his home in Inverness, which led police to identify three victims he had raped as children.

The 35-year-old's home on Friars Street was raided earlier this year after a tip-off from the National Online Child Abuse Prevention Agency and laptops were seized for analysis.

More than 2000 indecent photos and 899 videos were recovered, many of which contained material at the most extreme level.

The High Court in Edinburgh was told some images appeared to show children as young as one year old.

McGregor uploaded five videos to a peer-to-peer internet app which allowed others to view the abuse of one of his victims.

Police computer experts found the files had been accessed in the US, Germany and Czech Republic.

McGregor pleaded guilty to six offences, admitting three charges of raping boys, sexually assaulting a youngster, making indecent photos of children and distributing or showing indecent photos.

His assaults on children spanned more than a decade between 2001 and 2014 and all the attacks occurred in the Inverness area.

The offences relating to child abuse images took place between 2011 and March this year.

The advocate depute said McGregor's offending had a profound effect on some of his victims.

Defence solicitor advocate John Keenan said it was his intention to seek an independent risk assessment of McGregor following the receipt of initial reports in the case.

The judge, Lady Carmichael, said she would make a risk assessment order and continued the case until January, with McGregor remanded in custody.

The assessment could lead to an Order for Lifelong Restriction - an indeterminate sentence with the court setting a minimum period to be served in jail but any future consideration of release left to the parole authorities.

McGregor has also been put on the sex offenders register.