A pilot was pulled to safety from his downed plane seconds before it was smashed to pieces by a speeding train in California, police have said.

In bodycam footage, the bloodied pilot can be seen trapped in his cockpit as Los Angeles police officers desperately work to free him.

The video shows the frantic race against time as the train hurtles down the tracks towards the stranded plane.

The officers manage to yank the pilot free, and drag him along the road away from the level crossing, shouting "Go! Go! Go! Go! Go!" as the train - its horn blaring - crashes into the plane, sending debris everywhere.

Los Angeles police said the dramatic rescue took place in a northern suburb of the city, a few miles north of Hollywood.

The single-engine plane lost power shortly after taking off from a nearby airfield and the pilot had to make an emergency landing on a city street, coming to rest half on the rail line.

"I think this guy needs to buy a lottery ticket because he pretty much cheated death twice within 10 minutes," Robert Sherock, one of the police officers involved in the heroics told NBC television.

The pilot, who has not been named, was taken to hospital after the dramatic rescue and was in stable condition.

He was alone in the plane and there were no other injuries in the crash, emergency officials said.