View Single Post
  #423 (permalink)  
Old 07-01-2018, 9:55 AM
boatbod boatbod is offline
Join Date: Mar 2007
Location: Talbot Co, MD
Posts: 1,135

Originally Posted by falcongsr View Post
Hello. This is awesome.

I just got my Pi 3B+ set up. One of the things I prefer to do is to stream audio over mp3 to my phone. I'm sharing how I am doing this here in case it helps someone and maybe someone can suggest a simpler method for doing this.

How I stream mp3 audio from a Pi with other (non-SDR) radios.
- add a USB sound card to the Pi
- connect the audio out of the radio to the input of the sound card
- use VLC to encode the mp3 and serve the stream.

The VLC stream can be played directly by the phone in a browser or with the VLC client on the phone. With the VLC client you can adjust the latency and keep it low even streaming over the internet.

For op25 I have added a USB sound card (Behringer UCA222) and I send the decoded audio out of this device and then wrap it back into the inputs with an RCA cable physically connecting the outputs to the inputs.

For sending the audio out, the -U command is causing heavy stuttering and is completely unusable. This was also the case with the default sound card on the Pi (the headphone jack). So instead I am using netcat | aplay which works OK for either the headphone jack or the USB sound card.

./ setup for netcat | aplay : -w -W -u 56122

netcat | command for USB sound card: nc -kluvw 1 56122 | aplay -c1 -f S16_LE -r 8000 -D plughw:CARD=CODEC,DEV=0
(I used aplay -L to get the -D information)

vlc command: cvlc -vvv pulse://alsa_input.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo --sout '#transcode{acodec=mp3,ab=48,channels=1}:standard{ access=http,dst=}'
(used pacmd list-sources to get the pulse:// information)

Listen to the mp3 stream use "Pi_IP_Address:1234/audio.mp3" in a browser, or for the VLC client you'll need to specify http:// in front of the string.

My questions:

- Is there a better way to send audio to the sound card other than netcat | aplay? Like I said -U stuttering heavily so I'm not sure if it handles underruns better than netcat | aplay. I assume I'm losing some audio because of underruns. The op25 documentation mentions an "" but I cannot find it.

- It would be great to get rid of the sound card obviously. In the past I had lots of trouble streaming rtl_fm streams because of the squelch causing the stream data to stop. boatbod's posts seem to suggest this is being handled cleanly for op25 so there might be a way to send audio info to VLC without having to use extra hardware.

Thank you for all of the contributions and helpful discussions.
Whose version of op25 are you using? It makes a difference to how the alsa buffers are assigned and used. Plenty of people use -U but there might be things you need to do to optimize the installation on a pi3. (Reduce the sample rate is the single biggest help)

Have you experimented with loopback driver "aloop"? Two sound cards is definitely not the way I'd attempt to set up a loopback...
Reply With Quote