The phone also held dozens of abusive pictures of children being sexually abused and was traced back to the car's former owner by the SIM card, Northampton Crown Court heard.
Stephen West, 30, was sentenced to an indeterminate term for the public'
s protection and branded a continuing danger to children.
Pearl Willis, prosecuting, said West failed to keep up payments on the car so it was repossessed by a court order and taken to a depot in Brackmills, Northampton.
While it was being valeted, the phone was found and examined with the 31-second video and other abusive images were saved in its memory.
Miss Willis said: "It is clearly a shocking video – a child in a bathroom, not knowing what's about to happen to her, filmed on a mobile phone."
Forensic analysis revealed West had also downloaded and saved another sick video and 31 abusive images of children, including about a dozen showing children being subjected to sexual abuse. The court heard he was previously cautioned and placed on the sex offenders' register in 2006 for possessing child porn images.
As well as pleading guilty to four offences of making and possessing child pornography, he admitted carrying out the sexual assault of the child which he also filmed.
Judge Michael Fowler sentenced West, who kept his head bowed for almost the entire hearing, to imprisonment for public protection with a sexual offences prevention order, banning unsupervised contact with anyone aged under 18, and banned him from ever working with children. The identity of his victim cannot be published for legal reasons.
West, of Pencarrow Place, Fishermead, Milton Keynes, will now be on licence and liable to recall to prison for the rest of his life or for a decade after his release.
He must service a minimum of two years and eight months before being considered for parole and will only be released once the Parole Board deem it safe to do so.
Judge Fowler said: "Your history is woven through activities perpetrated by your perverted attitude to young children, not just below the age of consent but very young children indeed.
"It is disturbing, not least because the discovery of these matters was accidental through a chance access by the police to your mobile phone."
Branding West as a dangerous offender, the judge added: "There is significant risk of serious harm of further offences, particularly against young children."
Stuart Yeung, mitigating, said: "He is repulsed with himself for what he has done. He appreciates he's got a problem and recognises he needs help."