Playing streams off the web with FFplay

Slashdot it! Delicious Share on Facebook Tweet! Digg!

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

  1. The FFmpeg suite: http://www.ffmpeg.org
  2. Live-radio: http://www.live-radio.net

Buy this article as PDF

Express-Checkout as PDF

Pages: 2

Price $0.99
(incl. VAT)

Buy Ubuntu User

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content