使用CentOs7.0搭建伪直播应用:(一个推流静态视频,一个推流自己画面)
1:首先介绍一下推流视频原理:
1、下载SRS 源码包
https://github.com/ossrs/srs/archive/v3.0-r0.tar.gz
2、上传到CentOS7的服务器,进行解压
tar -zxvf srs-3.0-r0.tar.gz
cd srs-3.0-r0/trunk/
./configure
make
make install
3、设置服务开机自启动并启动(netstat -anp | grep srs
查看)
ln -sf /usr/local/srs/etc/init.d/srs /etc/init.d/srs
cp -f /usr/local/srs/usr/lib/systemd/system/srs.service /usr/lib/systemd/system/srs.service
systemctl daemon-reload
systemctl enable srs
systemctl start srs
4、用rpmfusion源安装ffmpeg
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
sed -i -e '/mirrors.cloud.aliyunccnblogs.com/d' -e '/mirrors.aliyunccnblogs.com/d' /etc/yum.repos.d/CentOS-Base.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum install epel-release
wget https://mirrors.aliyun.com/rpmfusion/free/el/rpmfusion-free-release-7.noarch.rpm
rpm -ivh rpmfusion-free-release-7.noarch.rpm
yum install ffmpeg
5、使用FFMPEG命令推流
ffmpeg -re -i /data/Dark.flv -vcodec copy -acodec copy -f flv -y rtmp://192.168.47.129:80/live/livestream
这里要注意自己创建data文件夹并在里面存放自己视频的名字以及后面要改成自己的端口
6、使用VLC观看RTMP流(改成自己的ip)
RTMP流地址为 rtmp://192.168.31.80/live/livestream
:我是分割线
······································································································································································
······································································································································································
······································································································································································
以上的方法是用ffmpeg推流一个服务器的视频,接下来讲一下怎样直播:使用OBS实现直播效果:
首先很多步骤和上面都一样,直到![请添加图片描述](https://i-blog.csdnimg.cn/blog_migrate/2702d95bc8f5ee0208ce8f5fc76696a0.png)
这个地方下面不要去使用ffmpeg -re -i /data/Dark.flv -vcodec copy -acodec copy -f flv -y rtmp://192.168.47.129:80/live/livestream
这个命令,我们现在下载好obs
只有点击「开始推流」按钮以后,SRS 服务器端才能收到数据,而且右下角的面板会出现一个绿色的小方块,「开始推流」这几个字也会变成「停止推流」
VLC前面我们已经安装好啦,步骤都一样!
哈哈成功啦!!!!