apply for .pcm file as sox

2019-06-14 03:55发布

问题:

I want to exchange 16kHz pcm --> 48kHz wav using sox. however, pcm file isn't applied in sox.

so, I just changed pcm to raw, and then sox -r 16000 -e signed -b 16 -c 1 test.raw -r 48000 out.wav

Can I apply for pcm file not convert raw?

回答1:

For the PCM file, since PCM's are headerless, you need to add '-t raw' as the first argument.

sox -t raw -r 16000 -e signed -b 16 -c 1 test.raw -r 48000 out.wav

Try that out.

Also try the different Endian settings; -L; -B; -x though only use one at a time, and only if not using one doesn't work.



回答2:

There is no need to convert the input file into raw. Sox can handle pcm files.

sox input.pcm -r 48000 output.wav

The input file can either be a .pcm or .wav.

Since .wav files have a header containing audio metadata (such as sample rate, bit precision, file length, etc), you don't have to pass any information about the input file. Hence, non need to use:

-r 16000 -e signed -b 16 -c 1

Converting pcm to raw you have just stripped down the file header.



标签: mp3 wav pcm sox