录音中的声音问题

录音中的声音问题

我有一个 cron 作业,每天运行一次以下脚本:

cd /home/me/myaudiodir
chmod 777 /dev/snd
chmod 777 /dev/snd/*
echo "/dev/snd/*:" > audiorec.log
ls -al /dev/snd >> audiorec.log
echo "/dev/snd:" >> audiorec.log
ls -al /dev | grep snd >> audiorec.log
echo "arecord -l:" >> audiorec.log
arecord -l >> audiorec.log
echo "-----------------------------------------------------------" >> audiorec.log
arecord -D hw:SIZHENG,0 -f S16_LE -r 44100 -d 28800 camera/audio-`date +%A`.wav 1>> audiorec.log 2>> audiorec.log
echo Bye! >> audiorec.log

该设备是麦克风SIZHENG。

但是,运行时会出现错误,可在文件中看到audiorec.log

/dev/snd/*:
total 0
drwxr-xr-x  4 root root      300 Feb 13 18:54 .
drwxr-xr-x 20 root root     4080 Feb 13 18:54 ..
drwxr-xr-x  2 root root       60 Feb 13 18:54 by-id
drwxr-xr-x  2 root root       80 Feb 13 18:54 by-path
crw-rw----  1 root audio 116,  2 Feb 13 11:51 controlC0
crw-rw----  1 root audio 116,  9 Feb 13 18:54 controlC1
crw-rw----  1 root audio 116,  4 Feb 13 21:19 pcmC0D0c
crw-rw----  1 root audio 116,  3 Feb 13 21:19 pcmC0D0p
crw-rw----  1 root audio 116,  5 Feb 13 11:51 pcmC0D1c
crw-rw----  1 root audio 116,  6 Feb 13 11:51 pcmC0D2c
crw-rw----  1 root audio 116,  7 Feb 13 11:51 pcmC0D3c
crw-rw----  1 root audio 116,  8 Feb 13 17:41 pcmC0D4p
crw-rw----  1 root audio 116, 10 Feb 13 18:54 pcmC1D0c
crw-rw----  1 root audio 116,  1 Feb 13 11:51 seq
crw-rw----  1 root audio 116, 33 Feb 13 11:51 timer
/dev/snd:
drwxr-xr-x  4 root root         300 Feb 13 18:54 snd
arecord -l:
**** List of CAPTURE Hardware Devices ****
card 0: ICH6 [Intel ICH6], device 0: Intel ICH [Intel ICH6]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: ICH6 [Intel ICH6], device 1: Intel ICH - MIC ADC [Intel ICH6 - MIC ADC]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: ICH6 [Intel ICH6], device 2: Intel ICH - MIC2 ADC [Intel ICH6 - MIC2 ADC]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: ICH6 [Intel ICH6], device 3: Intel ICH - ADC2 [Intel ICH6 - ADC2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: SIZHENG [SIZHENG], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
-----------------------------------------------------------
arecord: main:788: audio open error: Device or resource busy
Bye!

如图所示,错误是arecord: main:788: audio open error: Device or resource busy。我也pulseaudio安装了...

我搜索syslog并获得了:

Feb 13 23:00:01 server pulseaudio[2325]: [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Feb 13 23:00:01 server pulseaudio[2325]: [pulseaudio] main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

当我尝试arecord从命令行运行时,有时它会运行,有时它会给出上述错误。但是,在我运行播放歌曲后,aplay它似乎运行良好......

编辑:我尝试在 /etc/pulse/daemon.conf 中将 exit-idle-time 设置为 20,但没有得到想要的结果。再次,作业给出了相同的错误。我宁愿使用比 PulseAudio 更好的命令行界面。

答案1

PulseAudio 在一定时间内未使用时会停止。您可以使用exit-idle-time中的设置缩短该时间/etc/pulse/daemon.conf

或者,使用 PulseAudio 进行录音。

相关内容