How can I serve multiple audio files continuously as a live stream using FFmpeg?

In my project, I’m creating an online radio streaming service that will give customers a seamless, nonstop listening experience. This service offers a variety of audio content, such as music tracks, podcasts, and live DJ sets, all of which must be broadcast in a seamless live stream. My objective now is to solve the technical problem of serving these varied audio files in real-time using the flexible multimedia framework FFmpeg, so that consumers may listen to music and other content without interruptions.

Can anyone from the community provide me tutorial how can I do above?


You can write a script that concatenates and delivers the audio files in a loop in order to continually stream numerous audio files as a live audio stream using FFmpeg. Here is a tutorial for FFmpeg:

1. Set up FFmpeg

To download FFmpeg on your system follow the below guides:

Here, tag Gumlet existing articles to install FFmpeg

2. Get Your Audio Files Ready

Consider that you have the audio files “song1.mp3,” “song2.mp3,” and “song3.mp3.” You must make sure that these files are in the same directory as your FFmpeg script.

3. FFmpeg script creation

  1. Create a text file (for example, “”) and add the following script.


while true; do

ffmpeg -re -i song1.mp3 -acodec copy -f ogg icecast://source:your-password@your-server-ip:8000/mountpoint.ogg

ffmpeg -re -i song2.mp3 -acodec copy -f ogg icecast://source:your-password@your-server-ip:8000/mountpoint.ogg

ffmpeg -re -i song3.mp3 -acodec copy -f ogg icecast://source:your-password@your-server-ip:8000/mountpoint.ogg


Update the following script placeholders:

  • your-password: Your Icecast source password.
  • your-server-ip: The IP address or hostname of your Icecast server.
  • mountpoint.ogg: The Icecast mount point where you intend to stream the audio.

4. Give authorization for execution

Execute the next command to provide the script execution permission:

chmod +x

5. Run the FFmpeg program

Run the script to start continuously streaming the audio files:


The three audio files will be persistently played in order by the script, with FFmpeg sending the audio to your Icecast server.

6. Distribute and Publicise the Stream

Similar to the Icecast example, give your audience the URL of your streaming server. The given URL allows listeners to view your live audio feed.

7. Monitor and uphold

Monitor the script’s performance for any irregularities or interruptions. Use programs like Screen or Tmux to keep the script running in the background.

8. Legitimate Concerns

Make sure you have the necessary authorizations and rights to broadcast the audio files, especially if they contain copyrighted content.

The audio content from the provided audio files will be continuously looped through by this FFmpeg script and sent to your Icecast server for live streaming. To make it possible for FFmpeg to connect to your Icecast server successfully, remember to take care of network and server setups, including firewall settings.

Do check these links for more information: