How to encode huge FLAC files into MP3 and other files like AAC

audioflacmp3recording

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?

Best Answer

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.

Related Question