The video shows gym trainer T Siva standing close to the tracks as a Multi-Modal Transport System train approaches behind him.
Despite the train blasting its horn, Mr Siva doesn't move and keeps his eyes firmly fixed on his phone.
As he continues to film, the train strikes the right side of his head, before the phone drops to the ground.
Mr Siva survived, but suffered head injuries.
The 21-second video has been viewed thousands of times on Facebook since Monday.
Indian authorities have warned about the dangers of selfies after a series of selfie-related deaths last year.
In October, three teenagers were reportedly lying on the train tracks to take a photo of themselves when they were run over.
Last January two teenagers died while trying to take pictures in front of an oncoming train.
Near-death incident prompts warnings against selfies
India's Railways Minister Piyush Goyal said he was disheartened by the trend of young people taking selfies near railway tracks, urging them to channel their energy into more productive activities.
"You all are the future of the country and my appeal is to avoid putting your life at risk and stay alert around the railway tracks," he said in a letter to citizens published online.
"Follow the rules and signs and pay attention while approaching rail crossings."
India's rail authority South Central Railways also posted a warning on Twitter that taking selfies was dangerous and would be punished.
Mr Siva appeared in court and was fined 500 rupees ($10).