You need to be 5 meters from the train rails before you would be able to do this. There are some accidents that have occurred in the railroad wherein people have fallen to their deaths when the train passes.
You need to stay safe while you are near the railroad tracks. One thing that you can do is to make sure that you will obey the stated rules. You are also recommended to look at both ways if you need to cross. If the barrier says that you have to stop, you need to stop or you might get stuck in between the railroad tracks.
There are some people who are not aware that trains may pass simultaneously. One train may come from one side while the other one will come from the other side. Look at both sides before crossing.