软件_搭建rtsp视频推送环境

live555编译安装启动

编译

1
2
3
4
5
wget  http://www.live555.com/liveMedia/public/live555-latest.tar.gz
tar xzf live555-latest.tar.gz
cd live
./genMakefiles linux-64bit #注意后面这个参数是根据当前文件夹下config.<后缀>获取得到的
make

启动:cd mediaServer && ./live555MediaServer
打印出这些就说明编译安装成功了。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[root@localhost mediaServer]# ./live555MediaServer 
LIVE555 Media Server
version 0.89 (LIVE555 Streaming Media library version 2016.06.26).
Play streams from this server using the URL
rtsp://192.168.0.111/<filename> #这个就是访问的url地址
where <filename> is a file present in the current directory.
Each file's type is inferred from its name suffix:
".264" => a H.264 Video Elementary Stream file
".265" => a H.265 Video Elementary Stream file
".aac" => an AAC Audio (ADTS format) file
".ac3" => an AC-3 Audio file
".amr" => an AMR Audio file
".dv" => a DV Video file
".m4e" => a MPEG-4 Video Elementary Stream file
".mkv" => a Matroska audio+video+(optional)subtitles file
".mp3" => a MPEG-1 or 2 Audio file
".mpg" => a MPEG-1 or 2 Program Stream (audio+video) file
".ogg" or ".ogv" or ".opus" => an Ogg audio and/or video file
".ts" => a MPEG Transport Stream file
(a ".tsx" index file - if present - provides server 'trick play' support)
".vob" => a VOB (MPEG-2 video with AC-3 audio) file
".wav" => a WAV Audio file
".webm" => a WebM audio(Vorbis)+video(VP8) file
See http://www.live555.com/mediaServer/ for additional documentation.
(We use port 80 for optional RTSP-over-HTTP tunneling, or for HTTP live streaming (for indexed Transport Stream files only).)

填充视频

将视频放到和live555MediaServer同路径下就可以了。
需要留意的是live555并不支持mp4格式,需要将mp4转为mkv

1
ffmpeg -i xxx.mp4 xxx.mkv

此时用播放软件播放地址:

1
2
3
vlc rtsp://192.168.0.111/xxx.mkv
or
ffplay rtsp://192.168.0.111/xxx.mkv

花屏问题01缓冲区大小

视频的前几秒钟可能会有花屏问题,网上查了查,原因在于缓冲区大小不足。需要修改缓冲区大小

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
live555推送之后的视频流出现花屏,查看源码DynamicRTSPServer.cpp文件,源码如下:
sms->addSubsession(MPEG4VideoFileServerMediaSubsession::createNew(env, fileName, reuseSource));
} else if (strcmp(extension, ".264") == 0) {
// Assumed to be a H.264 Video Elementary Stream file:
NEW_SMS("H.264 Video");
OutPacketBuffer::maxSize = 100000; // allow for some possibly large H.264 frames
sms->addSubsession(H264VideoFileServerMediaSubsession::createNew(env, fileName, reuseSource));
} else if (strcmp(extension, ".265") == 0) {
// Assumed to be a H.265 Video Elementary Stream file:
NEW_SMS("H.265 Video");
OutPacketBuffer::maxSize = 100000; // allow for some possibly large H.265 frames
sms->addSubsession(H265VideoFileServerMediaSubsession::createNew(env, fileName, reuseSource));
} else if (strcmp(extension, ".mp3") == 0) {
// Assumed to be a MPEG-1 or 2 Audio file:
NEW_SMS("MPEG-1 or 2 Audio")

查看上面红色部分对于H264和H265输出包最大缓冲100000字节(100K),对于高清视频缓冲区太小了,必需更改大些。目前更改到800000,对于1080P视频使用VLC播放时,不会再出现花屏。
可用如下信息查询出需要修改那些文件:grep -rnw . -e ‘OutPacketBuffer::maxSize = ‘,需要修改buff的文件
修改后花屏问题可能存在,但视频卡顿问题会得到解决。

花屏问题02视频格式

花屏问题依然存在,本人曾经尝试过用h264格式代替mkv,发现live555无法识别h264格式,偶然扫到命令提示部分,发现live555支持的h264需要的扩展格式为264,将h264扩展改为264,发现花屏问题得到解决,(但是解决的并不完美)。
视频处理:

1
2
ffmpeg -i xxx.mp4 xxx.h264
mv xxx.h264 xxx.264

将视频复制到live555MediaServer同路径下,启动后连接rtsp地址,发现花屏问题得以解决。
小视频一般都是ok的(小于10M),大视频则会有问题(大于200M),vlc连接大视频的rtsp时依然会出现花屏问题。

1
2
3
opencv连接rtsp:ok
ffplay连接rtsp:ok
vlc连接rtsp:花屏

猜测是vlc对部分码流数据兼容不佳,或者视频源有问题,总之3个播放工具2个没问题,可以认为rtsp是ok的。

参考

用VLC做流媒体服务器:https://blog.csdn.net/redstarofsleep/article/details/49273405
win:利用live555搭建最简单的rtsp流媒体服务:https://blog.csdn.net/huweijian5/article/details/53928521
使用live555 在linux下搭建 rtsp server:https://www.cnblogs.com/dpf-10/p/5623101.html
nginx+rtmp:https://hub.docker.com/r/datarhei/nginx-rtmp/
nginx+rtsp:https://hub.docker.com/r/srnbckr/nginx-rtsp
ffmpeg+ffserver搭建rtsp服务器:https://blog.csdn.net/FPGATOM/article/details/98782202
live555推送1080p花屏:https://blog.csdn.net/youyicc/article/details/79862762
流媒体开发之开源项目live555—更改server端的帧率大小和码率大小:https://www.cnblogs.com/pengkunfan/p/3975442.html

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×