Sox command line to downsample Pcm to Flac |
Sox command line to downsample Pcm to Flac |
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 )
|
|
|
|
![]() |
Nov 19 2012, 02:04
Post
#2
|
|
|
Group: Members Posts: 42 Joined: 27-November 11 Member No.: 95439 |
Well, your audio seems to be little-endian, in any case.
To go on, we’ll need to know at least where standard input is coming from – is it something processing a file, or directly from an audio input? Also, more about the kind of “distortion” might be useful: Are chunks of the audio missing? Is the pitch wrong? Unexpected noise? Etc. |
|
|
|
Nov 19 2012, 19:45
Post
#3
|
|
![]() Group: Members Posts: 84 Joined: 12-May 08 Member No.: 53478 |
Well, your audio seems to be little-endian, in any case. See prior answer. I am working with four different source types: 2-ch, 24-bit, linear signed integer, big or little endian, 192000 or 96000Hz. The different sets of command line switches in my OP reflect those four source types. To go on, we’ll need to know at least where standard input is coming from – is it something processing a file, or directly from an audio input? The incoming audio is being delivered from remote audio servers through a TCP socket connection via HTTP; my Whitebear application fetches those streams and squirts them into sox.exe for transcoding through its Std_In pipe. Also, more about the kind of “distortion” might be useful: Are chunks of the audio missing? Is the pitch wrong? Unexpected noise? Etc. Unlike in the other three cases, it is not white noise in this case. I can actually recognise the music. But the sound it is all munged up. It is not a question of wrong pitch, or swapped channels or whatever. It sounds more like sox.exe is throwing audio samples in a box, jumbling them around, and taking them out again in an order that is close to, but not identical to, the correct order; or something like that... (I could send you one of them if you need it...) I should perhaps add that I have no problems when not trying to down-sample the audio. If I take one of my raw stream (any of the above-mentioned four formats) and convert it to flac at the same rate, then the resulting flac plays fine. However if I take the exact same raw stream and (try to) convert it to flac down-sampled to 48000Hz (or 44100Hz) then, as described in my OP, the resulting flac either plays white noise, or munged audio. In other words the problem is set off by adding the "rate 48000" effects switch at the end of the command line... CODE sox.exe -q -t raw -s -b24 -c2 -r192000 -L - -t flac -C0 - rate 48000 => resulting flac plays white noise, or munged audio
sox.exe -q -t raw -s -b24 -c2 -r192000 -L - -t flac -C0 - => resulting flac plays fine This post has been edited by andrewfg: Nov 19 2012, 19:47 -------------------- AndrewFG (Whitebear -- http://www.whitebear.ch/mediaserver )
|
|
|
|
Nov 19 2012, 20:27
Post
#4
|
|
|
Group: Members Posts: 4132 Joined: 2-September 02 Member No.: 3264 |
I should perhaps add that I have no problems when not trying to down-sample the audio. If I take one of my raw stream (any of the above-mentioned four formats) and convert it to flac at the same rate, then the resulting flac plays fine. However if I take the exact same raw stream and (try to) convert it to flac down-sampled to 48000Hz (or 44100Hz) then, as described in my OP, the resulting flac either plays white noise, or munged audio. In other words the problem is set off by adding the "rate 48000" effects switch at the end of the command line... CODE sox.exe -q -t raw -s -b24 -c2 -r192000 -L - -t flac -C0 - rate 48000 => resulting flac plays white noise, or munged audio sox.exe -q -t raw -s -b24 -c2 -r192000 -L - -t flac -C0 - => resulting flac plays fine Are you using -rate and expecting that to resample? Because: QUOTE A user must pass enough information to SoX on the command line so that it knows what type of data it contains. Audio data can usually be totally described by four characteristics: rate The sample rate is in samples per second. For example, CD sample rates are at 44100. So if you pass in 96k audio and then give sox -r 48000 I expect it to get quite screwed up. Perhaps you want to use the resample command instead? |
|
|
|
andrewfg Sox command line to downsample Pcm to Flac Nov 18 2012, 23:06
saratoga What format is the PCM you're feeding sox? Nov 19 2012, 00:04
andrewfg QUOTE (saratoga @ Nov 19 2012, 00:04) Wha... Nov 19 2012, 19:08
andrewfg QUOTE (saratoga @ Nov 19 2012, 20:27) Per... Nov 19 2012, 23:08
saratoga QUOTE (andrewfg @ Nov 19 2012, 18:08) QUO... Nov 19 2012, 23:12
JJZolx Are the results (white noise, distorted audio, wor... Nov 19 2012, 20:22
andrewfg QUOTE (JJZolx @ Nov 19 2012, 20:22) Are t... Nov 19 2012, 23:06
JJZolx I just tried this out for myself and it worked fin... Nov 20 2012, 02:43
andrewfg QUOTE (JJZolx @ Nov 20 2012, 02:43) I jus... Nov 22 2012, 11:14
chi QUOTE (saratoga @ Nov 19 2012, 21:27) Are... Nov 21 2012, 02:38
andrewfg QUOTE (chi @ Nov 21 2012, 02:38) Is it po... Nov 22 2012, 11:36![]() ![]() |
|
Lo-Fi Version | Time is now: 23rd May 2013 - 09:49 |