HydrogenAudio

Lossy Audio Compression => MP3 => Topic started by: khanfluence on 2020-09-17 06:08:31

Title: How to pipe SoX to LAME
Post by: khanfluence on 2020-09-17 06:08:31
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 (https://wiki.hydrogenaud.io/index.php/LAME#Resampling), and I'm lost on how to do so. I believe LAME requires a PCM input as mentioned here (https://hydrogenaud.io/index.php?topic=117535.0). 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:

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

Thanks.
Title: Re: How to pipe SoX to LAME
Post by: bennetng on 2020-09-17 12:01:01
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)

Title: Re: How to pipe SoX to LAME
Post by: john33 on 2020-09-17 12:49:59
Or, you could use lamedropXPd3, available in 32 and 64 bit flavours, which uses the SoX resampling libarary, always assuming you're on Windows. ;)
Title: Re: How to pipe SoX to LAME
Post by: khanfluence on 2020-09-17 16:44:30
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.
Title: Re: How to pipe SoX to LAME
Post by: AiZ on 2020-09-17 20:05:56
john33 - thanks, but this will end up as a foobar2000 preset.
Ouch...
A new resampler DSP for foobar2000 (https://hydrogenaud.io/index.php?topic=67373.0)
Title: Re: How to pipe SoX to LAME
Post by: khanfluence on 2020-09-17 22:33:16
I'm aware - I want to be comfortable with the more hands-on, exposed process before I use that.
Title: Re: How to pipe SoX to LAME
Post by: ThaCrip on 2021-03-31 08:54:13
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.
SimplePortal 1.0.0 RC1 © 2008-2021