Author Topic: Streaming to Multiple Icecast Servers with RTL SDR and Darkice  (Read 2683 times)

0 Members and 1 Guest are viewing this topic.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 6148
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Streaming to Multiple Icecast Servers with RTL SDR and Darkice
« Reply #25 on: April 03, 2017, 01:38:51 PM »
Ok, thanks for the explanation.  I think I'd like to continue using Darkice as I'd like to stream to the local icecast2 and to the wxradio.dyndns.org Icecast server with a new stream.

So.. what diagnostics do I need to get darkice to not have the TcpSocket connect error (and to actually run)?
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline tim273

  • Senior Member
  • **
  • Posts: 95
Re: Streaming to Multiple Icecast Servers with RTL SDR and Darkice
« Reply #26 on: April 03, 2017, 01:44:00 PM »
I took my instructions from this page: https://stmllr.net/blog/live-mp3-streaming-from-audio-in-with-darkice-and-icecast2-on-raspberry-pi/, in comment 20 at the bottom of the page someone has the same error, maybe start there.

It could be that you just need to comment out the second Icecast2 server setup in darkice.cfg and see if you can get just one to work.
« Last Edit: April 03, 2017, 01:46:38 PM by tim273 »

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 1745
    • SouthEast Lincoln, NE Weather
Re: Streaming to Multiple Icecast Servers with RTL SDR and Darkice
« Reply #27 on: April 03, 2017, 05:52:11 PM »
I've found a strange business with the frequency selection. This is my /home/pi/weather_radio.sh file:
Code: [Select]
#!/bin/sh

# Using Sox/Play with ALSA Loopback
rtl_fm -f 162.475M -s 48000 | play -q -r 48000 -t raw -e s -b 16 -c 1 -V1 -v 6 -
but this is my screen:
Code: [Select]
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Tuner gain set to automatic.
Tuned to 162727000 Hz.
Oversampling input by: 21x.
Oversampling output by: 1x.
Buffer size: 8.13ms
Exact sample rate is: 1008000.009613 Hz
Sampling at 1008000 S/s.
Output at 48000 Hz.

As you can see the tuner is set to 162.727MHz despite calling for 162.475M.  I'm not sure why this is, but my tuner is very scratchy and full of static like it's mistuned and needs refinement.  I've tried using kal but there aren't any consistent GSM base stations that I'm receiving because I'm in a cell relative dead zone and use calling over IP for my cell.

BTW I found this missing from the top of my /etc/init.d/darkice:
Code: [Select]
#! /bin/sh
### BEGI
Pasting it in solved my problem with the missing mountpoint.  I must have been really clumsy when I set this file up. :oops:
Regards, Jerry Wilkins
gwwilk@inebraska.com

Offline tim273

  • Senior Member
  • **
  • Posts: 95
Re: Streaming to Multiple Icecast Servers with RTL SDR and Darkice
« Reply #28 on: April 03, 2017, 05:58:07 PM »
I've found a strange business with the frequency selection. This is my /home/pi/weather_radio.sh file:
Code: [Select]
#!/bin/sh

# Using Sox/Play with ALSA Loopback
rtl_fm -f 162.475M -s 48000 | play -q -r 48000 -t raw -e s -b 16 -c 1 -V1 -v 6 -
but this is my screen:
Code: [Select]
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Tuner gain set to automatic.
Tuned to 162727000 Hz.
Oversampling input by: 21x.
Oversampling output by: 1x.
Buffer size: 8.13ms
Exact sample rate is: 1008000.009613 Hz
Sampling at 1008000 S/s.
Output at 48000 Hz.

As you can see the tuner is set to 162.727MHz despite calling for 162.475M.  I'm not sure why this is, but my tuner is very scratchy and full of static like it's mistuned and needs refinement.  I've tried using kal but there aren't any consistent GSM base stations that I'm receiving because I'm in a cell relative dead zone and use calling over IP for my cell.

BTW I found this missing from the top of my /etc/init.d/darkice:
Code: [Select]
#! /bin/sh
### BEGI
Pasting it in solved my problem with the missing mountpoint.  I must have been really clumsy when I set this file up. :oops:

