winlin

add scripts

@@ -15,7 +15,32 @@ who is the contributors: <br/> @@ -15,7 +15,32 @@ who is the contributors: <br/>
15 1. contribute important features to srs. <br/> 15 1. contribute important features to srs. <br/>
16 2. the name of all contributors will send in the response of NetConnection.connect and metadata. 16 2. the name of all contributors will send in the response of NetConnection.connect and metadata.
17 17
18 -### Usage 18 +### Usage(simple)
  19 +<strong>step 1:</strong> get srs <br/>
  20 +<pre>
  21 +tar xf simple-rtmp-server-*.*.tar.gz
  22 +cd simple-rtmp-server-*.*/trunk
  23 +</pre>
  24 +or get the latest code:<br/>
  25 +<pre>
  26 +git clone https://github.com/winlinvip/simple-rtmp-server
  27 +cd simple-rtmp-server/trunk
  28 +</pre>
  29 +<strong>step 2:</strong> build and start srs all demo features.<br/>
  30 +<pre>
  31 +bash scripts/demo.sh
  32 +</pre>
  33 +<strong>step 3:</strong> srs live show: [http://demo.srs.com/players](http://demo.srs.com/players) <br/>
  34 +requires client add server ip to hosts. <br/>
  35 +<pre>
  36 +# edit the folowing file:
  37 +# linux: /etc/hosts
  38 +# windows: C:\Windows\System32\drivers\etc\hosts
  39 +# where server ip is 192.168.2.111
  40 +192.168.2.111 demo.srs.com
  41 +</pre>
  42 +
  43 +### Usage(detail)
19 <strong>step 1:</strong> build srs <br/> 44 <strong>step 1:</strong> build srs <br/>
20 <pre> 45 <pre>
21 tar xf simple-rtmp-server-*.*.tar.gz 46 tar xf simple-rtmp-server-*.*.tar.gz
  1 +#!/bin/bash
  2 +src_dir='src'
  3 +if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi
  4 +
  5 +# step 1: build srs
  6 +echo "编译SRS"
  7 +./configure --with-ssl --with-hls --with-ffmpeg --with-http && make
  8 +ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:编译SRS失败"; exit $ret; fi
  9 +
  10 +# step 2: start srs
  11 +cmd="nohup ./objs/srs -c conf/srs.conf >./objs/logs/srs.log 2>&1 &"
  12 +echo "启动SRS服务器:$cmd"
  13 +pids=`ps aux|grep srs|grep "./objs"|grep "srs.conf"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done
  14 +nohup ./objs/srs -c conf/srs.conf >./objs/logs/srs.log 2>&1 &
  15 +ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS失败"; exit $ret; fi
  16 +
  17 +# step 3(optinal): start srs listen at 19350 to forward to
  18 +cmd="nohup ./objs/srs -c conf/srs.19350.conf > ./objs/logs/srs.19350.log 2>&1 &"
  19 +echo "启动SRS转发服务器:$cmd"
  20 +pids=`ps aux|grep srs|grep "./objs"|grep "srs.19350.conf"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done
  21 +nohup ./objs/srs -c conf/srs.19350.conf > ./objs/logs/srs.19350.log 2>&1 &
  22 +ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS转发服务器失败"; exit $ret; fi
  23 +
  24 +# step 4(optinal): start nginx for HLS
  25 +cmd="sudo ./objs/nginx/sbin/nginx"
  26 +echo "启动NGINX(HLS服务):$cmd"
  27 +pids=`ps aux|grep nginx|grep process|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; sudo kill -s SIGKILL $pid; done
  28 +sudo ./objs/nginx/sbin/nginx
  29 +ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动NGINX(HLS服务)失败"; exit $ret; fi
  30 +
  31 +# step 5(optinal): start http hooks for srs callback
  32 +cmd="nohup python ./research/api-server/server.py 8085 >./objs/logs/api-server.log 2>&1 &"
  33 +echo "启动API服务器:$cmd"
  34 +pids=`ps aux|grep python|grep research|grep "api-server"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done
  35 +nohup python ./research/api-server/server.py 8085 >./objs/logs/api-server.log 2>&1 &
  36 +ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动API服务器失败"; exit $ret; fi
  37 +
  38 +# step 6: publish demo live stream
  39 +cmd="nohup bash scripts/ffmpeg.demo.sh >./objs/logs/ffmpeg-demo.log 2>&1 &"
  40 +echo "启动FFMPEG推送demo流(播放器上12路演示):$cmd"
  41 +pids=`ps aux|grep scripts|grep "ffmpeg.demo.sh"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done
  42 +nohup bash scripts/ffmpeg.demo.sh >./objs/logs/ffmpeg-demo.log 2>&1 &
  43 +ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动FFMPEG推送demo流(播放器上12路演示)失败"; exit $ret; fi
  44 +
  45 +# step 7: publish players live stream
  46 +cmd="nohup bash scripts/ffmpeg.players.sh >./objs/logs/ffmpeg-players.log 2>&1 &"
  47 +echo "启动FFMPEG推送players流(播放器上演示用):$cmd"
  48 +pids=`ps aux|grep scripts|grep "ffmpeg.players.sh"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done
  49 +nohup bash scripts/ffmpeg.players.sh >./objs/logs/ffmpeg-players.log 2>&1 &
  50 +ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动FFMPEG推送players流(播放器上演示用)失败"; exit $ret; fi
  51 +
  52 +# step 8: add server ip to client hosts as demo.
  53 +cat<<END
  54 +SRS系统启动成功,您需要在客户端机器设置hosts后即可观看演示:
  55 + # edit the folowing file:
  56 + # linux: /etc/hosts
  57 + # windows: C:\Windows\System32\drivers\etc\hosts
  58 + # where server ip is 192.168.2.111
  59 + 192.168.2.111 demo.srs.com
  60 +默认的12路流演示:http://demo.srs.com/players
  61 +默认的播放器流演示:http://demo.srs.com/players/srs_player.html?vhost=players
  62 +推流(主播)应用演示:http://demo.srs.com/players/srs_publisher.html?vhost=players
  63 +视频会议(聊天室)应用演示:http://demo.srs.com/players/srs_chat.html?vhost=players
  64 +END
  1 +#!/bin/bash
  2 +src_dir='src'
  3 +if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi
  4 +
  5 +# step 1: build srs
  6 +echo "编译SRS"
  7 +./configure --with-ssl --with-hls --with-ffmpeg --with-http && make
  8 +ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:编译SRS失败"; exit $ret; fi
  9 +
  10 +# step 2: start srs
  11 +cmd="nohup ./objs/srs -c conf/srs.conf >./objs/logs/srs.log 2>&1 &"
  12 +echo "启动SRS服务器:$cmd"
  13 +pids=`ps aux|grep srs|grep "./objs"|grep "srs.conf"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done
  14 +nohup ./objs/srs -c conf/srs.conf >./objs/logs/srs.log 2>&1 &
  15 +ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS失败"; exit $ret; fi
  16 +
  17 +## step 3(optinal): start srs listen at 19350 to forward to
  18 +#cmd="nohup ./objs/srs -c conf/srs.19350.conf > ./objs/logs/srs.19350.log 2>&1 &"
  19 +#echo "启动SRS转发服务器:$cmd"
  20 +#pids=`ps aux|grep srs|grep "./objs"|grep "srs.19350.conf"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done
  21 +#nohup ./objs/srs -c conf/srs.19350.conf > ./objs/logs/srs.19350.log 2>&1 &
  22 +#ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS转发服务器失败"; exit $ret; fi
  23 +
  24 +# step 4(optinal): start nginx for HLS
  25 +cmd="sudo ./objs/nginx/sbin/nginx"
  26 +echo "启动NGINX(HLS服务):$cmd"
  27 +pids=`ps aux|grep nginx|grep process|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; sudo kill -s SIGKILL $pid; done
  28 +sudo ./objs/nginx/sbin/nginx
  29 +ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动NGINX(HLS服务)失败"; exit $ret; fi
  30 +
  31 +# step 5(optinal): start http hooks for srs callback
  32 +cmd="nohup python ./research/api-server/server.py 8085 >./objs/logs/api-server.log 2>&1 &"
  33 +echo "启动API服务器:$cmd"
  34 +pids=`ps aux|grep python|grep research|grep "api-server"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done
  35 +nohup python ./research/api-server/server.py 8085 >./objs/logs/api-server.log 2>&1 &
  36 +ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动API服务器失败"; exit $ret; fi
  37 +
  38 +## step 6: publish demo live stream
  39 +#cmd="nohup bash scripts/ffmpeg.demo.sh >./objs/logs/ffmpeg-demo.log 2>&1 &"
  40 +#echo "启动FFMPEG推送demo流(播放器上12路演示):$cmd"
  41 +#pids=`ps aux|grep scripts|grep "ffmpeg.demo.sh"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done
  42 +#nohup bash scripts/ffmpeg.demo.sh >./objs/logs/ffmpeg-demo.log 2>&1 &
  43 +#ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动FFMPEG推送demo流(播放器上12路演示)失败"; exit $ret; fi
  44 +##
  45 +## step 7: publish players live stream
  46 +#cmd="nohup bash scripts/ffmpeg.players.sh >./objs/logs/ffmpeg-players.log 2>&1 &"
  47 +#echo "启动FFMPEG推送players流(播放器上演示用):$cmd"
  48 +#pids=`ps aux|grep scripts|grep "ffmpeg.players.sh"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done
  49 +#nohup bash scripts/ffmpeg.players.sh >./objs/logs/ffmpeg-players.log 2>&1 &
  50 +#ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动FFMPEG推送players流(播放器上演示用)失败"; exit $ret; fi
  51 +
  52 +# step 8: add server ip to client hosts as demo.
  53 +cat<<END
  54 +SRS系统开发环境启动成功
  55 +默认的播放器流演示:http://dev/players
  56 +END
  1 +#!/bin/bash
  2 +for((;;)); do \
  3 + ./objs/ffmpeg/bin/ffmpeg -re -i ./doc/source.200kbps.768x320.flv \
  4 + -vcodec copy -acodec copy \
  5 + -f flv -y rtmp://127.0.0.1/live?vhost=demo.srs.com/livestream; \
  6 + sleep 1; \
  7 +done
  1 +#!/bin/bash
  2 +for((;;)); do \
  3 + ./objs/ffmpeg/bin/ffmpeg -re -i ./doc/source.200kbps.768x320.flv \
  4 + -vcodec copy -acodec copy \
  5 + -f flv -y rtmp://127.0.0.1/live?vhost=players/livestream; \
  6 + sleep 1; \
  7 +done
  1 +#!/bin/bash
  2 +
  3 +echo "停止SRS服务器"
  4 +ps aux|grep srs|grep "./objs"|grep "srs.conf"
  5 +pids=`ps aux|grep srs|grep "./objs"|grep "srs.conf"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done
  6 +
  7 +echo "停止SRS转发服务器"
  8 +ps aux|grep srs|grep "./objs"|grep "srs.19350.conf"
  9 +pids=`ps aux|grep srs|grep "./objs"|grep "srs.19350.conf"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done
  10 +
  11 +# step 4(optinal): start nginx for HLS
  12 +echo "停止NGINX(HLS服务)"
  13 +ps aux|grep nginx|grep process
  14 +pids=`ps aux|grep nginx|grep process|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; sudo kill -s SIGKILL $pid; done
  15 +
  16 +# step 5(optinal): start http hooks for srs callback
  17 +echo "停止API服务器"
  18 +ps aux|grep python|grep research|grep "api-server"
  19 +pids=`ps aux|grep python|grep research|grep "api-server"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done
  20 +
  21 +# step 6: publish demo live stream
  22 +echo "停止FFMPEG推送demo流(播放器上12路演示)"
  23 +ps aux|grep scripts|grep "ffmpeg.demo.sh"
  24 +pids=`ps aux|grep scripts|grep "ffmpeg.demo.sh"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done
  25 +
  26 +# step 7: publish players live stream
  27 +echo "停止FFMPEG推送players流(播放器上演示用)"
  28 +ps aux|grep scripts|grep "ffmpeg.players.sh"
  29 +pids=`ps aux|grep scripts|grep "ffmpeg.players.sh"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done
  30 +
  31 +echo "SRS系统服务均已停止"