centos下用ffmpeg推流宇视科技摄像头rtsp流到前端播放(无flash) - foxbaby213
source link: https://www.cnblogs.com/foxbaby/p/16087261.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
流程:安装SRS服务接收ffmpeg的推流,SRS会提供一个flv的播放地址,前端通过fls.js播放即可,无需flash。
1.安装ffmpeg
提供两个版本,都能推流
ffmpeg-5.0.tar.gz https://foxbaby.lanzouu.com/ixjhw02ex1ri
ffmpeg-4.1.6.tar.gz https://foxbaby.lanzouu.com/iBF2m02ex1yf
下载后上传至centos内解压进行源码安装,步骤如下:
1.1.解压压缩包 tar -zxvf ffmpeg-5.0.tar.gz
1.2.进入解压的目录 cd ffmpeg-5.0
1.3.执行 ./configure
1.4.执行 make
1.5.执行 make install
1.6.执行 ffmpeg -version
能够输出版本信息即说明安装成功
2.安装srs服务
使用源码进行安装
2.1.获取源码 git clone -b 4.0release https://gitee.com/ossrs/srs.git
2.2.进入目录 cd srs/trunk
2.3.执行 ./configure
2.4.编译 ./configure
2.5.启动服务 ./objs/srs -c conf/srs.conf
3.使用ffmpeg进行推流
宇视科技的摄像头输出的是rtsp流,格式如下:rtsp://admin:[email protected]/media/video2
rtsp://用户名:密码@摄像头ip/media/video1
video1第一流,video2第二流,video3第三流
推送命令如下:ffmpeg -re -i rtsp://用户名:密码@摄像头ip/media/video1 -s 640x480 -vcodec copy -acodec aac -f flv rtmp://192.168.1.1/live/livestream
命令含义:-s 640x480
以640*480的分辨率推送-vcodec copy
复制摄像头的视频流,如果摄像头输出的不是h264可能需要转码-acodec aac
以aac格式推送-f flv
输出flv格式
推送成功会看到如下内容
成功后使用flv.js或vlc等播放器播放这个地址即可看到效果 http://SRS的ip地址:SRS的端口号/live/livestream.flv
__EOF__
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK