我有一个 RTL-SDR 无线电接收器,它将流数据输出到标准输出。我可以使用以下命令收听音频:
$ rtl_fm -M wbfm -f 96.5M | play -r 32k -t raw -e s -b 16 -c 1 -V1 -
正如您所看到的,rtl_fm 以 32 kHz 的采样率输出由 16 位有符号整数组成的样本流。
现在,我想使用 sox 录制此音频,所以我尝试了
$ rtl_fm -M wbfm -f 96.5M -g 25 | rec -e s -b 16 -r 32000 out.wav
我收到了一个 wav 文件,但它只是空的 - 所有值都为零。我试过
$ rtl_fm -M wbfm -f 96.5M -g 25 | rec -e s -b 16 -r 32000 -t raw out.wav
但这只给了我一个文件,Audacity 无法识别为 wav。如果我将其作为原始数据导入,它仍然全为零。
就像我写的那样,当我运行播放命令时,我有音频,但当我录制时,我什么也没有得到。
无论如何,以下是 record 命令的输出:
$ rtl_fm -M wbfm -f 96.5M -g 25 | rec -e s -b 16 -r 32000 -c 1 out.wav
Found 1 device(s):
0: Realtek, RTL2838UHIDIR, SN: 00000001
rec WARN alsa: can't encode 0-bit Unknown or not applicable
Using device 0: Generic RTL2832U OEM
Input File : 'default' (alsa)
Channels : 1
Sample Rate : 32000
Precision : 16-bit
Sample Encoding: 16-bit Signed Integer PCM
In:0.00% 00:00:00.00 [00:00:00.00] Out:0 [ | ] Clip:0 Detached kernel driver
In:0.00% 00:00:00.26 [00:00:00.00] Out:0 [ | ] Clip:0 Found Rafael Micro R820T tuner
In:0.00% 00:00:00.51 [00:00:00.00] Out:8.19k [ | ] Clip:0 Tuner gain set to 25.40 dB.
Tuned to 96771000 Hz.
oversampling input by: 6x.
Oversampling output by: 1x.
Buffer size: 8.03ms
Exact sample rate is: 1020000.026345 Hz
Create UDP thread
Created UDP thread
Allocating 15 zero-copy buffers
Main socket started! :-) Tuning enabled on UDP/6020
Sampling at 1020000 S/s.
Output at 170000 Hz.
In:0.00% 00:00:09.22 [00:00:00.00] Out:287k [ | ] Clip:0 ^CSignal caught, exiting!
User cancel, exiting...
In:0.00% 00:00:09.47 [00:00:00.00] Out:295k [ | ] Clip:0
Aborted.
Signal caught, exiting!
Reattached kernel driver
答案1
你可以替换rec
为ffmpeg -f s16le -ar 32k -ac 1 -i pipe: file.wav
ffmpeg -formats | grep PCM
万一我错了。
你的输出
rec WARN alsa:无法编码 0 位未知或不适用
可能表明您实际上是从实际的麦克风录制的(我认为未连接)。