Skip to content
This repository has been archived by the owner on Jan 12, 2021. It is now read-only.

发生网络异常丢包,消息体:频繁出现丢包情况 #11

Open
hbyexplore opened this issue Nov 1, 2018 · 7 comments
Open

Comments

@hbyexplore
Copy link

tests发生网络异常丢包,消息体:[rtsp @ 0000000000eea340] max delay reached. need to consume packet
tests发生网络异常丢包,消息体:[rtsp @ 0000000000eea340] RTP: missed 5 packets
tests发生网络异常丢包,消息体:[rtsp @ 0000000000eea340] max delay reached. need to consume packet
tests发生网络异常丢包,消息体:[rtsp @ 0000000000eea340] RTP: missed 4 packets
tests:frame=13302 fps= 25 q=28.0 size= 155248kB time=00:08:53.56 bitrate=2383.6kbits/s dup=0 drop=5 speed=0.998x

我用的是java写的test程序,实现rtsp转为rtmp并推流出去通过Nginx后在WEB页面通过

具体代码很简单如下: 用户名和密码暂时用了密码代替...
String ip = "192.168.1.11";
String id = "tests";
FFmpegManagerImpl manager = null;
if (manager == null) {
manager = new FFmpegManagerImpl();
}
Map<String,String> map = new HashMap<>();
map.put("appName", id);
map.put("input", "rtsp://username:password@" + ip + ":554");
map.put("output", "rtmp://localhost/live/");
map.put("codec", "h264");
map.put("fmt", "flv");
map.put("fps", "25");
map.put("rs", "640x360");
map.put("twoPart", "0");
// 执行任务,id就是ap"pName,如果执行失败返回为null
return manager.start(map);

@eguid
Copy link
Owner

eguid commented Nov 1, 2018

这是rtsp协议默认使用udp导致的问题,所以rtsp强制使用tcp方式可以一定程度避免丢包。例如在命令中使用 -rtsp_transport tcp

@eguid
Copy link
Owner

eguid commented Nov 1, 2018

tests发生网络异常丢包,消息体:[rtsp @ 0000000000eea340] max delay reached. need to consume packet
tests发生网络异常丢包,消息体:[rtsp @ 0000000000eea340] RTP: missed 5 packets
tests发生网络异常丢包,消息体:[rtsp @ 0000000000eea340] max delay reached. need to consume packet
tests发生网络异常丢包,消息体:[rtsp @ 0000000000eea340] RTP: missed 4 packets
tests:frame=13302 fps= 25 q=28.0 size= 155248kB time=00:08:53.56 bitrate=2383.6kbits/s dup=0 drop=5 speed=0.998x

我用的是java写的test程序,实现rtsp转为rtmp并推流出去通过Nginx后在WEB页面通过标签来进行实时视频的播放,但是由于经常丢包所以视频延时达到了7秒,并且经常花屏.很不稳定,想问问大佬有什么办法改进嘛...

具体代码很简单如下: 用户名和密码暂时用了密码代替...
String ip = "192.168.1.11";
String id = "tests";
FFmpegManagerImpl manager = null;
if (manager == null) {
manager = new FFmpegManagerImpl();
}
Map<String,String> map = new HashMap<>();
map.put("appName", id);
map.put("input", "rtsp://username:password@" + ip + ":554");
map.put("output", "rtmp://localhost/live/");
map.put("codec", "h264");
map.put("fmt", "flv");
map.put("fps", "25");
map.put("rs", "640x360");
map.put("twoPart", "0");
// 执行任务,id就是ap"pName,如果执行失败返回为null
return manager.start(map);

命令可以改成使用这种方式拼接:
//执行原生ffmpeg命令(不包含ffmpeg的执行路径,该路径会从配置文件中自动读取)
manager.start("test1", "ffmpeg -i rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov -rtsp_transport tcp -vcodec copy -acodec copy -f flv -y rtmp://eguid.cc/rtmp/test");
//包含完整ffmpeg执行路径的命令
manager.start("test2,","d:/ffmpeg/ffmpeg -i rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov -rtsp_transport tcp -vcodec copy -acodec copy -f flv -y rtmp://eguid.cc/rtmp/test",true);

@hbyexplore
Copy link
Author

感谢大佬的详细解答!
非常感谢,问题已经解决真的是爽快.... 就加了那么一个命令就解决了,已经完全没有丢包情况,但是还是经常会卡顿?播放出来的视频一卡一卡.难道还是命令不够完善的问题嘛(我越发的决定我的命令不好使了...好像还有很大的改善空间)
请大佬指示!
命令如下:
manager.start("tests","ffmpeg -rtsp_transport tcp -i rtsp://admin:[email protected]:554 -vcodec h264 -f flv -an rtmp://localhost/live/tests ");

@eguid
Copy link
Owner

eguid commented Nov 1, 2018

发生卡顿问题的原因很多,比如网络状况,gop,缓存,帧率、编解码效率等等,可能还有一些其他因素没有说明,但是你这个命令可以通过最简单的转封装来优化转换效率,比如改成这样:manager.start("tests","ffmpeg -rtsp_transport tcp -i rtsp://admin:[email protected]:554 -vcodec copy -f flv -an rtmp://localhost/live/tests ");

@hbyexplore
Copy link
Author

我这个是通过Nginx来进行中转的,我是不是可以从Nginx的rtmp的配置方向考虑考虑

@eguid
Copy link
Owner

eguid commented Nov 1, 2018

nginx-rtmp确实有很大的优化空间

@hbyexplore
Copy link
Author

好的好的!谢谢指正! 还有那个 命令真的很好就加了一个copy...居然...延迟一下降低了5s...还不怎么卡了...厉害厉害

@eguid eguid added the question label Dec 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants