Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- recording_path=$(uci get application.audio.recording_path)
- recording_sample_rate=$(uci get application.audio.recording_sample)
- recording_time=$(uci get application.audio.duration) #seconds
- streaming_port=8080
- ffserver_config="/etc/ffserver.conf"
- if [ ! -e "$ffserver_config" ];then
- cat > "$ffserver_config" <<EOF
- HTTPPort ${streaming_port}
- HTTPBindAddress 0.0.0.0
- MaxHTTPConnections 10
- MaxClients 10
- MaxBandwidth 4096
- CustomLog /var/log/ffserver.log
- <Feed audio.ffm>
- File /tmp/audio.ffm
- FileMaxSize 1024M
- </Feed>
- <Stream audio>
- Feed audio.ffm
- Format wav
- AudioCodec pcm_s16le
- AudioBitRate 256
- AudioChannels 2
- AudioSampleRate 8000
- NoVideo
- StartSendOnKey
- </Stream>
- <Stream stat.html>
- Format status
- </Stream>
- EOF
- fi
- #
- sleep 1
- ffserver -f /etc/ffserver.conf &
- sleep 1
- rm -rf /tmp/fifo1 2 >/dev/null
- mkfifo /tmp/fifo1 2 >/dev/null
- #
- mkdir -p "$recording_path" || exit 1
- while true;do
- day=$(date '+%Y-%m-%d')
- mkdir -p "$recording_path"/"$day"
- ffmpeg -f alsa -i hw:0,0 -acodec pcm_s16le -shortest http://localhost:${streaming_port}/audio.ffm -f wav pipe:1 > /tmp/fifo1 &
- ffmpeg -i /tmp/fifo1 -ss 0 -t ${recording_time} -ar ${recording_sample_rate} "$recording_path"/"$day"/"$(date '+%Y-%m-%d_w_%H_%M_%S')".wav
- done
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement