Icecast video streaming with OBS
In this post I'll outline configuration steps for streaming video from an Icecast server with OBS as the source.
The intention is to be able to self-host a video stream that could be used for a variety of purposes, such as "watch/view together" use.
The configuration below has been tested to keep each connected viewer closely synced to the same point in the stream. The difference in sync between viewers stays roughly between 0-2 seconds in testing. If this isn't of importance to you, then you may benefit from increasing the Icecast queue-size
and burst-size
.
A self-signed SSL certificate will be generated in this example, with SSL/TLS used for the OBS > Icecast
connection, and for the Viewer > Icecast
connections. The Icecast server will be streaming publically unless you setup firewalling to do otherwise, or if you password protect the viewer connections (by putting Icecast behind a password protected NGINX proxy or similar).
Setup Icecast
This was tested on a Vultr 1 vCPU / 2GB RAM server running Fedora 33 x64.
- Stop firewalld, as the cloud provider's firewall around the instance will suffice for testing. Just make sure port 22 & 443 are accessible.
systemctl stop firewalld
- Install Icecast
dnf install -y icecast
- Generate a self-signed SSL certificate.
openssl req -x509 -nodes -days 365 -subj '/CN=icecastserver/O=icecastserver/C=SG' -newkey rsa:4096 -keyout /usr/share/icecast/ssl.crt -out /usr/share/icecast/ssl.crtchmod 644 /usr/share/icecast/ssl.crt
- Make sure the following items are set within the Icecast configuration, within their respective sections.
vim /etc/icecast.xml
<limits> <queue-size>2046000</queue-size> <burst-size>1024000</burst-size> </limits> <listen-socket> <port>443</port> <bind-address>icecast-server-ip-address-goes-here</bind-address> <ssl>1</ssl> </listen-socket> <paths> <ssl-certificate>/usr/share/icecast/ssl.crt</ssl-certificate> </paths> <authentication> <source-password>password-goes-here</source-password> <relay-password>password-goes-here</relay-password> <admin-user>admin</admin-user> <admin-password>password-goes-here</admin-password> </authentication>
- Start Icecast
icecast -b -c /etc/icecast.xml
Setup OBS
This was tested with OBS v27.0.1 running on Fedora 33 Linux - If you're intending to use OBS from Windows 10 or OSX, then you'll likely need to check the Troubleshooting section with respect to potential SSL/TLS connection issues.
- Setup OBS to stream to Icecast as follows:
File > Settings > Output Output Mode = Advanced Select the "Recording" tab Type = Custom Output (FFmpeg) File path or URL = icecast://source:<source-password>@<ip-address>:<port>/<mountpoint>.ts Container Format = mpegts Muxer Settings = content_type=video/m2ts tls=1 Video Bitrate = 6000 Kbps Keyframe interval (frames) = 250 Show all codecs = Ticked Video Encoder = libx264 Audio Bitrate = 192 Kbps Audio Encoder = libopus
- Click
Start Recording
to start streaming from OBS to the Icecast server.
Connect to the Icecast stream
Open the
.ts
URL of the Icecast server using your media player of choice (MPV, PotPlayer, VLC etc)mpv https://<ip-address>/<mountpoint>.ts
Troubleshooting
The media player disconnects mid stream or struggles to start the stream, and you don't think it's a bandwidth issue.
- Try increasing the Icecast
queue-size
andburst-size
, or reducing theVideo Bitrate
within OBS streaming to Icecast.
As soon as you click Start Recording
in OBS, it errors out with Error number -10054 occurred; ffmpeg_data_init failed
.
- In testing, this occured when trying to connect to Icecast over SSL/TLS, but only on Windows 10 and not under Linux (Fedora 34). OBS 27.0.1 was used on both systems. This appears to be due to differences between FFmpeg versions that may end up being used by OBS across these two tested OS setups. A way to fix this on Windows 10 is to use a newer version of FFmpeg with OBS that supports the Icecast
tls
option toEstablish a TLS (HTTPS) connection to Icecast
, or to disable SSL/TLS on the Icecastlisten-socket
that you're connecting to. Both approaches are outlined as below, depending on which you'd prefer to use.
Updating FFmpeg on Windows 10 OBS in order to connect to Icecast over SSL/TLS.
- Download a
shared
release of a recent version of FFmpeg. v4.4 was tested as working. You can grab it from here or here. - Extract the contents of the
bin
directory into the OBS bin directory, and overwrite any existing files. The path is typicallyC:\Program Files\obs-studio\bin\
- Try connecting OBS to the Icecast server once again now, it should work.
Alternatively: Disable SSL/TLS
You only need to apply this to the icecast listen-socket
you connect OBS to, you can still have another listen-socket
setup in the Icecast configuration for any viewers to connect with SSL/TLS if desired. You can use the adjusted config below to connect OBS to Icecast on port 8000 without SSL/TLS.
# Set <ssl> to 0 under the <listen-socket> section, and set the <port> to 8000
<listen-socket>
<port>8000</port>
<bind-address>icecast-server-ip-address-goes-here</bind-address>
<ssl>0</ssl>
</listen-socket>
# Set `tls=0` inside the OBS `Muxer Settings` (OBS will likely still connect if it's set to `tls=1`, as long as SSL isn't enabled on the Icecast `listen-socket` you're connecting to):
File > Settings > Output
Output Mode = Advanced
Select the "Recording" tab
Muxer Settings = content_type=video/m2ts tls=0
- Open the
.ts
URL of the Icecast server using your media player of choice (MPV, PotPlayer, VLC etc)mpv http://<ip-address>:8000/<mountpoint>.ts
How can I get this to use a browser friendly video container so I can stream within a web browser?
- You can try using
webm
for theContainer Format
inside OBS, withlibvpx
orlibvpx-vp9
as theVideo Encoder
. I encountered performance issues on the encoding end when testing this, but your mileage may vary.