zhu528 / ijkplayer-record

支持rtsp流,支持录制视频(支持录制开始状态获取),截图,修复ijkplayer对同一个目标ip会复用tcp链接的问题
GNU General Public License v2.0
3 stars 3 forks source link

rtsp 延迟优化 #1

Open v-jibfen opened 3 years ago

v-jibfen commented 3 years ago

您好,感谢您的源码分享,请问是否针对rtsp做过延迟优化

zhu528 commented 3 years ago

需要在项目中进行配置

zhu528 commented 3 years ago

List list = new ArrayList<>(); list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "dns_cache_clear", 1)); list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "fast", 1)); list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec", 0)); list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec-handle-resolution-change", 0)); list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "max-buffer-size", 0)); list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "min-frames", 2)); list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "rtsp_transport", "tcp")); list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzedmaxduration", 100)); list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "http-detect-range-support", 0)); list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_CODEC, "skip_loop_filter", 48)); list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzemaxduration", 100)); list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "probesize", 10240)); //下探视频时间 list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "flush_packets", 1)); list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "framedrop", 1)); list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "max_cached_duration", 600)); //直播 list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "infbuf", 1));//直播 list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "packet-buffering", 0));

这个是我这边进行优化的参数,还是可以继续优化的,目前可以达到2秒内打开,延迟的话也是2秒以内

zhu528 commented 3 years ago

希望对你有帮助

v-jibfen commented 3 years ago

是否可以对源码进行修改,优化延迟到300ms

v-jibfen commented 3 years ago

ffmpeg的代码可以也传上来吗,我这边编译不通过: In file included from ./libavutil/internal.h:42:0, from ./libavutil/common.h:467, from ./libavutil/avutil.h:296, from ./libavutil/samplefmt.h:24, from ./libavcodec/avcodec.h:31, from libavformat/avformat.h:319, from libavformat/asf.h:25, from libavformat/asf.c:21: ./libavutil/timer.h:45:5: warning: "HAVE_MACH_MACH_TIME_H" is not defined [-Wundef]

if HAVE_MACH_MACH_TIME_H

 ^

In file included from ./libavutil/common.h:467:0, from ./libavutil/avutil.h:296, from ./libavutil/samplefmt.h:24, from ./libavcodec/avcodec.h:31, from libavformat/avformat.h:319, from libavformat/asf.h:25, from libavformat/asf.c:21: ./libavutil/internal.h:115:5: warning: "HAVE_LOCAL_ALIGNED_8" is not defined [-Wundef]

if HAVE_LOCAL_ALIGNED_8

 ^

./libavutil/internal.h:121:5: warning: "HAVE_LOCAL_ALIGNED_16" is not defined [-Wundef]

if HAVE_LOCAL_ALIGNED_16

 ^

./libavutil/internal.h:127:5: warning: "HAVE_LOCAL_ALIGNED_32" is not defined [-Wundef]

if HAVE_LOCAL_ALIGNED_32

 ^

make: *** [libavformat/allformats.o] Error 1

zhu528 commented 3 years ago

https://www.jianshu.com/p/ded73b154356 你可以看看这个

zhu528 commented 3 years ago

有执行初始化ffmpeg的操作吗 ?

v-jibfen commented 3 years ago

执行了,ffmpeg代码有修改么

zhu528 commented 3 years ago

没有修改过,我已经上传了所有

zhu528 commented 3 years ago

我没有遇到过你这个错误,我一直都是按照我上面写的都能正常编译通过。

zhu528 commented 3 years ago

https://github.com/Bilibili/ijkplayer/issues/4049 你可以看一下这个,你应该是在ubuntu上面编译吧?

v-jibfen commented 3 years ago

是否可以把修改的内容发我一份,我在自己的项目上改,qq 823059782

v-jibfen commented 3 years ago

我也是mac编译的

zhu528 commented 3 years ago

你说的修改是指什么?

zhu528 commented 3 years ago

你是执行哪一个语句报错

v-jibfen commented 3 years ago

我执行的是./compile-ffmpeg.sh all, 我现在想加rtsp 截图和录像的功能代码

zhu528 commented 3 years ago

HAVE_LOCAL_ALIGNED_8 这个参数是你自己加的吗,提示未定义

v-jibfen commented 3 years ago

ffmpeg 相关代码我没有加过,原始就有的

v-jibfen commented 3 years ago

有联系方式可以交流么

zhu528 commented 3 years ago

加你了