1. sox 使用方式
sudo apt-get install sox
通过 play 查看音频格式 play male_audio.wav
play WARN alsa: can't encode 0-bit Unknown or not applicable
male_audio.wav:
File Size: 184k Bit Rate: 706k
Encoding: Signed PCM
Channels: 1 @ 16-bit
Samplerate: 44100Hz
Replaygain: off
Duration: 00:00:02.08
In:100% 00:00:02.08 [00:00:00.00] Out:91.9k [ | ] Clip:0
Done.
sox 命令:
sox [global-options]
[format-options] infile1
[[format-options] infile2] ...
[format-options] outfile
[effect [effect-options]] ...
2. 原始音频raw 转为wav 格式
• input.raw has single channel
• It uses 16-bit linear PCM
• Sample rate is 16kHz
command:
sox -c 1 -e signed-integer -b 16 -r 16000 input.raw
output.wav remix 1
3. 交换音频的 左右声道
sox input.wav output.wav remix 2 1
3.1 生成三个声道,
且第二个声道中的数值 为0;
sox input.wav output.wav remix 1 0 1
4. 重采样与格式转换
4.1 重采样
sox input.wav -r 8000 output.wav
4.2 编码格式转换
Convert 16-bit linear PCM file to μ-law.
sox input.wav -e mu-law output.wav
Convert from WAV to FLAC format.
sox input.wav output.flac
5. ffmpeg
sudo apt install ffmpeg
Convert MP4 file to WAV:
ffmpeg -i input.mp4 output.wav