Advertisement
Guest User

Untitled

a guest
Oct 9th, 2019
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. recording_path=$(uci get application.audio.recording_path)
  4. recording_sample_rate=$(uci get application.audio.recording_sample)
  5. recording_time=$(uci get application.audio.duration) #seconds
  6.  
  7. streaming_port=8080
  8.  
  9. ffserver_config="/etc/ffserver.conf"
  10.  
  11. if [ ! -e "$ffserver_config" ];then
  12. cat > "$ffserver_config" <<EOF
  13.  
  14. HTTPPort ${streaming_port}
  15. HTTPBindAddress 0.0.0.0
  16. MaxHTTPConnections 10
  17. MaxClients 10
  18. MaxBandwidth 4096
  19. CustomLog /var/log/ffserver.log
  20.  
  21. <Feed audio.ffm>
  22. File /tmp/audio.ffm
  23. FileMaxSize 1024M
  24. </Feed>
  25.  
  26. <Stream audio>
  27. Feed audio.ffm
  28. Format wav
  29. AudioCodec pcm_s16le
  30. AudioBitRate 256
  31. AudioChannels 2
  32. AudioSampleRate 8000
  33. NoVideo
  34. StartSendOnKey
  35. </Stream>
  36.  
  37. <Stream stat.html>
  38. Format status
  39. </Stream>
  40. EOF
  41. fi
  42. #
  43. sleep 1
  44. ffserver -f /etc/ffserver.conf &
  45. sleep 1
  46.  
  47. rm -rf /tmp/fifo1 2 >/dev/null
  48.  
  49. mkfifo /tmp/fifo1 2 >/dev/null
  50.  
  51. #
  52.  
  53. mkdir -p "$recording_path" || exit 1
  54.  
  55. while true;do
  56. day=$(date '+%Y-%m-%d')
  57. mkdir -p "$recording_path"/"$day"
  58. ffmpeg -f alsa -i hw:0,0 -acodec pcm_s16le -shortest http://localhost:${streaming_port}/audio.ffm -f wav pipe:1 > /tmp/fifo1 &
  59. 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
  60. done
  61.  
  62. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement