直播-srs起步

srs简介
 
 
原料
CentOS Linux release 7.2.1511 (Core)
ffmpeg:
macos可以通过brew install ffmpeg 安装
 
 
下载&编译
git clone https://github.com/ossrs/srs
cd srs/trunk
 
./configure --disable-all --with-ssl && make
这个过程过程比较顺利
 
 
运行
[chengning@localhost trunk]$ ./objs/srs -c conf/rtmp.conf
[2016-09-25 08:29:33.164][trace][16155][0] XCORE-SRS/2.0.218(ZhouGuowen)
[2016-09-25 08:29:33.164][trace][16155][0] config parse complete
[2016-09-25 08:29:33.164][trace][16155][0] write log to file ./objs/srs.log
[2016-09-25 08:29:33.164][trace][16155][0] you can: tailf ./objs/srs.log
[2016-09-25 08:29:33.164][trace][16155][0] @see: https://github.com/ossrs/srs/wiki/v1_CN_SrsLog
[chengning@localhost trunk]$
 
查看进程是否正常
[chengning@localhost trunk]$ ps aux | grep srs
chengni+ 16116  0.0  0.0  17212   964 pts/0    S    08:23   0:00 ./objs/srs -c conf/rtmp.conf
chengni+ 16159  0.0  0.0 112664   984 pts/0    R+   08:29   0:00 grep --color=auto srs
[chengning@localhost trunk]$
 
查看端口打开是否正常
[chengning@localhost trunk]$ sudo netstat -altupn
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:1935            0.0.0.0:*               LISTEN      16116/./objs/srs
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      824/sshd
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1192/master
tcp        0      0 192.168.199.156:22      192.168.199.137:52949   ESTABLISHED 9861/sshd: chengnin
tcp6       0      0 :::22                   :::*                    LISTEN      824/sshd
tcp6       0      0 ::1:25                  :::*                    LISTEN      1192/master
udp        0      0 0.0.0.0:47700           0.0.0.0:*                           626/dhclient
udp        0      0 0.0.0.0:68              0.0.0.0:*                           626/dhclient
udp6       0      0 :::16339                :::*                                626/dhclient
 
 
发布直播流
准备好一个mp4文件,如lizijun.mp4
将下面的脚步保存在srs.sh文件中
#!/bin/bash -ex
 
for((;;)); do
    ffmpeg -re -i ./lizijun.mp4
    -vcodec copy -acodec copy
    -f flv -y rtmp://192.168.199.156/live/livestream;
    sleep 1;
done
 
然后运行 ./src 
 
 
 
播放
ffplay rtmp://192.168.199.156/live/livestream
 
原文地址:https://www.cnblogs.com/vc60er/p/5906824.html