Code Monkey home page Code Monkey logo

Comments (7)

hbyexplore avatar hbyexplore commented on August 17, 2024 1

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

from ffch4j.

eguid avatar eguid commented on August 17, 2024

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

from ffch4j.

eguid avatar eguid commented on August 17, 2024

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);

from ffch4j.

hbyexplore avatar hbyexplore commented on August 17, 2024

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

from ffch4j.

eguid avatar eguid commented on August 17, 2024

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

from ffch4j.

hbyexplore avatar hbyexplore commented on August 17, 2024

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

from ffch4j.

eguid avatar eguid commented on August 17, 2024

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

from ffch4j.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.