This script wraps ffmpeg to pull a single Quran radio feed, add a live-updating title overlay, and restream it to multiple Telegram live-stream keys.
ffmpegandffprobe- writable runtime directory for the title file (
$TITLE_FILEor default) - network access to the source radio feed and Telegram RTMPS endpoints
| Variable | Purpose | Default |
|---|---|---|
STREAM_URL |
Source audio stream URL | https://backup.qurango.net/radio/tarateel |
TEE_TARGETS |
Pipe-separated tee muxer targets | hard-coded list of RTMPS endpoints |
TITLE_FILE |
Path to text file read by drawtext |
%t/radio-title.txt (systemd runtime dir) |
DEFAULT_TITLE |
Fallback overlay text | Quran Radio |
FONT |
Font file for drawtext | /usr/share/fonts/truetype/noto/NotoSansArabic-Bold.ttf |
Override any of them in the launching environment; most importantly supply fresh Telegram stream keys through TEE_TARGETS.
STREAM_URL=https://backup.qurango.net/radio/tarateel \
TEE_TARGETS='[f=flv:onfail=ignore:flvflags=no_duration_filesize]rtmps://dc4-1.rtmp.t.me/s/1305…|[f=flv:onfail=ignore:flvflags=no_duration_filesize]rtmps://dc4-1.rtmp.t.me/s/1409…' \
DEFAULT_TITLE='Quran Radio' \
FONT=/usr/share/fonts/truetype/noto/NotoSansArabic-Bold.ttf \
TITLE_FILE=/run/user/$(id -u)/radio-title.txt \
/usr/bin/env bash scripts/radio_stream.shThe script will:
- Fetch the current
StreamTitleviaffprobeand write it to$TITLE_FILE. - Spawn
ffmpegwith a still black background anddrawtextoverlay that reloads the file on metadata updates. - Restream audio/video to every target specified in
TEE_TARGETSusing theteemuxer.
Watch stderr (or the systemd journal) for lines like Metadata update for StreamTitle: to confirm overlay refreshes.
Create ~/.config/systemd/user/radio.service (adjust paths and keys):
[Unit]
Description=quran radio
After=network.target
[Service]
Type=exec
Restart=always
RestartSec=5
RuntimeMaxSec=1h
Environment=STREAM_URL=https://backup.qurango.net/radio/tarateel
Environment=TITLE_FILE=%t/radio-title.txt
Environment=DEFAULT_TITLE=Quran Radio
Environment=FONT=/usr/share/fonts/truetype/noto/NotoSansArabic-Bold.ttf
Environment=TEE_TARGETS=[f=flv:onfail=ignore:flvflags=no_duration_filesize]rtmps://dc4-1.rtmp.t.me/s/1305…|[f=flv:onfail=ignore:flvflags=no_duration_filesize]rtmps://dc4-1.rtmp.t.me/s/1409…|[f=flv:onfail=ignore:flvflags=no_duration_filesize]rtmps://dc4-1.rtmp.t.me/s/1420…|[f=flv:onfail=ignore:flvflags=no_duration_filesize]rtmps://dc1-1.rtmp.t.me/s/1478…
ExecStart=/usr/bin/env bash /home/USERNAME/radio_stream.sh
MemoryMax=256M
CPUQuota=100%
PrivateTmp=true
ProtectSystem=full
NoNewPrivileges=true
ProtectControlGroups=true
ProtectKernelTunables=true
RestrictAddressFamilies=AF_INET AF_INET6
RestrictNamespaces=true
RestrictRealtime=true
SystemCallArchitectures=native
[Install]
WantedBy=default.targetReplace every
…with the full Telegram stream key and swapUSERNAMEfor your login. Keep the keys fresh whenever you start a new live session.
If you want the service to survive logouts, enable linger with loginctl enable-linger USERNAME.
systemctl --user daemon-reload
systemctl --user enable --now radio.service
# Monitor logs
journalctl --user-unit radio.service -fIf only one output goes live, ensure each Telegram channel is in “Go Live” state and that all keys inside TEE_TARGETS are current. The onfail=ignore flag keeps other outputs running when any single destination rejects the publish.