A Python application that streams MP3 files to one or more Icecast servers in a continuous loop. Supports multiple endpoints with individual bitrate configuration.
Repository: https://github.com/alephcom/audio-push
- Python 3.6 or higher
- FFmpeg installed and available in your PATH
macOS:
brew install ffmpegLinux (Ubuntu/Debian):
sudo apt-get update
sudo apt-get install ffmpegLinux (RHEL/CentOS):
sudo yum install ffmpegWindows: Download from https://ffmpeg.org/download.html and add to PATH.
- Clone the repository:
git clone https://github.com/alephcom/audio-push.git cd audio-push - Ensure FFmpeg is installed (see above)
- No additional Python packages are required (uses standard library only)
The recommended way to use this application is with a JSON configuration file that specifies one or more Icecast endpoints.
- Create a JSON configuration file (see
config.example.jsonfor an example):
{
"endpoints": [
{
"host": "localhost",
"port": 8000,
"mount": "/stream.mp3",
"username": "source",
"password": "your_source_password",
"stream_name": "My Radio Station",
"bitrate": "128k",
"source_file": "path/to/audio.mp3",
"protocol": "http"
},
{
"host": "icecast.example.com",
"port": 8443,
"mount": "/live.mp3",
"username": "source",
"password": "another_password",
"stream_name": "Alternative Stream",
"bitrate": "192k",
"source_file": "path/to/audio2.mp3",
"protocol": "https"
}
]
}- Run the application:
# Using a local configuration file
python audio_streamer.py -c config.json
# Or using a remote configuration file URL
python audio_streamer.py -c https://example.com/config.jsonEach endpoint in the configuration file must include:
host: Icecast server hostname or IP address (required)port: Icecast server port, typically 8000 (required)mount: Icecast mount point, e.g.,/stream.mp3(required)password: Icecast source password (required)source_file: Path to the source MP3 file to stream (required)protocol: Protocol to use, eitherhttporhttps(optional, default:http)username: Icecast username (optional, default:source)stream_name: Name of the stream (optional, default:Audio Stream)bitrate: Audio bitrate, e.g.,128k,192k,64k(optional, default:128k)
For backward compatibility, you can still specify a single endpoint via command-line arguments:
python audio_streamer.py -f audio.mp3 -H localhost -p 8000 -m /stream.mp3 -P password-f, --file: Path to the MP3 file to stream (required)-c, --config: Path to JSON configuration file with endpoint(s) (recommended)-H, --host: Icecast server hostname or IP address (legacy, required if no config)-p, --port: Icecast server port (legacy, required if no config)-m, --mount: Icecast mount point (legacy, required if no config)-P, --password: Icecast source password (legacy, required if no config)-u, --username: Icecast username (legacy, default:source)-n, --name: Stream name (legacy, default:Audio Stream)
chmod +x audio_streamer.py
./audio_streamer.py -c config.json- Loads endpoint configuration from JSON file or command-line arguments
- Each endpoint specifies its own source MP3 file and protocol (HTTP/HTTPS)
- Groups endpoints by (source_file, bitrate) combination for efficiency
- Creates one FFmpeg process per group (multiple endpoints with same file/bitrate share a process)
- Streams to all configured Icecast servers simultaneously using the specified protocol
- Automatically loops the source file indefinitely for each endpoint
- Handles reconnections if any stream drops
- Each endpoint can have its own source file, bitrate, and protocol configuration
Endpoints sharing the same source file and bitrate are automatically grouped together and streamed using a single FFmpeg process. This reduces CPU usage and network overhead when streaming to multiple endpoints with the same configuration.
Make sure your Icecast server is configured to accept streams on the specified mount point. Your Icecast configuration file should include:
<mount>
<mount-name>/stream.mp3</mount-name>
<password>your_source_password</password>
</mount>Press Ctrl+C to gracefully stop the stream.
Make sure FFmpeg is installed and available in your PATH. Test with:
ffmpeg -version- Check that the Icecast server is running
- Verify the host, port, and mount point are correct
- Check firewall settings
- Verify the username and password are correct
- Check Icecast source password configuration
MIT License - see LICENSE file for details.