Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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 encoder applications like lame, or neroaacenc.

Now, I was doing that where possible, but I was uising 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 forcing decoding into RAW and then encode that into the target format.

Now, I'd 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?

share|improve this question

1 Answer

up vote 4 down vote accepted

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.

share|improve this answer
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 May 1 '12 at 13:38
Nope, the encoder fails at encoding a stream it does not know what it is composed of. – polemon May 1 '12 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 May 1 '12 at 14:13
Yup, this is what I had in mind, I'll test it in the morning. – polemon May 2 '12 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 May 5 '12 at 15:36
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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