Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: How to pipe SoX to LAME (Read 4344 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How to pipe SoX to LAME

Hi,

I'm trying to convert 24-bit, 48+ kHz FLAC to 44.1 kHz MP3 V0. I want to use SoX to resample before invoking LAME as suggested here, and I'm lost on how to do so. I believe LAME requires a PCM input as mentioned here. I think my closest attempt has been:
Code: [Select]
sox.exe input.flac -t wav - rate 44100 | lame.exe - -V 0 output.mp3
which results in:
Code: [Select]
Unsupported data format: 0x3F3F
Can't init infile '-'
from LAME. I've also tried:
  • `-t wavpcm` for SoX output, which is accepted by LAME, but results in garbage.
  • trying to match raw output/input between SoX and LAME:
    Code: [Select]
    sox.exe input.flac -t raw -c 2 -e signed-integer -L - rate 44100 | lame.exe -r -s 44.1 --bitwidth 24 --signed --little-endian - -V 0 output.mp3
    which produces different garbage.

I'm not very familiar with audio processing. What's a correct way to do this?

Thanks.

Re: How to pipe SoX to LAME

Reply #1
Code: [Select]
sox -V3 -G 2448.flac -t wav -r 44100 - | lame -V 0 - 44k.mp3
sox:      SoX v14.4.2
sox INFO formats: detected file format type `flac'

Input File     : '2448.flac'
Channels       : 2
Sample Rate    : 48000
Precision      : 24-bit
Duration       : 00:00:19.78 = 949519 samples ~ 1483.62 CDDA sectors
File Size      : 1.36M
Bit Rate       : 549k
Sample Encoding: 24-bit FLAC
Endian Type    : little
Reverse Nibbles: no
Reverse Bits   : no


Output File    : '-' (wav)
Channels       : 2
Sample Rate    : 44100
Precision      : 24-bit
Duration       : 00:00:19.78 = 872370 samples = 1483.62 CDDA sectors
Sample Encoding: 24-bit Signed Integer PCM
Endian Type    : little
Reverse Nibbles: no
Reverse Bits   : no
Comment        : 'Processed by SoX'

sox INFO sox: effects chain: input        48000Hz  2 channels
sox INFO sox: effects chain: gain         48000Hz  2 channels
sox INFO sox: effects chain: rate         44100Hz  2 channels
sox INFO sox: effects chain: gain         44100Hz  2 channels
sox INFO sox: effects chain: output       44100Hz  2 channels
sox INFO gain: 0.578dB not reclaimed
LAME 3.100.1 32bits (http://lame.sf.net)
CPU features: MMX (ASM used), SSE (ASM used), SSE2
polyphase lowpass filter disabled
Encoding <stdin> to 44k.mp3
Encoding as 44.1 kHz j-stereo MPEG-1 Layer III VBR(q=0)


Re: How to pipe SoX to LAME

Reply #2
Or, you could use lamedropXPd3, available in 32 and 64 bit flavours, which uses the SoX resampling libarary, always assuming you're on Windows. ;)

Re: How to pipe SoX to LAME

Reply #3
Solved. I feel bad - I'm not a Windows CLI person and was using PowerShell, which apparently pipes objects. I tried it on Linux, and it worked fine, which then made me try it with cmd. Glad I had the usage right.

john33 - thanks, but this will end up as a foobar2000 preset.


Re: How to pipe SoX to LAME

Reply #5
I'm aware - I want to be comfortable with the more hands-on, exposed process before I use that.

Re: How to pipe SoX to LAME

Reply #6
I'm trying to convert 24-bit, 48+ kHz FLAC to 44.1 kHz MP3 V0. I want to use SoX to resample before invoking LAME. I'm not very familiar with audio processing. What's a correct way to do this?

Personally I would just use Foobar2000 (like you brought up) and convert the 'HD FLAC' files to standard 16/44.1 using the SoX plugin for Foobar2000 (i.e. https://hydrogenaud.io/index.php/topic,67376.0.html (if this is outdated, feel free to correct me)). once you do that it makes it easy to convert your FLAC files (which will now be standard @ 16/44.1) to MP3 since you will be at AUDIO CD standards which we have had for along time now. so conversion will always be nice and easy in Foobar2000 from lossless (i.e. FLAC etc) to lossy (i.e. MP3/AAC etc) and you don't have to worry about any potential conversion problems.

plus, if I understand it correctly... while converting from "HD FLAC" (i.e. 24-bit/48Khz+ (and the like)) to standard FLAC (16/44.1) is not a lossless process (technically speaking), it's pretty much a lossless process since the sound quality on the original 'HD FLAC' vs 'standard FLAC' will be basically the same to peoples ears, which is the true test.

NOTE: I know some of those perfectionist/purist types of people might prefer to keep their original 'HD FLAC', but I would definitely opt for the 16/44.1 standard. plus, as a bonus with standard 16/44.1 is it shaves off quite a bit of file size over 'HD FLAC' files which is all the more reason to stick with standard 16/44.1 FLAC and, to state the obvious, standard 16/44.1 is never going to become 'outdated' to the human ear since it appears 16/44.1 is already more than high enough quality to begin with.
For music I suggest (using Foobar2000)... MP3 (LAME) @ V5 (130kbps). NOTE: using on AGPTEK-U3 as of Mar 18th 2021. I use 'fatsort' (on Linux) so MP3's are listed in proper order on AGPTEK-U3.