Technically speaking, photography and videoing on FS/Trenitalia property (stations, yards, depots. etc.) is still illegal without a written permit obtained in advance....and I have been pulled-up for it a couple of times in the distant past. However, since the widespread introduction of smartphones, the railway police seem to have largely given-up trying to enforce that particular law. Provided that you stay in publicly-accessible areas such as on platforms, footbridges, etc. you shouldn't encounter many problems. If you are photographing and videoing trains and a railway police officer blows their whistle at you and waves a finger from side to side, stop immediately, acknowledge in a friendly fashion and put your camera/phone away for a short while. If in doubt, discretion is the better part of valour....so conceal yourself behind a building or pillar or similar while filming. You won't have any hassle from railway staff as they all think - quite rightly - that it's a stupid outdated law which isn't worth bothering about. Indeed some staff may come up to you and talk about your interest in railways if you can find a common language and you may find yourself being invited into a signalbox - if located on the platform - or another interesting railway office. There are no restrictions on photography or filming on the stations of Italian 'private' railways and you will will usually find the staff to be very friendly and amenable.
At large terminal stations such as Roma Termini, Milano Centrale, Torino Porta Nuova, Firenze SMN and Napoli Centrale there are staffed ticket barriers and you would need a valid travel ticket to be admitted to the platforms. In these cities the best photographic opportunies - certainly for capturing moving trains - are at the peripheral main line stations which are 'open'. (e.g. Milano Lambrate, Milano Rogoredo, Firenze Rifredi, Firenze Campo di Marte, Roma Tiburtina, etc.) Don't forget that tickets for Italian regional trains are only valid on the day of issue, must be validated in the green or yellow machines at or near the platform entrances and are valid for a maximum of four hours from the time of validation. However, break of journey is permitted within that four hour period on Trenitalia services....but not on most of the 'private' lines. InterCity and high speed trains have compulsory reservation, therefore tickets are train- and date-specific.