Skip to content

Instantly share code, notes, and snippets.

@duracell80
Last active July 23, 2023 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duracell80/c0d31f2395fb85af5b92091260dd5e43 to your computer and use it in GitHub Desktop.
Save duracell80/c0d31f2395fb85af5b92091260dd5e43 to your computer and use it in GitHub Desktop.
NRSC5, FM and HLS to Icecast MP3
# Send a HDRadio program (Hybrid Digital) to icecast for listening across network on audio apps and standalone internet radios without HDRadio tuners onboard
# https://github.com/theori-io/nrsc5
# sudo apt install icecast2
nrsc5 -q -d 0 107.5 0 -o - | ffmpeg -re -i pipe:0 -codec:a libmp3lame -b:a 192k -f mp3 -content_type audio/mpeg icecast://source:rdo@192.168.1.10:3345/hdradio
# Streams a HLS station from vlc for listening on older equipment that can't tune to HLS or can't decode FLAC or other codecs
# sudo apt install vlc
cvlc https://the-hls-radio-stream/hls_listen --prefetch-buffer-size=8000 --sout-mux-caching=8000 --sout '#transcode{acodec=vorb,ab=320}:standard{access=http,mux=ogg,dst=192.168.1.10:3372/cdradio.ogg}'
# Streams a FM station to icecast for listening across network in audio apps, or listening on internet radios that doesn't have FM tuners
# sudo apt install rtl-sdr icecast2
rtl_fm -f 90.3M -M wfm -s 180k -E deemp | sox -traw -r180k -es -b16 -c1 -V1 - -t flac - | ffmpeg -re -i pipe:0 -codec:a libmp3lame -b:a 192k -f mp3 -content_type audio/mpeg icecast://source:rdo@192.168.1.10:3345/fmradio
# Take a youtube live stream at very low video quality and send audio to icecast
# sudo apt install yt-dlp icecast2
yt-dlp -f 91 https://www.youtube.com/watch?v=jfKfPfyJRdk -o - | ffmpeg -re -i pipe:0 -vn -codec:a libmp3lame -b:a 192k -f mp3 -content_type audio/mpeg icecast://source:rdo@192.168.1.10:3345/ytradio
<icecast>
<!-- location and admin are two arbitrary strings that are e.g. visible
on the server info page of the icecast web interface
(server_version.xsl). -->
<location>Earth</location>
<admin>icemaster@localhost</admin>
<!-- IMPORTANT!
Especially for inexperienced users:
Start out by ONLY changing all passwords and restarting Icecast.
For detailed setup instructions please refer to the documentation.
It's also available here: http://icecast.org/docs/
-->
<limits>
<clients>100</clients>
<sources>2</sources>
<queue-size>524288</queue-size>
<client-timeout>30</client-timeout>
<header-timeout>15</header-timeout>
<source-timeout>10</source-timeout>
<burst-on-connect>1</burst-on-connect>
<!-- same as burst-on-connect, but this allows for being more
specific on how much to burst. Most people won't need to
change from the default 64k. Applies to all mountpoints -->
<burst-size>65535</burst-size>
</limits>
<authentication>
<!-- Sources log in with username 'source' -->
<source-password>rdo</source-password>
<!-- Relays log in with username 'relay' -->
<relay-password>supersecurerelaypassword</relay-password>
<!-- Admin logs in with the username given below -->
<admin-user>admin</admin-user>
<admin-password>supersecureadminpassword</admin-password>
</authentication>
<hostname>localhost</hostname>
<listen-socket>
<port>3345</port>
</listen-socket>
<http-headers>
<header name="Access-Control-Allow-Origin" value="*" />
</http-headers>
<fileserve>1</fileserve>
<paths>
<basedir>/usr/share/icecast2</basedir>
<logdir>/var/log/icecast2</logdir>
<webroot>/usr/share/icecast2/web</webroot>
<adminroot>/usr/share/icecast2/admin</adminroot>
<alias source="/" destination="/status.xsl"/>
</paths>
<logging>
<accesslog>access.log</accesslog>
<errorlog>error.log</errorlog>
<!-- <playlistlog>playlist.log</playlistlog> -->
<loglevel>3</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error -->
<logsize>10000</logsize> <!-- Max size of a logfile -->
<!-- If logarchive is enabled (1), then when logsize is reached
the logfile will be moved to [error|access|playlist].log.DATESTAMP,
otherwise it will be moved to [error|access|playlist].log.old.
Default is non-archive mode (i.e. overwrite)
-->
<!-- <logarchive>1</logarchive> -->
</logging>
<security>
<chroot>0</chroot>
</security>
</icecast>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment