Record Internet Radio Streams with FFmpeg on Linux

Recording a live internet radio stream on Linux is a straightforward process when using FFmpeg, a powerful command-line tool for handling multimedia data. This article provides a quick overview of the exact command needed to capture audio streams, explains how the command works breakdown by breakdown, and offers tips on automating your recordings for scheduling purposes.

To record a live internet radio stream, you need the direct URL of the audio stream (often ending in .mp3, .aac, or .pls) and the FFmpeg package installed on your Linux system. The basic command structure captures the live network data and saves it directly to your local storage without re-encoding, preserving the original audio quality.

The standard command to record a stream is:

ffmpeg -i "http://streaming.radio.com/stream.mp3" -c copy output.mp3

Here is what each part of that command does:

  • ffmpeg: Invokes the FFmpeg program.
  • -i "http://streaming.radio.com/stream.mp3": Specifies the input source, which is the URL of the radio stream. Always wrap the URL in quotes to prevent the Linux shell from misinterpreting special characters like ? or &.
  • -c copy: Tells FFmpeg to copy the audio stream directly without re-encoding it. This uses minimal CPU power and ensures zero quality loss.
  • output.mp3: The name and format of the file where the recording will be saved. Match the file extension to the stream's native format (e.g., use .aac if the stream is AAC).

If you want to limit the recording to a specific duration, you can add the -t flag. For example, to record exactly one hour (3600 seconds), use the following command:

ffmpeg -i "http://streaming.radio.com/stream.mp3" -c copy -t 3600 output.mp3

For advanced users, this command can be paired with Linux utilities like cron or at to automate and schedule recordings of your favorite radio shows while you are away from your computer.