A man has narrowly escaped death after knocking himself out on a safety barrier as he tried to cross a set of train tracks on his scooter in Vietnam.

In nailbiting footage posted to social media, a man is seen riding a motorbike towards a railway crossing as the alarms blare and an automatic barrier lowers down, only to be struck in the neck.

The impact throws him off of the bike, leaving him sprawled motionless on the tracks as his motorcycle gets sent flying towards the road.

A few moments later, Than Nhon, a 59-year-old local passerby, spots the injured driver.

With not a second to lose, he rushes in and drags him off the tracks, before being crushed by the 460-tonne passenger train as it speeds past.

Th elocal hero was reportedly taking his grandchild to school when he spotted the man lying on the tracks.

According to local reports, the motorcyclist was rushed to hospital and sustained injuries to his ribs, nose and heels.

The incident happened on Wednesday at about noon (local time) at an automated railway crossing in Tam Anh Commune, Da Nang City, according to VN Express.

Da Nang Railway Signal and Telecommunication JSC has suggested that Mr Nhon should receive a special commendation for his bravery, quick thinking and courage.

The SE2 passenger train, with 12 carriages, was approaching the crossing when the driver saw the man seemingly unconscious on the tracks and applied the emergency brakes, resulting in the train stopping metres away from where he lay.

According to railway officials, the sun glare may of affected the motorcyclist’s vision which lead to the accident, however they have warned locals that heavy passenger trains cannot come to an immediate stop when there is an obstacle on the tracks.

Officials have urged locals to respond to warning lights, alarms and barriers.