Stream Video to Icecast Using FFmpeg
This article provides a direct, step-by-step guide on how to stream live video to an Icecast server using the native Icecast protocol in FFmpeg. You will learn the exact FFmpeg command structure, the required video and audio codecs, and how to configure your output parameters to successfully broadcast WebM or Ogg video streams.
To stream video to Icecast, you must use a container format and codecs that Icecast supports, typically WebM (VP8 video and Vorbis/Opus audio) or Ogg (Theora video and Vorbis audio). Modern implementations favor the WebM format.
Here is the standard FFmpeg command to stream a video file or live input to an Icecast server using WebM:
ffmpeg -re -i input.mp4 -c:v libvpx -b:v 1M -c:a libvorbis -b:a 128k -f webm -content_type video/webm icecast://source:your_password@your_server_ip:8000/stream.webmCommand Breakdown
-re: Forces FFmpeg to read the input in real-time. This is crucial for live streaming; omitting this will cause FFmpeg to stream too quickly, causing buffer issues.-i input.mp4: Specifies your input source. This can be a local video file, a live camera feed, or an RTSP stream.-c:v libvpx: Encodes the video using the VP8 codec (standard for WebM video streams).-b:v 1M: Sets the video bitrate to 1 Megabit per second. Adjust this based on your available upload bandwidth.-c:a libvorbis: Encodes the audio using the Vorbis codec.-b:a 128k: Sets the audio bitrate to 128 kbps.-f webm: Forces the output format to be WebM.-content_type video/webm: This is an Icecast-specific flag passed to the protocol wrapper. It tells the Icecast server what MIME type to expect and broadcast to viewers.icecast://...: The native FFmpeg Icecast URL.source: The default username required by Icecast for streaming sources.your_password: The source password configured in youricecast.xmlfile.your_server_ip:8000: The IP address (or domain) and port of your Icecast server./stream.webm: The mountpoint where users will access your stream.
Alternative: Streaming Ogg/Theora
If you prefer using the older Ogg/Theora format, modify the codecs and container parameters as follows:
ffmpeg -re -i input.mp4 -c:v libtheora -q:v 6 -c:a libvorbis -q:a 4 -f ogg -content_type video/ogg icecast://source:your_password@your_server_ip:8000/stream.ogvEnsure that your Icecast configuration (icecast.xml) has
enough bandwidth and limit settings allowed for video streams, as video
requires significantly more throughput than standard audio-only
streams.