I've installed sox and now this whole thing is freaking out :) I'm trying to get sox to record a flac file for me.

aplay and arecord work ok:

pi@raspberrypi /tmp $ arecord -d 3 test1.wav
Recording WAVE 'test1.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono

pi@raspberrypi /tmp $ aplay test1.wav
Playing WAVE 'test1.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono

sox will convert the wav to flac with some warnings - I guess I can work out them later:

pi@raspberrypi /tmp $ sox test1.wav test1.flac channels 1 rate 16k
sox WARN rate: rate clipped 40 samples; decrease volume?
sox WARN dither: dither clipped 37 samples; decrease volume?

It sounds like a valid flac:

pi@raspberrypi /tmp $ mplayer test1.flac
Playing test1.flac.
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
libavcodec version 53.35.0 (external)
Mismatching header version 53.32.2
AUDIO: 16000 Hz, 1 ch, s16le, 38.1 kbit/14.89% (ratio: 4766->32000)
Selected audio codec: [ffflac] afm: ffmpeg (FFmpeg FLAC audio)

But when I'm trying to record anything with sox it will fail:

pi@raspberrypi /tmp $ rec -c 1 some.flac -t flac -r 16000 trim 0 0:05
rec WARN alsa: can't encode 0-bit Unknown or not applicable
Segmentation fault

What can I do to fix this?

  • 1
    I found a post explaining this a bit and was able to get rid of the first message by removing libsox-fmt-alsa. It hasn't helped recording though. I am going to build sox from its most recent sources to see if the fixes claimed have solved the issue.
    – abolotnov
    Commented Jan 29, 2013 at 19:39
  • Please write what external sound card are you using. From your post I can see that you are trying to record from a playback-only device.
    – dicoder
    Commented Feb 28, 2013 at 12:57
  • Try adding -t alsa at the end
    – Pablo A
    Commented May 18, 2023 at 19:20

1 Answer 1


Solution here: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=13088

export AUDIODEV=hw:1,0

export AUDIODRIVER=alsa

Of course you may have to adapt hardware id, guess it from arecord -l

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.