sound doesn't work until I login

Karl Auer kauer at biplane.com.au
Sun Sep 11 14:59:56 UTC 2016


On Sat, 2016-09-10 at 04:05 +1000, Karl Auer wrote:
> That works very well. aplay looks like it should work too, but it
> doesn't. This command:
> 
>    avconv -i file.ext -f wav - | aplay -t wav -
> 
> ...doesn't play anything on the Pi.

After a lot of investigation I decided that my choice of WAV was bad.
WAV has a file length element in the header, and that's not compatible
with a stream of indeterminate length. Since it does work on my Ubuntu
system, I'm guessing that later versions of aplay ignore those
elements when playing standard input.

Anyway, the following works to convert and play a file on the Pi (all
on one line though):

   avconv -i artifax.mp3 -f s16le -
     | aplay -f S16_LE -r 44100 -c 2 -t raw -

The downside is that the input file will always need to be stereo,
sampled at 44100Hz, but since that's pretty much all commercial music
that's OK.

If anyone with more sound know-how than I wants to suggest a more
flexible format for streaming through a pipe, do tell! I found that the
sox program "play" also works fine with ALSA, so we are not limited to
the four formats (VOC, WAV, RAW and AU) that aplay supports.

Regards, K.

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Karl Auer (kauer at biplane.com.au)
http://www.biplane.com.au/kauer
http://twitter.com/kauer389

GPG fingerprint: E00D 64ED 9C6A 8605 21E0 0ED0 EE64 2BEE CBCB C38B
Old fingerprint: 3C41 82BE A9E7 99A1 B931 5AE7 7638 0147 2C3C 2AC4







More information about the ubuntu-users mailing list