Set Icecast Mount, Password, and Content Type in FFmpeg
Streaming live audio to an Icecast server using FFmpeg requires configuring specific parameters to ensure proper authentication and routing. This guide explains how to define the mount point, source password, and audio content type directly within your FFmpeg command-line arguments for seamless broadcasting.
The Icecast URL Structure (Mount Point and Password)
In FFmpeg, the mount point, username, and password are set directly within the output URL using the Icecast protocol handler. The standard syntax for the destination URL is:
icecast://username:password@host:port/mountpoint
- Username: For Icecast source connections, the
default username is almost always
source. - Password: The source password configured in your
icecast.xmlfile. - Host and Port: The IP address or domain name of
your Icecast server, followed by the port (usually
8000). - Mount Point: The specific path where your stream
will be published (e.g.,
/stream.mp3or/radio.ogg). This must include the leading slash and the appropriate file extension.
Setting the Content Type
To tell the Icecast server and connecting clients what audio format
you are streaming, you must use the -content_type flag in
FFmpeg. This flag maps directly to the HTTP Content-Type
header.
Common content types include: * MP3:
-content_type audio/mpeg * Ogg/Vorbis or
Ogg/Opus: -content_type audio/ogg *
AAC: -content_type audio/aac or
-content_type audio/aacp
This flag must be placed before the output Icecast URL in your command line.
Complete FFmpeg Command Example
Below is a practical command that transcodes an input audio source into a 128kbps MP3 stream and sends it to an Icecast server:
ffmpeg -re -i input.wav -c:a libmp3lame -b:a 128k -content_type audio/mpeg -f mp3 icecast://source:your_secure_password@yourserver.com:8000/live.mp3Command Breakdown:
-re: Tells FFmpeg to read the input in real-time (crucial for live streaming).-i input.wav: Defines the input source (this could also be a live microphone input or playlist).-c:a libmp3lame -b:a 128k: Encodes the audio to MP3 at a bitrate of 128 kbps.-content_type audio/mpeg: Sets the MIME type so Icecast knows it is receiving an MP3 stream.-f mp3: Forces the output format to MP3.icecast://...: Authenticates with the server and targets the/live.mp3mount point.