Playing streams off the web with FFplay
|
Recording
Taking things a bit further, it may at some point occur to you that it would be nice not only to hear the radio station but to record a program on it. Because streams often already contain MP3 files, you can use FFmpeg to convert the stream into an MP3 file (see Listing 3).
Listing 3
Converting to MP3
$ ffmpeg -i http://87.118.64.215:8000/ -acodec copy $(date +"%Y-%m-%d_%H%M%S").mp3
The program copies the actual user data (with the -acodec copy option). During this process, it adds a real header to the file that converts the file to a full-fledged MP3. You can then copy the file to another device, such as a smartphone, so as to fully enjoy the recordings.
To make things even easier, insert this line in a script or create a keyboard shortcut or start button on the command bar or menu, so that you can have things at the push of a button.
Be careful, however, to activate the Run in terminal option when applying the button or keyboard shortcut; otherwise, you can't stop the recording with Ctrl+C, and it will run along happily in the background until you shut down the computer or issue a kill command.
Conclusion
The script in Listing 2 easily can be enhanced in many ways. One possibility, as already mentioned, is outsourcing the station list for individualized listings. Alternatively, you could provide the recorded audio files in a separate selection.
Moving from an idea to a multimedia tool is often very easy in Linux. The large number of command-line tools that have appropriate functions make it easy to include these functions into a corresponding script. You can then tailor the program to your needs and open possibilities that many classic media players don't necessarily provide.
Infos
- The FFmpeg suite: http://www.ffmpeg.org
- Live-radio: http://www.live-radio.net
« Previous 1 2 Next »
Buy this article as PDF
Pages: 2
(incl. VAT)