sound doesn't work until I login
Nils Kassube
kassube at gmx.net
Sun Sep 11 16:27:47 UTC 2016
Karl Auer wrote:
> 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.
I'm directly using sox in my script to play music - this is the relevant
line:
sox -q "$file" -t wav - vol $vol 2>/dev/null |
aplay -q -t wav &>/dev/null
This isn't limited to 44.1 kHz stereo. The files in my music collection
are using various sample rates, mostly 48 kHz and 44.1 KHz. OTOH, I
didn't try it on a Raspberry Pi.
Nils
More information about the ubuntu-users
mailing list