How to Stream Audio to Shoutcast Using FFmpeg

This article provides a straightforward guide on how to stream live or pre-recorded audio to a Shoutcast server using the FFmpeg command-line tool. You will learn the exact command-line syntax required to encode your audio source, configure the connection parameters, and successfully broadcast your stream in real time.

Prerequisites

Before you begin, ensure you have the following: * FFmpeg installed on your system. * Your Shoutcast server details: Server IP/Host, Port, Stream ID (for Shoutcast v2), and the Source Password. * An audio source (such as an audio file, a playlist, or a live microphone input).

The FFmpeg Command Structure

FFmpeg utilizes the Icecast protocol format to connect and stream to Shoutcast v2 servers. Below is the standard command structure used to stream an MP3 audio file to a Shoutcast server:

ffmpeg -re -i input.wav -acodec libmp3lame -ab 128k -ac 2 -ar 44100 -f mp3 icecast://source:password@yourserver.com:8000/stream/1

Command Parameter Breakdown

To customize the stream for your specific setup, understand what each parameter does:

Streaming a Live Audio Input

If you want to stream from a live input device (such as a microphone or line-in) instead of an audio file, change the input parameters.

On Windows (using dshow):

ffmpeg -f dshow -i audio="Microphone (Realtek Audio)" -acodec libmp3lame -ab 128k -ac 2 -ar 44100 -f mp3 icecast://source:password@yourserver.com:8000/stream/1

On Linux (using ALSA):

ffmpeg -f alsa -i hw:0 -acodec libmp3lame -ab 128k -ac 2 -ar 44100 -f mp3 icecast://source:password@yourserver.com:8000/stream/1

On macOS (using AVFoundation):

ffmpeg -f avfoundation -i ":0" -acodec libmp3lame -ab 128k -ac 2 -ar 44100 -f mp3 icecast://source:password@yourserver.com:8000/stream/1