使い方
Webカメラで約50秒間の動画を配信させる
pepoliveserver /dev/video0 50000
http://Raspberry pi_IP:8090/stat.htmlからswfファイルを選択して動画が見れます
o 2015.7.24 Camera moduleの動画を配信出来るように機能アップした
o 2015.8.2 Camera moduleのパラメータを変更
- #!/bin/sh
- # pepoliveserver ; liveserver for raspberry pi
- # licence GPLv3 ; this scripts designed by Isamu.Yamauchi 2011.11.28 update 2015.8.2
- # pepoliveserver dev timer
- PATH=$PATH:/usr/local/bin:/usr/local/sbin
- WORKDIR=/www/remote-hand/tmp
- pid=`echo $$`
- prog=pepoliveserver
- pidfile=/var/run/${prog}.pid
- #CONF=${WORKDIR}/ffserver.conf
- LIVEFILE=${WORKDIR}/remote-hand.ffm
- #VIDEOPG=ffmpeg
- VIDEOPG=avconv
- #VIDEOSV=ffserver
- VIDEOSV=avserver
- RASPICAMERA=/dev/vchiq
- RASPIVID=raspivid
- CONF=/etc/${VIDEOSV}.conf
- TIMER=45000
- VIDEOSIZE=320x240
- VIDEORATE=1
- RATE=1
- PEPORASPVIDEO=/usr/local/bin/peporaspvid
- if [ $# -lt 1 -o $# -gt 2 ];then
- echo "usage: $0 /dev/video0 | timer(seconds)"
- exit
- fi
- DEV=$1
- if [ ! -e $DEV ];then
- echo $1 not found ;exit
- fi
- error(){
- if [ -e $pidfile ];then
- VIDEOPG_PID=`pgrep ${VIDEOPG}` ; [ ! -z ${VIDEOPG_PID} ] && kill -HUP ${VIDEOPG_PID}
- VIDEOPG_PID=`pgrep ${RASPIVID}` ; [ ! -z ${VIDEOPG_PID} ] && kill -HUP ${VIDEOPG_PID}
- VIDEOSERVER_PID=`pgrep ${VIDEOSV}` ; [ ! -z ${VIDEOSERVER_PID} ] && kill -HUP ${VIDEOSERVER_PID}
- rm -f $pidfile
- [ -e ${LIVEFILE} ] && rm -f ${LIVEFILE}
- fi
- exit
- }
- trap error SIGINT SIGTERM SIGHUP SIGKILL SIGCHLD
- if [ -e $pidfile ];then
- tpid=`cat $pidfile`
- kill -HUP $tpid
- msleep 1000
- [ -e $pidfile ] && rm -f $pidfile
- fi
- if [ $DEV = $RASPICAMERA ];then
- VIDEOSIZE=640x480
- VIDEORATE=10
- fi
- [ $# = 2 ] && TIMER=$2
- MSLEEP=$(($TIMER * 2))
- RASPITIMER=$(($TIMER - 0))
- if [ ${VIDEOPG} != "ffmpeg" ];then
- OPT="-r 1 -vcodec flv"
- else
- OPT=""
- fi
- IP=`ip -f inet addr|awk '/inet 192.168/{split($2,I,"/");printf I[1]}'`
- [ -e $CONF ] && rm -f $CONF
- if [ ! -e $CONF ];then
- cat >$CONF<<EOF
- # $CONF
- ######################################
- # This file specifies all the options for streaming
- # an avconv produced file as flash
- ######################################
- Port 8090 # this is the port you have set up for streaming
- BindAddress 0.0.0.0
- MaxHTTPConnections 10
- MaxClients 10
- MaxBandwidth 10000
- <Feed remote-hand.ffm>
- File ${LIVEFILE}
- FileMaxSize 2M
- </Feed>
- # swf output - good for streaming
- <Stream remote-hand.swf>
- # the source feed
- Feed remote-hand.ffm
- # the output stream format - FLV = FLash Video
- Format swf
- # this must match the ffmpeg -r argument
- VideoFrameRate $VIDEORATE
- # generally leave this is a large number
- #VideoBufferSize 2M
- # another quality tweak
- #VideoBitRate 200
- # quality ranges - 1-31 (1 = best, 31 = worst)
- VideoQMin 1
- VideoQMax 10
- #VideoSize 640x480
- #VideoSize 320x240
- VideoSize $VIDEOSIZE
- # this sets how many seconds in past to start
- PreRoll 0
- # wecams don't have audio
- NoAudio
- </Stream>
- <Stream stat.html>
- Format status
- </Stream>
- <Redirect index.html>
- # credits!
- URL http://$IP:8090/stat.html
- </Redirect>
- ################################################################################
- #
- #URL http://ffmpeg.sourceforge.net/
- # ${VIDEOPG} -f video4linux2 -s 320x240 -i $DEV $OPT http://$IP:8090/remote-hand.ffm >/dev/null 2>&1
- EOF
- fi
- if [ $DEV = $RASPICAMERA ];then
- VIDEOPG_PID=`pgrep ${RASPIVID}` ; [ ! -z ${VIDEOPG_PID} ] && kill -HUP ${VIDEOPG_PID}
- fi
- VIDEOPG_PID=`pgrep ${VIDEOPG}` ; [ ! -z ${VIDEOPG_PID} ] && kill -HUP ${VIDEOPG_PID}
- VIDEOSERVER_PID=`pgrep ${VIDEOSV}` ; [ ! -z ${VIDEOSERVER_PID} ] && kill -HUP ${VIDEOSERVER_PID}
- msleep 100
- [ -e $pidfile ] && rm -f $pidfile
- echo -n $pid >${pidfile}
- [ -e ${LIVEFILE} ] && rm -f ${LIVEFILE}
- ${VIDEOSV} -v verbose >/dev/null 2>&1 &
- if [ $DEV = $RASPICAMERA ];then
- ${RASPIVID} -vf -hf -o - -w 640 -h 480 -t $RASPITIMER -b 500000 -fps 2 | \
- ${VIDEOPG} -f h264 -r 2 -i - -vcodec flv http://$IP:8090/remote-hand.ffm >/dev/null 2>&1 &
- else
- ${VIDEOPG} -f video4linux2 -s 320x240 -i $DEV $OPT http://$IP:8090/remote-hand.ffm >/dev/null 2>&1 &
- fi
- #msleep $TIMER
- MSLEEP=$(($MSLEEP / 100))
- while [ $MSLEEP -gt 0 ];do
- msleep 100
- MSLEEP=$(($MSLEEP - 1))
- done
- kill -TERM $pid
[PageInfo]
LastUpdate: 2015-08-06 05:01:20, ModifiedBy: pepolinux
[License]
GNU Free Documentation License
[Permissions]
view:all, edit:doc editors, delete/config:doc editors