Mine is like that too, I'm not sure why, but it's right.  For doing the PPM error correction another option you could do on a Windows machine is use SDRSharp (http://airspy.com/download/ - it's the "core SDR package") and that will give you a better idea.  Here's a guide to set that up: http://www.rtl-sdr.com/rtl-sdr-quick-start-guide/ then you can visually see the signal and adjust the PPM that way.

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 1745
    • SouthEast Lincoln, NE Weather
Re: Streaming to Multiple Icecast Servers with RTL SDR and Darkice
« Reply #29 on: April 03, 2017, 06:26:42 PM »
I've ordered a new tuner from NooElec that's been tested to be within spec.  We'll see if it helps.  My NOAA Weather Radios all get a clean, clear signal here without extending the antenna or even pulling it up to vertical, so I don't think signal quality should be an issue.
Regards, Jerry Wilkins
gwwilk@inebraska.com

Offline tim273

  • Senior Member
  • **
  • Posts: 95
Re: Streaming to Multiple Icecast Servers with RTL SDR and Darkice
« Reply #30 on: April 03, 2017, 06:34:15 PM »
I've ordered a new tuner from NooElec that's been tested to be within spec.  We'll see if it helps.  My NOAA Weather Radios all get a clean, clear signal here without extending the antenna or even pulling it up to vertical, so I don't think signal quality should be an issue.

That works.  Two things to keep in mind, the first is that the RTL SDR dongles use very cheap crystals and because of that these issues happen.  The other thing is that you can still use a regular weather radio with Darkice (or even ezstream) as it just listens to the sound card input, you just need an external sound card.  I was doing that (Raspberry Pi/Weather Radio/Darkice) for a few years when I was streaming to WU.  I updated my post to cover how to do that.

Offline satcop

  • Senior Contributor
  • ****
  • Posts: 184
    • Clifton Virginia Weather
Re: Streaming to Multiple Icecast Servers with RTL SDR and Darkice
« Reply #31 on: April 03, 2017, 08:01:53 PM »
Hi Tim;

I was trying to get two streams to self start from boot but having no joy.  It seems that darkice dumps when the rtl sdr stream is turned on.  After boot I can get both feeds to work, providing I do a sudo screen -r , than get out of that screen with a control a d and than do a sudo darkice start.  At that point both streams work.  If I don't look at the feed with the  sudo screen -r than darkice comes up but with no audio.

Bob
Clifton, Virginia Weather


Blitzortung Stations 1189, 1451 - CWOP EW1675

Offline tim273

  • Senior Member
  • **
  • Posts: 95
Re: Streaming to Multiple Icecast Servers with RTL SDR and Darkice
« Reply #32 on: April 03, 2017, 10:42:41 PM »
Hi Tim;

I was trying to get two streams to self start from boot but having no joy.  It seems that darkice dumps when the rtl sdr stream is turned on.  After boot I can get both feeds to work, providing I do a sudo screen -r , than get out of that screen with a control a d and than do a sudo darkice start.  At that point both streams work.  If I don't look at the feed with the  sudo screen -r than darkice comes up but with no audio.

Bob

I've been having a similar problem, but I had it working before, let me look it up and I'll get back to you.  As long as you get it working, that's good, you rarely need to reboot the Pi.  I've had Raspberry Pi's up for a month or more without rebooting.

Offline tim273

  • Senior Member
  • **
  • Posts: 95
Re: Streaming to Multiple Icecast Servers with RTL SDR and Darkice
« Reply #33 on: April 06, 2017, 02:33:44 PM »
Hi Everyone,

I've copied over my Raspberry Pi tutorial over to Github:

https://github.com/tim273/weather_radio_scripts

I've also put all the stuff (well almost) in there so all you won't have to copy/paste as much.  Hopefully that makes it a little easier.

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 1745
    • SouthEast Lincoln, NE Weather
Re: Streaming to Multiple Icecast Servers with RTL SDR and Darkice
« Reply #34 on: April 08, 2017, 05:14:53 PM »
Just got my new tuner for the Raspberry Pi today.  Wow!  What a difference!  The stream is very listenable, and now I want to stream it as an alternate.  I would definitely urge anyone who is contemplating going this route to buy the 'Plus' factory verified version.

I'm still not able to switch to a port other than 8000, which is a problem since I'm using that port through my firewall for my wxradio.dyndns.org feed from a weather radio. :-(

Why won't the port switch to something like 86 or 8500 when I set it to that in 'etc/darkice.cfg'?  Is there another setting that I need to use as well?  When I switch to another port using 'etc/darkice.cfg' I'm no longer able to use Chrome to access the Raspberry Pi through the new port.  When I switch 'etc/darkice.cfg back to port 8000, all is well.
Regards, Jerry Wilkins
gwwilk@inebraska.com

Offline tim273

  • Senior Member
  • **
  • Posts: 95
Re: Streaming to Multiple Icecast Servers with RTL SDR and Darkice
« Reply #35 on: April 08, 2017, 06:36:21 PM »
Just got my new tuner for the Raspberry Pi today.  Wow!  What a difference!  The stream is very listenable, and now I want to stream it as an alternate.  I would definitely urge anyone who is contemplating going this route to buy the 'Plus' factory verified version.

I'm still not able to switch to a port other than 8000, which is a problem since I'm using that port through my firewall for my wxradio.dyndns.org feed from a weather radio. :-(

Why won't the port switch to something like 86 or 8500 when I set it to that in 'etc/darkice.cfg'?  Is there another setting that I need to use as well?  When I switch to another port using 'etc/darkice.cfg' I'm no longer able to use Chrome to access the Raspberry Pi through the new port.  When I switch 'etc/darkice.cfg back to port 8000, all is well.

I have the same RTL SDR stick and it does make a difference, I also switched to a ground plane antenna and that helped too.

If you're running an Icecast2 server locally, you can change the port there and then match it in your darkice.cfg.  The icecast config file is /etc/icecast2/icecast.xml  and in mine the port is on line 61.  Look for this:

Code: [Select]
<!-- You may have multiple <listener> elements -->
    <listen-socket>
        <port>8000</port>
        <!-- <bind-address>127.0.0.1</bind-address> -->
        <!-- <shoutcast-mount>/stream</shoutcast-mount> -->
    </listen-socket>
    <!--
    <listen-socket>
        <port>8001</port>
    </listen-socket>
    -->

Then just change port 8000 to what you want and then change darkice.cfg to match.  Hopefully that should do it.  Then just restart both

Code: [Select]
sudo service icecast2 restart
sudo service darkice restart
« Last Edit: April 08, 2017, 06:38:48 PM by tim273 »

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 1745
    • SouthEast Lincoln, NE Weather
Re: Streaming to Multiple Icecast Servers with RTL SDR and Darkice
« Reply #36 on: April 08, 2017, 07:24:14 PM »
Thanks for the reply, Tim.  Changing the port to 88 in both darkice.cfg and icecast.xml leaves me unable to reconnect at 192.168.2.161:88 whereas before the change 192.168.2.161:8000 brought up the icecast2 status with links to the stream in 3 formats.  Perhaps I'm making this too difficult?
Regards, Jerry Wilkins
gwwilk@inebraska.com

Offline tim273

  • Senior Member
  • **
  • Posts: 95
Re: Streaming to Multiple Icecast Servers with RTL SDR and Darkice
« Reply #37 on: April 08, 2017, 08:38:48 PM »
Thanks for the reply, Tim.  Changing the port to 88 in both darkice.cfg and icecast.xml leaves me unable to reconnect at 192.168.2.161:88 whereas before the change 192.168.2.161:8000 brought up the icecast2 status with links to the stream in 3 formats.  Perhaps I'm making this too difficult?

Ok, I guess I'm not sure then, I thought that would do it, but I'm not sure, I haven't done that before, but here's more info: http://icecast.org/docs/icecast-2.4.0/config-file.html

Offline tim273

  • Senior Member
  • **
  • Posts: 95
Re: Streaming to Multiple Icecast Servers with RTL SDR and Darkice
« Reply #38 on: April 09, 2017, 12:35:57 PM »
I'm still not able to switch to a port other than 8000, which is a problem since I'm using that port through my firewall for my wxradio.dyndns.org feed from a weather radio. :-(

I just thought of this, you probably don't need to set up port forwarding to your computer with the weather radio because you only need to do that with incoming connections, not outgoing ones.  So you should be good to go.

Offline satcop

  • Senior Contributor
  • ****
  • Posts: 184
    • Clifton Virginia Weather
Re: Streaming to Multiple Icecast Servers with RTL SDR and Darkice
« Reply #39 on: April 21, 2017, 08:01:15 PM »
Hi Tim;

I was trying to get two streams to self start from boot but having no joy.  It seems that darkice dumps when the rtl sdr stream is turned on.  After boot I can get both feeds to work, providing I do a sudo screen -r , than get out of that screen with a control a d and than do a sudo darkice start.  At that point both streams work.  If I don't look at the feed with the  sudo screen -r than darkice comes up but with no audio.

Bob

I've been having a similar problem, but I had it working before, let me look it up and I'll get back to you.  As long as you get it working, that's good, you rarely need to reboot the Pi.  I've had Raspberry Pi's up for a month or more without rebooting.

Ok working with another pi user (he is feeding Washington DC and Baltimore with pis) we figured out how to get them to work from a cold boot.  We added:

sleep 20
service darkice restart

after the screen line and before exit in the rc.local file.  It seems that darkice may be coming up before the connection to the router is fully established and drops.

Bob
Clifton, Virginia Weather


Blitzortung Stations 1189, 1451 - CWOP EW1675

Offline tim273

  • Senior Member
  • **
  • Posts: 95
Re: Streaming to Multiple Icecast Servers with RTL SDR and Darkice
« Reply #40 on: April 21, 2017, 10:46:44 PM »
Hi Tim;

I was trying to get two streams to self start from boot but having no joy.  It seems that darkice dumps when the rtl sdr stream is turned on.  After boot I can get both feeds to work, providing I do a sudo screen -r , than get out of that screen with a control a d and than do a sudo darkice start.  At that point both streams work.  If I don't look at the feed with the  sudo screen -r than darkice comes up but with no audio.

Bob

I've been having a similar problem, but I had it working before, let me look it up and I'll get back to you.  As long as you get it working, that's good, you rarely need to reboot the Pi.  I've had Raspberry Pi's up for a month or more without rebooting.

Ok working with another pi user (he is feeding Washington DC and Baltimore with pis) we figured out how to get them to work from a cold boot.  We added:

sleep 20
service darkice restart

after the screen line and before exit in the rc.local file.  It seems that darkice may be coming up before the connection to the router is fully established and drops.

Bob

Good deal, glad that worked!

Offline CF20852

  • Member
  • *
  • Posts: 17
Re: Streaming to Multiple Icecast Servers with RTL SDR and Darkice
« Reply #41 on: April 22, 2017, 11:19:44 AM »
Tim,

Thanks for loaning us your expertise and good documentation skills.  I followed your procedure to get a couple of Raspberry Pi/R820T setups working.

I riffed off the email script you posted at https://github.com/tim273/weather_radio_scripts/blob/master/OPTIONAL.md and modified it so that it attempts to restart Darkice if it doesn't see my mountpoint up on the Icecast server.  I called this script check_darkice_up.sh, and put it in /home/pi:

Code: [Select]
#!/bin/bash

url="http://wxradio.dyndns.org:8000"
status_code=$(curl -v  $url 2>&1 | grep -o /mycity/mycallsign.mp3)
#echo "$status_code"

if [ "$status_code" == "" ]
then
    sudo /usr/sbin/service darkice restart
fi

I had to put "sudo /usr/sbin/" in front of "service darkice restart" to get it to run as a cron job.  Most of the clue on why that's necessary was posted in the first answer under https://unix.stackexchange.com/questions/179042/shell-script-issue-when-added-to-cron.  Without the "sudo," cron sent me an email at /var/mail/pi telling me the script failed at /usr/sbin/service darkice restart with an "Access denied" error.

I made the script executable:
Code: [Select]
chmod +x /home/pi/check_darkice_up.sh
Then I added a line to crontab to run it once each minute:
Code: [Select]
* * * * * /home/pi/check_darkice_up.sh
I tested it by stopping darkice using
Code: [Select]
sudo service darkice stop and letting the cron job run.  I can also run the script using:
Code: [Select]
sudo /home/pi/check_darkice_up.sh
Once I found that it runs OK as a cron job, I changed the interval to 31 minutes by changing the line in crontab to
Code: [Select]
*/31 * * * * /home/pi/check_darkice_up.sh
I should have let satcop know I was working on this, because in the middle of testing it, I got an email message to the effect that "your stream is down again!"  8-)

Chip

Offline tim273

  • Senior Member
  • **
  • Posts: 95
Re: Streaming to Multiple Icecast Servers with RTL SDR and Darkice
« Reply #42 on: April 22, 2017, 01:46:09 PM »
Tim,

Thanks for loaning us your expertise and good documentation skills.  I followed your procedure to get a couple of Raspberry Pi/R820T setups working.

I riffed off the email script you posted at https://github.com/tim273/weather_radio_scripts/blob/master/OPTIONAL.md and modified it so that it attempts to restart Darkice if it doesn't see my mountpoint up on the Icecast server.  I called this script check_darkice_up.sh, and put it in /home/pi:

Code: [Select]
#!/bin/bash

url="http://wxradio.dyndns.org:8000"
status_code=$(curl -v  $url 2>&1 | grep -o /mycity/mycallsign.mp3)
#echo "$status_code"

if [ "$status_code" == "" ]
then
    sudo /usr/sbin/service darkice restart
fi

I had to put "sudo /usr/sbin/" in front of "service darkice restart" to get it to run as a cron job.  Most of the clue on why that's necessary was posted in the first answer under https://unix.stackexchange.com/questions/179042/shell-script-issue-when-added-to-cron.  Without the "sudo," cron sent me an email at /var/mail/pi telling me the script failed at /usr/sbin/service darkice restart with an "Access denied" error.

I made the script executable:
Code: [Select]
chmod +x /home/pi/check_darkice_up.sh
Then I added a line to crontab to run it once each minute:
Code: [Select]
* * * * * /home/pi/check_darkice_up.sh
I tested it by stopping darkice using
Code: [Select]
sudo service darkice stop and letting the cron job run.  I can also run the script using:
Code: [Select]
sudo /home/pi/check_darkice_up.sh
Once I found that it runs OK as a cron job, I changed the interval to 31 minutes by changing the line in crontab to
Code: [Select]
*/31 * * * * /home/pi/check_darkice_up.sh
I should have let satcop know I was working on this, because in the middle of testing it, I got an email message to the effect that "your stream is down again!"  8-)

Chip

Great Job!  I added your script to the Github repository.  I'll update the documentation as well a little later (got some errands to run).

 

anything