Skip to content

Instantly share code, notes, and snippets.

@summersab
Last active December 23, 2022 06:29
Show Gist options
  • Save summersab/43d83fbfecaf9dffa665bacdc39cba10 to your computer and use it in GitHub Desktop.
Save summersab/43d83fbfecaf9dffa665bacdc39cba10 to your computer and use it in GitHub Desktop.
VLC -> Icecast without soundcard
darkice.cfg:
[general]
duration = 0 # duration of encoding, in seconds. 0 means forever
bufferSecs = 1 # size of internal slip buffer, in seconds
reconnect = yes # reconnect to the server(s) if disconnected
# this section describes the audio input that will be streamed
[input]
#device = /dev/dsp # OSS DSP soundcard device for the audio input COMMENTED OUT
device = default # best configuration as of Ubuntu 16.04
sampleRate = 11025 # sample rate in Hz. 11025, 22050, 44100
bitsPerSample = 16 # bits per sample. 16 for mono feeds, 32 for stereo feeds
channel = 2 # channels. 1 = mono, 2 = stereo
[icecast2-0]
# The audio format to encode to, we're using mp3 here
format = mp3
bitrateMode = cbr
bitrate = 16 # (16 for mono feeds, 32 for stereo feeds)
server = 127.0.0.1
password = [REDACTED]
port = 8000
mountPoint = stream
# These are the basic packages that need to be installed. VLC is stripped down to the bare minimum without X.
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y darkice icecast2 pulseaudio jackd2 alsa-utils dbus-x11 vlc vlc-plugin-video-output x11-utils- xdg-utils- vlc-plugin-samba- fonts-freefont-ttf- libnotify4-
# These are the commands you need to run to get everything going. I'm assuming that you installed Icecast and went through the configuration wizard during install.
sudo service icecast2 start
sudo jackd -r -ddummy & sleep 0.25 ;
pulseaudio -D & sleep 0.25 ;
darkice -c darkice.cfg & sleep 0.25 ;
cvlc --network-caching 10000 --no-video [file-or-url]
# To kill everything, run the following. Note:
# - Programs are killed in a specific order. Killing Pulseaudio before Darkice results in crashing.
# - For some reason, you have to kill Jack twice (once as sudo, once as the current user). A delay is required between the two operations.
pkill darkice ; pkill pulseaudio ; sudo pkill jackd ; sleep 0.25 ; pkill jackd
# If you don't want to type :8000 to access your server (or it's blocked by a firewall), you can always install nginx and use a reverse proxy on port 80.
server {
listen 80 default_server;
listen [::]:80 default_server;
location /stream {
proxy_pass http://localhost:8000/stream;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment