Go Back   Home > Forums > >
Home Forums Rules Articles diyAudio Store Blogs Gallery Wiki Register Donations FAQ Calendar Search Today's Posts Mark Forums Read

PC Based Computer music servers, crossovers, and equalization

Playing RTL-SDR radio through VLC
Playing RTL-SDR radio through VLC
Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 15th August 2019, 10:11 PM   #1
rpi is offline rpi  United States
diyAudio Member
 
Join Date: Apr 2015
Location: San Francisco
Default Playing RTL-SDR radio through VLC

I originally posted this question on VLC forum:
Playing RTL-SDR radio through VLC - The VideoLAN Forums
Hopefully this diyAudio forum will be more helpful.

I'm trying to add support for RTL-SDR radio to the Peppy player and facing the issue with playing the FM radio stream through VLC player.

The idea is to connect three different programs through anonymous pipes. The first program (rtl_fm) will send output to STDOUT. The second program (redsea) will recieve that stream at STDIN, will make some processing and send the result of processing to the STDERR and echo the input to STDOUT. And finally the third program (vlc) will get stream from STDIN and send it to ALSA for playback.

The flow (without program options) will look like this:
rtl_fm | redsea | cvlc


rtl_fm - decodes FM radio signal recieved by RTL-SDR USB dongle
redsea - fetches RDS messages (e.g. artist name, song name etc) from FM signal
cvlc - command line version of VLC used for audio playback

VLC has option "-" which allows the program to read audio/video stream from STDIN

The problem is that there is no sound if I use it like this: 'cvlc -'
The whole syntax looks like this:
rtl_fm -M fm -l 0 -A std -p 0 -s 171k -g 20 -F 9 -f 97.3M | redsea -e | cvlc -

But if I use 'aplay' instead of 'vlc' it works fine:
rtl_fm -M fm -l 0 -A std -p 0 -s 171k -g 20 -F 9 -f 97.3M | redsea -e | aplay -r 171000 -f S16_LE

It looks like VLC cannot automatically detect the format of the input stream. But 'aplay' works because I define the signal sample rate and format manually. In case of VLC there are the following error messages in the console:
[mp3 @ 0x73836cf0] Header missing
....

I couldn't find a way to specify signal format for VLC input stream. There are only settings for output stream.

I highly appreciate any help.
  Reply With Quote
Old 16th August 2019, 07:40 AM   #2
phofman is offline phofman  Czech Republic
diyAudio Member
 
Join Date: Apr 2005
Location: Pilsen
IMO the problem is redsea does not output any audio format, just raw stream. Whereas aplay can work with it (I would suggest specifying the remaining params (-c 1 -t raw) so that defaults are not relied on), cvlc assumes some real audio format which it does not detect - Header missing.

Why do you need cvlc? E.g. aplay, sox can pass the incoming raw stream to alsa devices correctly. VLC is a huge software, rather complicated to configure in detail.
  Reply With Quote
Old 16th August 2019, 03:15 PM   #3
rpi is offline rpi  United States
diyAudio Member
 
Join Date: Apr 2015
Location: San Francisco
I use vlc as the default audio player in Peppy. You can also choose mpd or mplayer just defining that in the config file if you want. Therefore it would be better to stay with vlc for all use cases rather than switching between players and implementing a wrapper for a new player. Why vlc? Mostly because it can play everything (has all required codecs) and has the most efficient way to control it - Python bindings and has support for video which I probably will be using in the future

You are right, the stream is the raw stream. Maybe there is a way to define that for vlc (?)
  Reply With Quote
Old 16th August 2019, 04:58 PM   #4
rpi is offline rpi  United States
diyAudio Member
 
Join Date: Apr 2015
Location: San Francisco
If aplay can output to STDOUT and can provide info required by VLC then the following chain could probably work (?):
rtl_fm | redsea | aplay | cvlc
  Reply With Quote
Old 16th August 2019, 05:04 PM   #5
CharlieLaub is offline CharlieLaub  United States
diyAudio Member
 
Join Date: Mar 2007
Location: Michigan
One alternative might be to use RTP+SDP. VLC and ffmpeg can transcode/receive RTP streams. There is the same problem, that RTP needs additional info about what is being streamed, and this is where SDP comes in. It's just a small file (text only) that contains a couple of fields about the stream. The RTP RX app must "know" about it, and typically you can specify where that info is located.

The idea is that you stream the RTP to a port on the localhost. I suggest using the port number 16384, which is reserved for UDP/TCP already, and the next few port numbers above that if you need alternatives. Then the RX app is pointed at the local port. Since it is local, there is no transmission delay or packet loss. This is something that I might try myself to send audio data between Windows and the Windows Subsystem for Linux, since the latter has no audio capability (yet).

In the past I tried streaming over my LAN using ffmpeg and VLC, and I knew ahead of time the filepath to which I would write the SDP file. I could then point the stream RX app to it. Worked great. You might give it a try instead of pipes, which have inherent latency issues in my experience. Yes, I tried that too, to send audio from one application to another on the same machine. It's not good.

P.S.
I found a couple of files containing notes I wrote myself a couple of years ago on the above concepts. I was streaming from one machine to a Raspberry Pi. They might be helpful if you want to try it out.
__________________
Visit my Audio Web Page <<--CLICK TO LEARN MORE-->> Get my LADSPA plugins

Last edited by CharlieLaub; 16th August 2019 at 05:15 PM.
  Reply With Quote
Old 16th August 2019, 05:38 PM   #6
phofman is offline phofman  Czech Republic
diyAudio Member
 
Join Date: Apr 2005
Location: Pilsen
Charlie, I think rpi wants to listen to FM radio while displaying RDS info (hence the redsea decoder)

rpi: Raw - VideoLAN Wiki , first line of code in VLC package with mp3 encoding support - Raspberry Pi Forums , VLC command-line help - VideoLAN Wiki - section Raw Audio Demuxer
  Reply With Quote
Old 16th August 2019, 06:11 PM   #7
rpi is offline rpi  United States
diyAudio Member
 
Join Date: Apr 2015
Location: San Francisco
CharlieLaub, you are right saying that pipes add some latency. Streaming in general adds some lag to the system. I think adding more links to the chain like transcoding and streaming to the port (even on localhost) overcomplicates the system. Anyway, thank you for another twist/solution

phofman, yes the idea is to get local FM radio stream, fetch artist name and song name from that stream using the 'redsea' then display the album art and lyrics for that song in Peppy player. I'm doing that right now for the Internet radio and want to do the same for FM radio. Thanks a lot for the links! I hope that's exactly what I need. I will verify that in the evening (PST) and let you know.

Last edited by rpi; 16th August 2019 at 06:17 PM.
  Reply With Quote
Old 17th August 2019, 04:58 AM   #8
rpi is offline rpi  United States
diyAudio Member
 
Join Date: Apr 2015
Location: San Francisco
Here are the cvlc parameters which make it working with raw input stream:

rtl_fm -M fm -l 0 -A std -p 0 -s 171k -g 20 -F 9 -f 97.3M | redsea -e | cvlc --demux=rawaud --rawaud-channels=1 --rawaud-samplerate=171000 --rawaud-fourcc=s16l -

The dash in the end can be replaced either by stream:///dev/stdin or fd://0
Thank you phofman!
  Reply With Quote
Old 17th August 2019, 06:43 AM   #9
phofman is offline phofman  Czech Republic
diyAudio Member
 
Join Date: Apr 2005
Location: Pilsen
Congrats to a very useful and interesting feature. I have never seen FM+RDS support in an embedded linux player. Thanks!
  Reply With Quote
Old 17th August 2019, 07:17 AM   #10
phofman is offline phofman  Czech Republic
diyAudio Member
 
Join Date: Apr 2005
Location: Pilsen
Any chance of decoding the MPX stream to stereo? There is an FM stereo demodulator in gnu radio wfm_rcv_pll, perhaps it can be used for decoding the MPX stream before feeding to cvlc somehow...
  Reply With Quote

Reply


Playing RTL-SDR radio through VLCHide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
External Radio Speaker- 1/2 Watt (yes) for Nightstand Grundig Radio SanJoseMichael Full Range 2 4th January 2018 02:17 AM
Internet Radio vs Broadcast Radio - Bandwidth ? Bigun Digital Source 13 6th December 2015 12:54 PM
Who else has a radio station still playing Christmas tunes? Geek The Lounge 7 21st February 2008 06:31 AM
what's better, a mid playing high, or a tweet playing low??? cody6766 Multi-Way 10 20th February 2005 09:40 PM


New To Site? Need Help?

All times are GMT. The time now is 11:36 AM.


Search Engine Optimisation provided by DragonByte SEO (Pro) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 14.29%
vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.
Copyright ©1999-2019 diyAudio
Wiki