Skip to content

Instantly share code, notes, and snippets.

@soramugi
Created June 23, 2016 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soramugi/39ed0e0858cea28199d780e08b6a0a7a to your computer and use it in GitHub Desktop.
Save soramugi/39ed0e0858cea28199d780e08b6a0a7a to your computer and use it in GitHub Desktop.
らじるらじる(NHKラジオ)録音bashスクリプト
#!/bin/bash
# 参考
# https://gist.github.com/soramugi/836952a6b09e540eb6a3
# https://gist.github.com/matchy2/5310409
# https://gist.github.com/riocampos/5656450
date=`date '+%Y_%m_%d_%H%M'`
outdir="."
if [ $# -le 1 ]; then
echo "usage : $0 channel_name minuites [outputdir] [prefix]"
exit 1
fi
if [ $# -ge 2 ]; then
channel=$1
DURATION=`expr $2 \* 60 + 15`
fi
if [ $# -ge 3 ]; then
outdir=$3
fi
PREFIX=${channel}
if [ $# -ge 4 ]; then
PREFIX=$4
fi
#
# set channel
#
case $channel in
"NHK1")
rtmp="rtmpe://netradio-r1-flash.nhk.jp"
playpath="NetRadio_R1_flash@63346"
;;
"NHK2")
rtmp="rtmpe://netradio-r2-flash.nhk.jp"
playpath="NetRadio_R2_flash@63342"
;;
"NHKFM")
rtmp="rtmpe://netradio-fm-flash.nhk.jp"
playpath="NetRadio_FM_flash@63343"
;;
*)
echo "failed channel"
exit 1
;;
esac
rtmpdump -r ${rtmp} \
--app "live" \
--playpath ${playpath} \
--swfVfy http://www3.nhk.or.jp/netradio/files/swf/rtmpe.swf \
--stop ${DURATION} \
--live \
--flv "/tmp/${date}_${PREFIX}.flv"
ffmpeg -i "/tmp/${date}_${PREFIX}.flv" \
-acodec copy "${outdir}/${date}_${PREFIX}.m4a" && \
rm -f "/tmp/${date}_${PREFIX}.flv"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment