Skip to content

Instantly share code, notes, and snippets.

@kfatehi
Created April 17, 2022 06:22
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 kfatehi/5b15b99c764972e5d9c391aad0e95e96 to your computer and use it in GitHub Desktop.
Save kfatehi/5b15b99c764972e5d9c391aad0e95e96 to your computer and use it in GitHub Desktop.
Rebroadcast (transcode) the audio of a video livestream over Icecast.
#!/bin/bash
# You can use streamlink to extract the stream URL, e.g.:
# PL_URL=$(streamlink --stream-url https://livestream-website-url best)
# Generally figured out from this gist...
# https://gist.github.com/keiya/c8a5cbd4fe2594ddbb3390d9cf7dcac9
PL_URL=https://some.owncast-server.tv/hls/1/stream.m3u8
while ! curl -s $PL_URL | grep -q offline; do
ffmpeg -re -i $PL_URL \
-c:a libfdk_aac \
-profile:a aac_he_v2 -ab 48k \
-content_type 'audio/aac' \
-vn -f adts \
icecast://source:hackme@localhost:8000/some-name
sleep 1
echo "restarting ffmpeg"
done
echo "Stream is offline"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment