关于使用sox转换wav文件参数变化的问题

关于使用sox转换wav文件参数变化的问题

我想将一个 wav 文件(11400HZ 采样率和 2 个通道)转换为另一个 wav 文件,只需更改采样率和通道即可。我使用的命令是:

sox 1.wav -r 8000 -c 1 2.wav

1.wav 可以播放 4 分钟,但转换后 2.wav 的长度只有 25 秒。我想这一定是采样率和声道降低造成的。我尝试了以下命令:

sox 1.wav 2.wav

结果是1.wav和2.wav的长度相同。

但是我的项目中需要更改采样率和通道。如果你知道怎么做,请帮我一下。谢谢~

答案1

回答@Patrice Levesque:

mcc@mcc-Lenovo:~/test_pro$ sox --info -V255 longwav_11k.wav 
sox INFO formats: detected file format type `wav'
sox DBUG wav: WAV Chunk fmt 
sox DBUG wav: WAV Chunk data
sox DBUG wav: Reading Wave file: Microsoft PCM format, 1 channel, 11025 samp/sec
sox DBUG wav:         22050 byte/sec, 2 block align, 16 bits/samp, 471682 data bytes
sox DBUG wav:         235841 Samps/chans

Input File     : 'longwav_11k.wav'
Channels       : 1
Sample Rate    : 11025
Precision      : 16-bit
Duration       : 00:00:21.39 = 235841 samples ~ 1604.36 CDDA sectors
File Size      : 472k
Bit Rate       : 176k
Sample Encoding: 16-bit Signed Integer PCM

回答@chirlu:

mcc@mcc-Lenovo:~/test_pro$ sox -V4 longwav_11k.wav -r 8000 -c 1 longwav_temp.wav 
sox:      SoX v14.4.1
time:     May 30 2013 10:34:23
uname:    Linux mcc-Lenovo 3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012 x86_64
compiler: gcc 4.6.3
arch:     1288 48 88 L OMP
sox INFO formats: detected file format type `wav'
sox DBUG wav: WAV Chunk fmt 
sox DBUG wav: WAV Chunk data
sox DBUG wav: Reading Wave file: Microsoft PCM format, 1 channel, 11025 samp/sec
sox DBUG wav:         22050 byte/sec, 2 block align, 16 bits/samp, 471682 data bytes
sox DBUG wav:         235841 Samps/chans

Input File     : 'longwav_11k.wav'
Channels       : 1
Sample Rate    : 11025
Precision      : 16-bit
Duration       : 00:00:21.39 = 235841 samples ~ 1604.36 CDDA sectors
File Size      : 472k
Bit Rate       : 176k
Sample Encoding: 16-bit Signed Integer PCM
Endian Type    : little
Reverse Nibbles: no
Reverse Bits   : no

sox INFO sox: Overwriting `longwav_temp.wav'
sox DBUG wav: Writing Wave file: Microsoft PCM format, 1 channel, 8000 samp/sec
sox DBUG wav:         16000 byte/sec, 2 block align, 16 bits/samp

Output File    : 'longwav_temp.wav'
Channels       : 1
Sample Rate    : 8000
Precision      : 16-bit
Duration       : 00:00:21.39 = 171132 samples ~ 1604.36 CDDA sectors
Sample Encoding: 16-bit Signed Integer PCM
Endian Type    : little
Reverse Nibbles: no
Reverse Bits   : no
Comment        : 'Processed by SoX'

sox DBUG rate: i/o=1.37813; 441:640 @ level 0
sox DBUG effects_i_dsp: 1 0.29345 1.5
sox DBUG effects_i_dsp: make_lpf(n=19199, Fc=0.00188523 beta=13.7461 dc-norm=1 scale=640)
sox DBUG rate: fir_len=30 phases=640 coef_interp=0 mult=1 size=154k
sox DBUG effects_i_dsp: 0.4655 0.020248 0.5
sox DBUG effects_i_dsp: make_lpf(n=409, Fc=0.479752 beta=12.8525 dc-norm=1 scale=1)
sox DBUG rate: fir_len=409 dft_length=4096 Fp=0.931 att=125 mult=1
sox DBUG rate: stage=0  pre_post=29 pre=0  preload=14
sox DBUG rate: stage=1  pre_post=0  pre=0  preload=204
sox INFO sox: effects chain: input        11025Hz  1 channels (multi) 16 bits 00:00:21.39
sox INFO sox: effects chain: rate          8000Hz  1 channels         32 bits 00:00:21.39
sox INFO sox: effects chain: dither        8000Hz  1 channels         16 bits 00:00:21.39
sox INFO sox: effects chain: output        8000Hz  1 channels (multi) 16 bits 00:00:21.39
sox WARN rate: rate clipped 5 samples; decrease volume?
sox WARN dither: dither clipped 4 samples; decrease volume?

我使用一个输入文件 longwav_11k.wav,其采样率为 11025,通道为 1。谢谢!

相关内容