Advertisement
zefie

pi icecast to fm with rds metadata via pifmrds

Mar 6th, 2019
453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.31 KB | None | 0 0
  1. #!/bin/bash
  2. FRQ=88.5
  3. SID=0420
  4. PPM=22
  5. SSID="TEST"
  6. F_RDS="TEST"
  7. F_FILE="http://10.42.0.13:5738/stream"
  8. F_META="http://10.42.0.13:5738/rds.xsl"
  9. F_CTL="/root/_fmctl"
  10.  
  11.  
  12. Z_RAD_PID=0
  13.  
  14. trap ctrl_c INT
  15.  
  16. function ctrl_c() {
  17.         echo "** Caught CTRL-C"
  18.         if [ ${Z_RAD_PID} > 0 ] ; then
  19.                 echo "** Stopping transmission"
  20.                 kill ${Z_RAD_PID} 2>/dev/null
  21.                 if [ -e "${F_CTL}" ]; then
  22.                         echo "** Cleaning up transmitter control pipe"
  23.                         rm -f "${F_CTL}"
  24.                 fi
  25.  
  26.                 exit
  27.         fi
  28. }
  29.  
  30. if [ ! -e "${F_CTL}" ]; then
  31.         mkfifo "${F_CTL}"
  32. fi
  33.  
  34. cd /home/pi/dev/rpitx
  35. ffmpeg -loglevel warning -i "${F_FILE}" -c:a pcm_s16le -ac 2 -ar 48000 -f wav - | \
  36. ./pifmrds -freq ${FRQ} -ppm ${PPM} -pi ${SID} -ps ${SSID} -rt "${F_RDS}" -ctl "${F_CTL}" -audio - &
  37. Z_RAD_PID=$!
  38.  
  39.  
  40. METADATA=""
  41. METADATA_L=""
  42. while (true); do
  43.         METADATA=$(curl -sL "${F_META}")
  44.         if [ "${METADATA}" != "${METADATA_L}" ]; then
  45.                 if [ -e "${F_CTL}" ]; then
  46.                         # ctl stuff
  47. #                       echo "PS ${SSID}" > "${F_CTL}"
  48.                         echo "RT ${METADATA}" > "${F_CTL}"
  49.                 fi
  50.                 METADATA_L="${METADATA}"
  51.         fi
  52.         sleep 3;
  53. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement