MP3 is now substantially patent free due to patents expiring

"The basic MP3 decoding and encoding technology is patent-free in the European Union, all patents having expired there by 2012 at the latest. In the United States, the technology became substantially patent-free on 16 April 2017 "

Free alternatives are Ogg and Flac