IPB

Welcome Guest ( Log In | Register )

Sox command line to downsample Pcm to Flac
andrewfg
post Nov 18 2012, 23:06
Post #1





Group: Members
Posts: 84
Joined: 12-May 08
Member No.: 53478



Can anyone please tell me the switches needed for downsampling hi-res Pcm (Std_In) to lo-res Flac (Std_Out)?

I am trying the following, but at 192000Hz neither the big nor little endian variety works.

CODE
sox.exe -q -t raw -s -b24 -c2 -r192000 -L - -t flac -C0 - rate 48000 => outputs distorted audio
sox.exe -q -t raw -s -b24 -c2 -r192000 -B - -t flac -C0 - rate 48000 => outputs white noise

Whereas (oddly enough) at 96000Hz the little endian works, but the big endian does not.

CODE
sox.exe -q -t raw -s -b24 -c2 -r96000 -L - -t flac -C0 - rate 48000 => works !!
sox.exe -q -t raw -s -b24 -c2 -r96000 -B - -t flac -C0 - rate 48000 => outputs white noise

Don't ask me why, but the fact that at 96000Hz an extra byte order flip makes a difference to the success rate, gives me a gut feeling that sox.exe is somehow hitting an internal timing issue or lack of CPU capacity (e.g. thread timing issue?).


--------------------
AndrewFG (Whitebear -- http://www.whitebear.ch/mediaserver )
Go to the top of the page
+Quote Post
 
Start new topic
Replies
JJZolx
post Nov 20 2012, 02:43
Post #2





Group: Members
Posts: 396
Joined: 26-November 04
Member No.: 18345



I just tried this out for myself and it worked fine in all four cases. I started with 24/96 and 24/192 FLAC files and tested it two ways, each with the same results. First by using flac.exe to decode the FLACs to individual .pcm files with the desired endianness, and feeding these files into SoX, and then by just piping the output of flac.exe directly into SoX.

Here are the command lines for the latter. The SoX parts are exactly like yours:

CODE
flac.exe -dc "File96.flac" --force-raw-format --sign=signed --endian=little -- | sox.exe -q -t raw -s -b24 -c2 -r96000 -L - -t flac -C0 "File96_L_48.flac" rate 48000
flac.exe -dc "File96.flac" --force-raw-format --sign=signed --endian=big -- | sox.exe -q -t raw -s -b24 -c2 -r96000 -B - -t flac -C0 "File96_B_48.flac" rate 48000
flac.exe -dc "File192.flac" --force-raw-format --sign=signed --endian=little -- | sox.exe -q -t raw -s -b24 -c2 -r192000 -L - -t flac -C0 "File192_L_48.flac" rate 48000
flac.exe -dc "File192.flac" --force-raw-format --sign=signed --endian=big -- | sox.exe -q -t raw -s -b24 -c2 -r192000 -B - -t flac -C0 "File192_B_48.flac" rate 48000


You're not actually starting with PCM files, are you? I'd guess that whatever you're piping into SoX isn't the format that you expect.

This post has been edited by JJZolx: Nov 20 2012, 02:50
Go to the top of the page
+Quote Post
andrewfg
post Nov 22 2012, 11:14
Post #3





Group: Members
Posts: 84
Joined: 12-May 08
Member No.: 53478



QUOTE (JJZolx @ Nov 20 2012, 02:43) *
I just tried this out for myself and it worked fine in all four cases. I started with 24/96 and 24/192 FLAC files and tested it ... by just piping the output of flac.exe directly into SoX.


I confirm that I tried the same pipeline test as you [input file => flac (decode) => sox (resample) => output file] and got the same (positive) results as you. I even tried yet a longer pipeline ([nput file => flac (decode) => sox (resample) => sox (resample again) => output file] to check if the issue was related to the endpoints of the pipeline. However basically it always seems to work in such cases.

QUOTE (JJZolx @ Nov 20 2012, 02:43) *
You're not actually starting with PCM files, are you? I'd guess that whatever you're piping into SoX isn't the format that you expect.


Yes I am using a pcm source, and yes it is a good pcm stream. I know this is because if I use the same pcm with the same sox command line but without the resample rate switch, then the output is properly audible; the process only fails on high bit rates and where there is a resample rate switch in the command line...


--------------------
AndrewFG (Whitebear -- http://www.whitebear.ch/mediaserver )
Go to the top of the page
+Quote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 16th September 2014 - 11:21