Open pilovis opened 6 years ago
notes: with the above script and PiFM trasmitter running, the total CPU usage on a Pi2 overclocked at 1000 Mhz, is about 40% The total memory usage is less than 50 Mbytes.
You can also create a list of MP3 files to be played in sequence by sox, or better have your own broadcasting station using MPD, see my other how-to here: https://github.com/ChristopheJacquet/PiFmRds/issues/73
If you want to launch this customized "rebroadcasting FM transmitter" at startup, just put the following line in the "/etc/rc.local" file, just before the "exit 0" line:
/bin/sh /root/inject-title.sh
WARNING: do not launch any script or program, before or after this script, that is using audio otherwise you will have big audio problems (slow speed audio reproduction, like a 45s vinyl disk reproduced at 33 speed) and this is a real bug of this program that should be corrected by the programmers of PiFmAdv
Another old bug still present and unresolved:
Program quits after 3-4 hours with error: "Could not rewind in audio file. Terminating"
see: https://github.com/ChristopheJacquet/PiFmRds/issues/6 and https://github.com/ChristopheJacquet/PiFmRds/issues/16
I partially mitigated this problem by increasing the sox buffer to 65536 and by rebooting the FM radio trasmitter every hour (1 minute downtime).
sudo crontab -e
and there you have to make the following new entry (in a new line):
0 */1 * * * /sbin/reboot
does no refresh the song, here are a one solution edit a bin of a notepad
while true do
/usr/local/bin/ffprobe 2> /dev/null -show_format http://stream.srg-ssr.ch/m/rsp/mp3_128 | grep TAG:StreamTitle= | cut -d '=' -f 2 | /usr/bin/perl -ne 'print "PS 'RADIO-88'\nRT $_"' | cat > rds_ctl
sleep 10 exit 0
save the sh and rename notepad to inject-title.sh on the folder on PiFmAdv on pi folder user, no ROOT (root its no necesary, delete this folder and script of root folder with sudo nautilus on terminal)
so now, open a terminal open the folder cd Desktop. and cd PiFmAdv. and cd src mode supersu : sudo su sudo /bin/sh /root/inject-title.sh & cat >rds_ctl &
and insert this for funcionality
sox -t mp3 http://stream.srg-ssr.ch/m/rsp/mp3_128 -t wav - | sudo ./pi_fm_adv --gpio 20 --audio - --pty 9 --freq 88.0 --ctl rds_ctl
its ok, now refresh the tittle and artist song, only this song artist is end, and pass the next song artist , the tittle song and artist apears
100% funcionally
Rebroadcast internet or local streaming radio to FM with updated Artist and Song name in RDS text
The scope of this How-To is to be able to extract song info and put it into the RT field of RDS in pseudo real time (10 seconds delay)
This is not an issue but a 'How-To', sorry but I didn't find anywhere to put this.
0) prerequisites
install PiFmAdv as user "root" in /root directory, do not install the program as "Pi" user.
1) install ffmpeg (because we need the ffprobe command to do the job):
download and compile ffmpeg from the source. https://www.ffmpeg.org/download.html the current version is ffmpeg-4.0.2.tar.bz2
IMPORTANT NOTE: on Pi2 the above FFMPEG compile process takes several hours to be completed!! Be extremely patient.
2) this is my script to do the dirty job:
sudo nano /root/inject-title.sh
note: I put rds_ctl file in /tmp (RAM tmpfs) to avoid wearing out the SD card.
4) give the right permissions to the above script:
sudo chmod 755 /root/inject-title.sh
5) launch the script and it's done:
sudo /bin/sh /root/inject-title.sh &
note: after a few seconds delay the FM radio should start transmitting on 88.0 Mhz with "RADIO-88" station name.
6) to stop the FM transmitter and all related processes, use the following command:
sudo killall pi_fm_adv
Enjoy Maurizio