Magnetic BV functions and the Bourgain-Brezis-Mironescu formula