Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
OK, perhaps the trouble is that I don't understand exactly what you mean by "linux satellite receiver". Is this separate hardware, a computer, or what? I think I'm beyond the limits of my competency here.
I presumed his satellite receiver is connected to the internet and can receive radio stations that stream online, so I've suggested an SDR or probably closer to what he needs is Radio Tray
root@zegmma-p:~# aplay -D sysdefault:Set Music/Pralka.wav
Playing WAVE 'Music/Pralka.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
The command above can play via USB sound dongle the "Pralka.wav" file, parallel to watching TV and/or even Sat receiver is in standby mode. Of course soundbar is connected to USB dongle via 3,5 mm Jack cable.
But when mpg123 is used, I got an error:
Code:
root@zegmma-p:~# mpg123 -D sysdefault:Set test.mp3
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
version 1.25.11; written and copyright by Michael Hipp and others
free software (LGPL) without any warranty but with best wishes
[../mpg123-1.25.11/src/libout123/modules/pulse.c:107] error: Failed to open pulse audio output: Connection refused
[../mpg123-1.25.11/src/libout123/libout123.c:454] error: Found no driver out of [pulse] working with device <default>.
main: [../mpg123-1.25.11/src/mpg123.c:313] error: out123 error 3: failure loading driver module
So now the problem is. How to play mp3 stream/file without pulseaudio from CLI? Any idea?
[ EDIT]
Maybe using ffmpeg without video output with redirection to USB, transcode in pipe mp3 -> wav?
Last edited by mackowiakp; 08-25-2020 at 07:51 AM.
So now the problem is. How to play mp3 stream/file without pulseaudio from CLI? Any idea?
This is very simple. You can stream PCM output from mpg123 to standard output and pipe it to aplay. From the mpg123 manpage
Code:
NAME
mpg123 - play audio MPEG 1.0/2.0/2.5 stream (layers 1, 2 and 3)
SYNOPSIS
mpg123 [ options ] file-or-URL...
DESCRIPTION
mpg123 reads one or more files (or standard input if ``-'' is specified) or URLs and plays them on the audio device (default) or outputs them to stdout. file/URL is as‐
sumed to be an MPEG audio bit stream.
....
-s, --stdout
The decoded audio samples are written to standard output, instead of playing them through the audio device. This option must be used if your audio hardware is not
supported by mpg123. The output format per default is raw (headerless) linear PCM audio data, 16 bit, stereo, host byte order (you can force mono or 8bit).
You would pipe the mpg123 output to aplay as follows:
Code:
$mpg123 --stdout test.mp3 | aplay -D sysdefault:Set --file-type raw --format=cd
This assumes that mpg123 outputs cd format audio.
Code:
The available format shortcuts are:
-f cd (16 bit little endian, 44100, stereo) [-f S16_LE -c2 -r44100]
If you don't specify a filename for aplay it will default to reading the standard input from the pipe.
Code:
NAME
arecord, aplay - command-line sound recorder and player for ALSA soundcard driver
SYNOPSIS
arecord [flags] [filename]
aplay [flags] [filename [filename]] ...
DESCRIPTION
arecord is a command-line soundfile recorder for the ALSA soundcard driver. It supports several file formats and multiple soundcards with multiple devices. If recording
with interleaved mode samples the file is automatically split before the 2GB filesize.
aplay is much the same, only it plays instead of recording. For supported soundfile formats, the sampling rate, bit depth, and so forth can be automatically determined from
the soundfile header.
If filename is not specified, the standard output or input is used. The aplay utility accepts multiple filenames.
Last edited by tofino_surfer; 08-25-2020 at 06:05 PM.
Where $url - URL of the radio internet station stream.
The problem, however, is that mpg123 supports HTTP streams but not HTTPS. And about 20% of stations use HTTPS.
That's why I use the following command to play the station (script fragment):
So where is FIFO pipe file used, located in RAM (to eliminate FLASH usage). In this case CURL is responsible for Internet transmission not mpg123 itself. Now it works properly with HTTPS transmitted stations, but not with all HTTP streams.
First command (without CURL) works perfectly with all HTTP based sources.
For example, two URLs that can be inserted in place of the $url variable in both commands.
The first address works fine with CURL but the second one does not. But using the first command, both works properly.
All you would have to do is use an if else structure to run different commands depending on whether the url has https:// in it or not. You can use grep with the --quiet flag to return an exit code of 0 with a match.
Code:
if echo $url | grep --quiet "https://"; then
/usr/bin/curl -Ls $url -o /dev/shm/pipe & mpg123 --stdout /dev/shm/pipe | aplay -D sysdefault:Set --file-type raw --format=cd &
else
mpg123 --stdout $url | aplay -D sysdefault:Set --file-type raw --format=cd &
fi
Yep. I use similar script but with "grep -c" instead "grep --quiet".
So far, I have not found an HTTPS broadcast station that does not work with this script.
But as the connection was made via Bluetooth, all stations were played correctly using CURL. No matter if HTTP or HTTPS.
It's a bit strange. And so for my curiosity. Maybe someone knows what the problem is?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.