我需要在linux中監聽我的音頻line-in,並且在播放音頻的情況下,必須將聲音記錄並保存到文件中。熟悉如何motion監視視頻源。監聽音頻線
是否有可能用bash做到這一點?
#!/bin/bash
# audio device
device=/dev/audio-line-in
# below this threshold audio will not be recorded.
noise_threshold=10
# folder where recordings are stored
storage_folder=~/recordings
# run indefenitly, until Ctrl-C is pressed
while true; do
# noise_level() represents a function to determine
# the noise level from device
if noise_level($device) > $noise_threshold; then
# stream from device to file, can be encoded to mp3 later.
cat $device > $storage_folder/$(date +%FT%T).raw
fi;
done;
編輯:沿東西線的流動,我想從這項計劃中得到的是
a. when noise > threshold, start recording
b. stop recording when noise < threshold for 10 seconds
c. save recorded piece to separate file
以前從未聽說過議案,不錯 – 2010-04-10 11:38:08
'date'的默認輸出中有空格。最好使用'$(date +%FT%T)',看起來像:「2010-04-10T08:55:56」,因此它是可排序的並且沒有空格。 [ISO 8601](http://www.iso.org/iso/support/faqs/faqs_widely_used_standards/widely_used_standards_other/date_and_time_format.htm)(和[here](http://en.wikipedia.org/wiki/ISO_8601)) – 2010-04-10 14:00:09
@ Dennis,thanx,改變了這一點。 – Stefan 2010-04-10 14:38:33