John Sharp, 54, was found to have downloaded the massive collection of indecent images when police called at his Edinburgh home last year.
Sharp had previously been jailed for 22 months and placed on the Sex Offenders' Register for ten years in 2014 after admitting to covertly filming women where he worked as a porter.
Police turned up at his flat in October last year to check the history of any electronic devices he owned as part of his release conditions.
But when asked about his laptop the pervert “began to shake” and told officers he had thousands of images stored away on the computer and a mobile phone.
Child abuse images
Sharp was arrested and charged and he appeared back in the dock from custody at Edinburgh Sheriff Court on Tuesday where he pleaded guilty to possessing the huge haul of child abuse pictures.
Fiscal depute Susan Dickson told the court cyber crime unit officers searched the computer and the mobile phone and discovered Sharp had downloaded a total of 922,413 indecent images.
Ms Dickson said Sharp, of the city’s Greendykes area, possessed 4927 Category A images - the most depraved end of the spectrum - and a further 5581 at Category B.
He was also found to have 176,905 at Category C and the court was told the computer equipment also held an additional 735,000 pictures of children being abused that had not yet been classified.
Ms Dickson said: “In October 2019 he was being spoken to by officers (at his home) and they asked if he had any computers that can access the internet and when they asked that he began to shake.”
Sharp then handed over a laptop and a mobile phone to the officers that he admitted contained “thousands of images” on them.
Forensic analysis was carried out on the devices and the hundreds of thousands of images were found hidden away within folders.
Defence solicitor Neil Martin said he would reserve his mitigation to the sentencing hearing.
Sheriff Kenneth McGowan remanded Sharp in custody and placed him on the Sex Offenders Register for a term still to be decided.
Full sentence was deferred to next month for the preparation of reports.
Sharp pleaded guilty to possessing indecent images of children at Wauchope House, Greendykes, Edinburgh, between November 28, 2016 and October 17 last year.
Sharp was caged for 22 months in May 2014 after he had admitted to placing a camera in changing rooms at his workplace in Bruntsfield and recording women undress.
He was also jailed for four years in 2001 for sexually abusing two young girls and possessing child abuse images.
At the time he claimed he had been left traumatised following his service in the Royal Marines and had also witnessed sexual abuse when he was younger.