CCTV footage of a man narrowly missing a train has been released by Network Rail to warn of the dangers of level crossings.