Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to convert a wav file(11400HZ samples rate and 2 channels) to another wav file, just changing the samples rates and channel. The command I use is :

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

1.wav can play 4 minutes, but after the conversion, 2.wav's length is only 25 seconds. I suppose it must be caused by the decreasing of samples rates and channels. I try the command:

sox 1.wav 2.wav

The result is the length of 1.wav and 2.wav is the same.

But the samples rates and channels have to be changed in my project. If you know how to do it, please give me a hand.Thanks~

share|improve this question

migrated from stackoverflow.com Jun 14 '13 at 11:21

This question came from our site for professional and enthusiast programmers.

    
What does sox understand about your input file? Can you please paste the output of “sox --info -V255 1.wav”? –  Patrice Levesque Jun 14 '13 at 18:08
    
The conversion is supposed to maintain the length (in time, not in samples, of course). Could you show the output of sox -V4 1.wav -r 8000 -c 1 2.wav as well? (NB: -V4 with capital V.) –  chirlu Jun 14 '13 at 20:53
    
I'm so sorry, I have made a mistake. The loss of file's length only occurs in changing channels by libsox. Conversion can do perfectly by sox command. Are you familiar with the libsox ? If yes, I can paste my codes. Thanks! –  gold_luck Jun 17 '13 at 4:18
add comment

1 Answer

Answer to @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

Answer to @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?

I user a input file longwav_11k.wav with 11025 samples rates and 1 channel. Thanks!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.