Audio
將 parec 的輸出通過管道傳輸到 sox
sox
可能是繼續讓我感到沮喪的一個 linux 程序。同時,我對它的能力感到敬畏,如果不掌握它,我想接近流利。今天,我花了大約 2 個小時試圖通過管道
sox
讀取字節。parec
parec
字節是一個“pulseaudio
接收器”。為了讓它們流過管道,我使用了 askubuntu 的這個答案。這是我一直在使用的命令:
$ parec -d telephonControl.monitor | sox -b 16 -e signed -c 2 -r 44100 - -t pulse hmm.ogg silence 1 0.50 0.1% 1 2.0 0.1% : newfile : restart
這是我得到的錯誤:
sox FAIL formats: can't determine type of `-' write() failed: Broken pipe
更重要的是, oggenc 解析它們就好了:
parec -d telephonControl.monitor | oggenc -b 192 -o telephonControl.ogg --raw - Encoding standard input to "telephonControl.ogg" at approximate bitrate 192 kbps (VBR encoding enabled)
我完全不知道如何
sox
消化這些字節。$ parec -d telephonControl.monitor >> somebytes $ soxi somebytes soxi FAIL formats: can't determine type of file `somebytes'
但我知道它們是原始音頻,16 位有符號小端,2 通道 44100kHz:
$pacmd >>> list-sink-inputs 1 sink input(s) available. index: 17 driver: <protocol-native.c> flags: state: RUNNING sink: 2 <telephonControl> volume: 0: 100% 1: 100% 0: 0.00 dB 1: 0.00 dB balance 0.00 muted: no current latency: 92.86 ms requested latency: 23.20 ms sample spec: s16le 2ch 44100Hz channel map: front-left,front-right Stereo resample method: (null) module: 7 client: 53 <ALSA plug-in> properties: media.name = "ALSA Playback" application.name = "ALSA plug-in" native-protocol.peer = "UNIX socket client" native-protocol.version = "26" application.process.id = "3609" application.process.user = "alec" application.process.host = "ROOROO" window.x11.display = ":0" application.language = "en_GB.UTF-8" application.process.machine_id = "eec7c6ae60f90bb3921ad16d0000302d" application.process.session_id = "eec7c6ae60f90bb3921ad16d0000302d-1345384044.64188-1149507345" module-stream-restore.id = "sink-input-by-application-name:ALSA plug-in"
該
-t
選項需要位於它適用的文件名*之前。*此外,-t pulse
意味著直接讀取(或寫入)PulseAudio 守護程序;它不是這樣的文件格式。原始音頻的類型名稱是raw
.嘗試這個:
parec ... | sox -t raw -b 16 -e signed -c 2 -r 44100 - hmm.ogg ...
(其中
...
意味著保持與以前相同的論點)
soxi
無法辨識文件類型,因為它所做的只是查看標題。原始音頻沒有可供查看的標題。