My problem is very long recordings, longer than supported by WAV. I'm talking about continuous recordings of around eight hours in length.

Now, I do most of my recording using sox into FLAC, which makes the most sense, since those are live recordings from an external sound card.

Now, I'd like to encode that into MP3 or into AAC (in an MP4 container).

The only way I managed to do that, is using FFmpeg, but I'd actually rather use an encoder application like lame, or neroaacenc.

Now, I was doing that where possible, but I was using WAV as a detour. I was decoding the FLAC into WAV and then encoding the WAV into the end product. But as I said, it doesn't work for recordings over a certain length.

Now, my idea was to use pipes and force decoding into RAW and then encode that into the target format.

I need some help with this. Could someone please supply me with some examples how to decode a FLAC file, and encode that into MP3 using lame by piping RAW data?

2 Answers 2


You should try something like:

flac -c -d -force-raw-format --endian=little --signed=unsigned input.flac | \
  lame -r --little-endian --unsigned \
       -s 44.1 [other encoding options here] - output.mp3

On the flac side:

  • -c means output to stdout
  • -d decode
  • -force-raw-format --endian=little --signed=unsigned force RAW, little-endian, unsigned output

On the lame side:

  • - read from stdin (this is nearly standard)
  • -r read RAW pcm data
  • --little-endian --unsigned match what lame outputs
  • -s frequency: match that parameter with what your flac file contains
  • You might need --bitwidth if your flac file isn't 16bits/sample

Concerning the endian-ness and signed-ness, not sure what the "native" format you have is (or how to determine that) - try a few combinations. As long as they match on both sides of the pipe, picking the wrong one should only cost CPU time.

  • Doesn't work, it'll use WAV format, which does not work on the files I have, since they're way over 4GB in size. I have to use RAW. I was trying your example a while ago, doesn't work, obviously. I have to use --fore-raw-format and then lame needs to know how the stream is composed, that's where I have my problems (endian, sample size, etc. I tried a couple of times, but it didn't work).
    – polemon
    Commented May 1, 2012 at 13:38
  • Nope, the encoder fails at encoding a stream it does not know what it is composed of.
    – polemon
    Commented May 1, 2012 at 13:42
  • Sorry about that, I think I finally got what your actual problem was. Edited. Does that appear to work for you?
    – Mat
    Commented May 1, 2012 at 14:13
  • Yup, this is what I had in mind, I'll test it in the morning.
    – polemon
    Commented May 2, 2012 at 17:29
  • Yeah, it works; those are my options: flac -d --force-raw-format --endian=little --sign=signed <file>.flac -c | lame -r -s 48 - <file>.mp3. I use mostly default values. The file in this example: Endian: little, Channels: 2, Sample rate: 48kHz, Sign: signed, Bits per sample: 16.
    – polemon
    Commented May 5, 2012 at 15:36

Consider using mp3fs. This User Space Filesystem daemon creates a view on your filesystem where flac files are presented as mp3's. Once installed, you can have eg. your media player read from that filesystem directly, even though the mp3's do not physically exist. Also, you can just copy files from that filesystem for eg. you mp3 player.

  • 1
    Although this works, mp3fs only supports constant bitrate MP3 files. Not the best quality for a given endresult file size.
    – Anthon
    Commented Feb 18, 2014 at 11:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .