daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Mar 23rd, 2016 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. #
  3. # record.sh
  4. #
  5. # Use mplayer to capture the stream
  6. # at $STREAM to the file $FILE
  7. #
  8. # example: record.sh my_radio_show 60 mms://someserver.com/stream
  9.  
  10. DIR=/Users/ELHEFE/Desktop/rdo #directory where to save the file
  11. TEMPDIR=/tmp
  12.  
  13. # Don't edit anything below this line
  14. #######################################################
  15. DATE=`date +%Y_%m_%d_%H%M%S`  # Save the date as DD-Mmm-YYYY
  16. YEAR=`date +%Y` # Save just the year as YYYY
  17. NAME=$1
  18. DURATION=$2 # enough to catch the show, plus a bit
  19. STREAM=$3
  20. TEMPFILE=$TEMPDIR/$NAME-$DATE
  21. FILE=$DIR/$NAME-$DATE # Where to save it
  22.  
  23. # Capture Stream
  24. mkfifo $TEMPFILE.wav
  25. mkfifo $TEMPFILE-silenced.wav
  26.  
  27. # The lame settings below are optimized for voice encoding
  28. # The sox command below strips out any silent portions
  29. lame -S -a -m m --ty "$YEAR" --vbr-new -V 9 --lowpass 13.4 --athaa-sensitivity 1 \
  30.     --resample 32 $TEMPFILE-silenced.wav $FILE.mp3 >/dev/null &
  31. /usr/local/bin/sox $TEMPFILE.wav -c 1 $TEMPFILE-silenced.wav \
  32.     silence 1 0.2 0.5% -1 0.2 0.5% >/dev/null&
  33. /usr/local/bin/mplayer -really-quiet -cache 500 \
  34.     -ao pcm:file="$TEMPFILE.wav" -vc dummy -vo null \
  35.     -noframedrop $STREAM >/dev/null&
  36.  
  37. sleep 5
  38. # get the pid of all processes started in this script.
  39. PIDS=`ps auxww | grep $TEMPFILE | awk '{print $2}'`
  40.  
  41. # the & turns the capture into a background job
  42. sleep `echo ${DURATION}*60 | bc`  # wait for the show to be over
  43. kill $PIDS >/dev/null # kill the stream capture
  44. rm $TEMPFILE.wav
  45. rm $TEMPFILE-silenced.wav
RAW Paste Data
Top