Page 1 of 1
Playing RTL-SDR radio through VLC
Posted: 13 Aug 2019 20:04
by peppy.player
I didn't find a better place for this question.
I'd like to play FM radio streams from RTL-SDR USB dongle. Here is the whole shell command for that using 'aplay' as the audio player:
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
'redsea' is for getting RDS messages (artist name, song name etc) from FM signal.
Is is possible to use 'cvlc' instead of 'aplay' ? I couldn't find a way to define sample rate and signal format as command line arguments for 'cvlc'.
If I put 'cvlc' without any arguments it doesn't work.
Thanks in advance!
Re: Playing RTL-SDR radio through VLC
Posted: 13 Aug 2019 22:03
by Rémi Denis-Courmont
If it's a proper ALSA device, it should show under Audio capture in the playlist. Otherwise, you need to open it manually with alsa:// or pulse:// followed by the device name.
Re: Playing RTL-SDR radio through VLC
Posted: 13 Aug 2019 22:22
by peppy.player
I can probably define Alsa and device using these command line arguments:
--aout=alsa --alsa-audio-device=hw
The question is more about sample rate and format of the input stream. Can 'cvlc' auto-detect that or should I specify it in a similar way as I'm doing that for 'aplay'? If the latter how can I do that?
Thanks!
Re: Playing RTL-SDR radio through VLC
Posted: 15 Aug 2019 05:36
by peppy.player
There is the option "-" for reading from 'stdin': https://wiki.videolan.org/Uncommon_uses/
So I tried:
rtl_fm -M fm -l 0 -A std -p 0 -s 171k -g 20 -F 9 -f 97.3M | redsea -e | cvlc -
and got the following messages:
VLC media player 2.2.6 Umbrella (revision 2.2.6-0-g1aae78981c)
Found 1 device(s):
0: Realtek, RTL2838UHIDIR, SN: 00000001
Using device 0: Generic RTL2832U OEM
[001b90c8] pulse audio output error: PulseAudio server connection failure: Connection refused
[001d3568] core interface error: no suitable interface module
[0011f918] core libvlc error: interface "globalhotkeys,none" initialization failed
[001d3568] dbus interface error: Failed to connect to the D-Bus session daemon: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[001d3568] core interface error: no suitable interface module
[0011f918] core libvlc error: interface "dbus,none" initialization failed
[001d3568] dummy interface: using the dummy interface module...
Found Rafael Micro R820T tuner
Tuner gain set to 19.70 dB.
Tuned to 97642000 Hz.
Oversampling input by: 8x.
Oversampling output by: 1x.
Buffer size: 5.99ms
Exact sample rate is: 1368000.013046 Hz
Sampling at 1368000 S/s.
Output at 171000 Hz.
[mp3 @ 0x73836cf0] Header missing
[mp3 @ 0x73836cf0] Header missing
[mp3 @ 0x73836cf0] Header missing
...
So it looks like vlc cannot detect the input stream format.The same question still remains - how can I define the sample rate of the input stream?
Thanks!
Re: Playing RTL-SDR radio through VLC
Posted: 15 Aug 2019 05:51
by peppy.player
If I create named pipe/fifo:
mkfifo fff
And then run:
rtl_fm -M fm -l 0 -A std -p 0 -s 171k -g 20 -F 9 -f 97.3M | redsea -e > fff
and run vlc in separate terminal:
cvlc fff
I had the same result:
[mp3 @ 0x73d39180] Header missing
mplayer also fails:
mplayer fff
MPlayer 1.3.0 (Debian), built with gcc-6.2.1 (C) 2000-2016 MPlayer Team
Playing fff.
libavformat version 57.56.101 (external)
Mismatching header version 57.56.100
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
...
Re: Playing RTL-SDR radio through VLC
Posted: 15 Aug 2019 16:57
by Rémi Denis-Courmont
VLC negotiates the sample format and sample rate automatically with the ALSA device driver, of course.
Re: Playing RTL-SDR radio through VLC
Posted: 15 Aug 2019 18:21
by peppy.player
Does it mean that vlc cannot detect input stream format? As I mentioned 'aplay' works fine if I define the sample rate and format:
aplay -r 171000 -f S16_LE
I use vlc as the main audio player in my own app. It would be a pity to switch to 'aplay' just for handling RTL-SDR radio streams. But so far I didn't find any way to make vlc working
Re: Playing RTL-SDR radio through VLC
Posted: 17 Aug 2019 07:04
by peppy.player
Just in case anybody else will need a solution here are the command line parameters which define the sample rate and format of the 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
The solution was suggested at the diyAudio forum: https://www.diyaudio.com/forums/pc-based/341527-playing-rtl-sdr-radio-vlc.html#post5886696