Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

长时间播放RTSP卡住问题 #4000

Open
Don0429 opened this issue Jun 17, 2024 · 19 comments
Open

长时间播放RTSP卡住问题 #4000

Don0429 opened this issue Jun 17, 2024 · 19 comments

Comments

@Don0429
Copy link

Don0429 commented Jun 17, 2024

问题描述:

在recycleview中(非列表页面播放也一样)播放RTSP视频流(或者demo中的视频也一样)一段时间后都在转圈圈,查看设备CPU和内存占道都不到一半(在8+32G的RK3588上播放4路视频,3个本地摄像头的RTSP流,都是h264,25fps的720P视频,不算大,另一路播放demo中的视频,作为对比参照,运行了周日一天,周一回来都在转圈),使用的是demo中的多任务支持player,实现多个视频流同时播放,刚开始都是正常的,延迟大概在4秒内

出现问题的视频流

3个摄像头都是本地nvr的rtsp流,海康摄像头的,另一路是取自demo中的视频:https://res.exexm.com/cw_145225549855002

问题机型/系统:

工控平板RK3588,Android 12

GSY依赖版本

implementation 'com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-java:v8.6.0-release-jitpack'
//是否需要ExoPlayer模式
implementation 'com.github.CarGuo.GSYVideoPlayer:GSYVideoPlayer-exo2:v8.6.0-release-jitpack'
//更多ijk的编码支持
implementation 'com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-ex_so:v8.6.0-release-jitpack'

Demo中的复现步骤

Demo中的detailPlayer页面打开后XXXX会出现这个问题。

问题代码:(如果有)

在页面中初始化options:

public static void setGSYVideoPlayerOptions() {
        List<VideoOptionModel> list = new ArrayList<>();


        //开启软解码,硬解码:1、打开,0、关闭
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec", 0));
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec-auto-rotate", 0));
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mmediacodec-handle-resolution-change", 0));
        //软解码:1、打开,0、关闭
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "videotoolbox", 1));



        // 每处理一个packet之后刷新io上下文
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "flush_packets", 1));
        //为什么拖动视屏会弹回来,因为ijk的FFMPEG对关键帧问题。
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "enable-accurate-seek", 1));

        // 设置播放前的最大探测时间(单位毫秒),尝试减小这个值
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "rtsp_setup_timeout", "100")); // 示例值,根据实际情况调整

        // 视频帧处理不过来的时候丢弃一些帧达到同步的效果(如果视频帧数太高导致卡画面不同步)
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "framedrop", 30));
        //如果视频seek之后从头播放
//        VideoOptionModel videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "enable-accurate-seek", 1);
        /***************rtsp 配置****************/
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "allowed_media_types", "video"));
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "timeout", 2000));
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "dns_cache_timeout", -1));
        // 或者尝试设置较小的缓冲大小
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "buffer_size", 1316));
//        rtsp设置 https://ffmpeg.org/ffmpeg-protocols.html#rtsp
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "rtsp_transport", "tcp"));
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "rtsp_flags", "prefer_tcp"));
        //是否开启缓冲 设置无packet缓存 尝试减小或关闭预缓冲(1开启,0关闭)(谨慎设置,可能会增加卡顿风险)(一般直播项目会开启,达到秒开的效果,不过带来了播放丢帧卡顿的体验)
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "packet-buffering", 0));
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "infbuf", 1));//是否限制输入缓存数,无限读
        // 设置播放前的探测时间 1,达到首屏秒开效果
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzeduration", 1));
        // 设置播放前的最大探测时间 (100未测试是否是最佳值)
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzemaxduration", 100));
        //设置无packet缓存
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "fflags", "nobuffer"));
        //分析码流时长:默认1024*1000
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzedmaxduration", 100));
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT,"probesize",10240));
        //设置是否开启变调 isModifyTone?0:1
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "soundtouch", 1));
        //设置是否开启环路过滤: 0开启,画面质量高,解码开销大,48关闭,画面质量差点,解码开销小
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_CODEC, "skip_loop_filter", 48));
        //播放重连次数
        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "reconnect", 5));
        //最大缓冲大小,单位kb
//        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "max-buffer-size", 102400));
        //最大fps
//        list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "max-fps", 30));
        /***************rtsp 配置****************/
        // 应用这些配置到GsyVideoPlayer
        GSYVideoManager.instance().setOptionModelList(list);
    }

在adapter中
@Override
    public void onBindViewHolder(@NonNull BaseViewHolder holder, @SuppressLint("RecyclerView") int position) {
//        this.gsyVideoHelper.addVideoPlayer(position,null,deviceList.get(position).deviceNo,holder.getView(R.id.list_item_container),null);
        String rtsp = deviceList.get(position).rtsp;
        MyVideoPlayer videoPlayer = holder.getView(R.id.video_player);
        videoPlayer.setStartAfterPrepared(true);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
            videoPlayer.setAutoHandwritingEnabled(true);
        }
        //防止错位设置
        videoPlayer.setPlayTag(TAG);
        videoPlayer.setPlayPosition(position);
        videoPlayer.setUpLazy(rtsp,false,null,null,rtsp);
        videoPlayer.startPlayLogic();
        //是否根据视频尺寸,自动选择竖屏全屏或者横屏全屏
        videoPlayer.setAutoFullWithSize(false);
        //全屏动画
        videoPlayer.setShowFullAnimation(true);
//        videoPlayer.setNeedOrientationUtils(false);
        //小屏时不触摸滑动
        videoPlayer.setIsTouchWiget(false);
        videoPlayer.setLooping(true);
        //返回按键
        videoPlayer.getBackButton().setVisibility(View.GONE);
        //标题
        videoPlayer.getTitleTextView().setVisibility(View.VISIBLE);
        videoPlayer.getFullscreenButton().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                videoPlayer.startWindowFullscreen(mContext, false, true);
            }
        });
    }

问题log(如果有)


这是周一早上卡主时刷的日志

2024-06-17 09:47:47.518 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43867, dts 2037106939
2024-06-17 09:47:47.561 18756-19239 IJKMEDIA                cn.lgwl.iot.ele                      D  nal_unit_type: 1, nal_ref_idc: 2
2024-06-17 09:47:47.569 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30557, dts 2037133333
2024-06-17 09:47:47.569 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43867, dts 2037106939
2024-06-17 09:47:47.601 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      V  ret=0 c=0a [
                                                                                                    ]
2024-06-17 09:47:47.619 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30557, dts 2037133333
2024-06-17 09:47:47.619 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43868, dts 2037153379
2024-06-17 09:47:47.628 18756-19235 IJKMEDIA                cn.lgwl.iot.ele                      D  nal_unit_type: 1, nal_ref_idc: 2
2024-06-17 09:47:47.694 18756-19236 IJKMEDIA                cn.lgwl.iot.ele                      D  nal_unit_type: 1, nal_ref_idc: 2
2024-06-17 09:47:47.699 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30558, dts 2037200000
2024-06-17 09:47:47.700 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43868, dts 2037153379
2024-06-17 09:47:47.700 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30558, dts 2037200000
2024-06-17 09:47:47.700 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43869, dts 2037199819
2024-06-17 09:47:47.711 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      D  ffp_toggle_buffering_l: start
2024-06-17 09:47:47.711 18756-18891 IJKMEDIA                cn.lgwl.iot.ele                      D  FFP_MSG_BUFFERING_START:
2024-06-17 09:47:47.711 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      V  Sending:
                                                                                                    PAUSE rtsp://192.168.1.209:554/Streaming/Channels/301 RTSP/1.0
                                                                                                    CSeq: 303448
                                                                                                    User-Agent: Lavf58.12.100
                                                                                                    Session: 1432801852
                                                                                                    Authorization: Digest username="admin", realm="bbbda2952459926bed004ae0", nonce="16c6f1bf", uri="rtsp://192.168.1.209:554/Streaming/Channels/301", response="795e493e858bfe9f88150109f3dd2856", algorithm="MD5"
                                                                                                    
                                                                                                    --
2024-06-17 09:47:47.711 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      V  ret=0 c=00 [
2024-06-17 09:47:47.711 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      V  Sending:
                                                                                                    PAUSE rtsp://192.168.1.209:554/Streaming/Channels/301 RTSP/1.0
                                                                                                    CSeq: 303449
                                                                                                    User-Agent: Lavf58.12.100
                                                                                                    Session: 1432801852
                                                                                                    Authorization: Digest username="admin", realm="bbbda2952459926bed004ae0", nonce="16c6f1bf", uri="rtsp://192.168.1.209:554/Streaming/Channels/301", response="795e493e858bfe9f88150109f3dd2856", algorithm="MD5"
                                                                                                    
                                                                                                    --
2024-06-17 09:47:47.711 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      V  ret=0 c=00 [
2024-06-17 09:47:47.711 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      E  rtsp://admin:a1234567@192.168.1.209:554/Streaming/Channels/301: error while seeking
2024-06-17 09:47:47.711 18756-18891 IJKMEDIA                cn.lgwl.iot.ele                      D  ijkmp_get_msg: FFP_MSG_SEEK_COMPLETE
2024-06-17 09:47:47.711 18756-18891 IJKMEDIA                cn.lgwl.iot.ele                      D  FFP_MSG_SEEK_COMPLETE:
2024-06-17 09:47:47.711 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      V  ret=0 c=0a [
                                                                                                    ]
2024-06-17 09:47:47.711 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      D  ffp_toggle_buffering_l: end
2024-06-17 09:47:47.711 18756-18891 IJKMEDIA                cn.lgwl.iot.ele                      D  FFP_MSG_BUFFERING_END:
2024-06-17 09:47:47.720 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30558, dts 2037200000
2024-06-17 09:47:47.720 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43870, dts 2037246259
2024-06-17 09:47:47.761 18756-19237 IJKMEDIA                cn.lgwl.iot.ele                      D  nal_unit_type: 5, nal_ref_idc: 3
2024-06-17 09:47:47.770 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30559, dts 2037266667
2024-06-17 09:47:47.770 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43870, dts 2037246259
2024-06-17 09:47:47.770 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30559, dts 2037266667
2024-06-17 09:47:47.770 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43871, dts 2037292698
2024-06-17 09:47:47.770 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30560, dts 2037333333
2024-06-17 09:47:47.770 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43871, dts 2037292698
2024-06-17 09:47:47.770 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30560, dts 2037333333
2024-06-17 09:47:47.770 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43872, dts 2037339138
2024-06-17 09:47:47.770 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30561, dts 2037400000
2024-06-17 09:47:47.770 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43872, dts 2037339138
2024-06-17 09:47:47.770 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30561, dts 2037400000
2024-06-17 09:47:47.770 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43873, dts 2037385578
2024-06-17 09:47:47.770 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30561, dts 2037400000
2024-06-17 09:47:47.770 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43874, dts 2037432018
2024-06-17 09:47:47.770 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30562, dts 2037466667
2024-06-17 09:47:47.770 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43874, dts 2037432018
2024-06-17 09:47:47.770 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30562, dts 2037466667
2024-06-17 09:47:47.770 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43875, dts 2037478458
2024-06-17 09:47:47.770 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30563, dts 2037533333
2024-06-17 09:47:47.770 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43875, dts 2037478458
2024-06-17 09:47:47.771 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30563, dts 2037533333
2024-06-17 09:47:47.771 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43876, dts 2037524898
2024-06-17 09:47:47.771 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30563, dts 2037533333
2024-06-17 09:47:47.771 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43877, dts 2037571338
2024-06-17 09:47:47.771 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30564, dts 2037600000
2024-06-17 09:47:47.771 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43877, dts 2037571338
2024-06-17 09:47:47.771 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30564, dts 2037600000
2024-06-17 09:47:47.771 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43878, dts 2037617778
2024-06-17 09:47:47.822 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      V  ret=0 c=0a [
                                                                                                    ]
2024-06-17 09:47:47.828 18756-19238 IJKMEDIA                cn.lgwl.iot.ele                      D  nal_unit_type: 1, nal_ref_idc: 2
2024-06-17 09:47:47.894 18756-19239 IJKMEDIA                cn.lgwl.iot.ele                      D  nal_unit_type: 1, nal_ref_idc: 2
2024-06-17 09:47:47.901 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30565, dts 2037666667
2024-06-17 09:47:47.901 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43878, dts 2037617778
2024-06-17 09:47:47.901 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30565, dts 2037666667
2024-06-17 09:47:47.901 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43879, dts 2037664218
2024-06-17 09:47:47.922 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30565, dts 2037666667
2024-06-17 09:47:47.922 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43880, dts 2037710658
2024-06-17 09:47:47.932 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      D  ffp_toggle_buffering_l: start
2024-06-17 09:47:47.932 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      V  Sending:
                                                                                                    PAUSE rtsp://192.168.1.209:554/Streaming/Channels/301 RTSP/1.0
                                                                                                    CSeq: 303450
                                                                                                    User-Agent: Lavf58.12.100
                                                                                                    Session: 1432801852
                                                                                                    Authorization: Digest username="admin", realm="bbbda2952459926bed004ae0", nonce="16c6f1bf", uri="rtsp://192.168.1.209:554/Streaming/Channels/301", response="795e493e858bfe9f88150109f3dd2856", algorithm="MD5"
                                                                                                    
                                                                                                    --
2024-06-17 09:47:47.932 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      V  ret=0 c=00 [
2024-06-17 09:47:47.932 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      V  Sending:
                                                                                                    PAUSE rtsp://192.168.1.209:554/Streaming/Channels/301 RTSP/1.0
                                                                                                    CSeq: 303451
                                                                                                    User-Agent: Lavf58.12.100
                                                                                                    Session: 1432801852
                                                                                                    Authorization: Digest username="admin", realm="bbbda2952459926bed004ae0", nonce="16c6f1bf", uri="rtsp://192.168.1.209:554/Streaming/Channels/301", response="795e493e858bfe9f88150109f3dd2856", algorithm="MD5"
                                                                                                    
                                                                                                    --
2024-06-17 09:47:47.932 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      V  ret=0 c=00 [
2024-06-17 09:47:47.932 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      E  rtsp://admin:a1234567@192.168.1.209:554/Streaming/Channels/301: error while seeking
2024-06-17 09:47:47.932 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      V  ret=0 c=0a [
                                                                                                    ]
2024-06-17 09:47:47.932 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      D  ffp_toggle_buffering_l: end
2024-06-17 09:47:47.932 18756-18891 IJKMEDIA                cn.lgwl.iot.ele                      D  FFP_MSG_BUFFERING_START:
2024-06-17 09:47:47.932 18756-18891 IJKMEDIA                cn.lgwl.iot.ele                      D  ijkmp_get_msg: FFP_MSG_SEEK_COMPLETE
2024-06-17 09:47:47.932 18756-18891 IJKMEDIA                cn.lgwl.iot.ele                      D  FFP_MSG_SEEK_COMPLETE:
2024-06-17 09:47:47.932 18756-18891 IJKMEDIA                cn.lgwl.iot.ele                      D  FFP_MSG_BUFFERING_END:
2024-06-17 09:47:47.961 18756-19235 IJKMEDIA                cn.lgwl.iot.ele                      D  nal_unit_type: 1, nal_ref_idc: 2
2024-06-17 09:47:47.962 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30566, dts 2037733333
2024-06-17 09:47:47.962 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43880, dts 2037710658
2024-06-17 09:47:48.022 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30566, dts 2037733333
2024-06-17 09:47:48.022 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43881, dts 2037757098
2024-06-17 09:47:48.027 18756-19236 IJKMEDIA                cn.lgwl.iot.ele                      D  nal_unit_type: 1, nal_ref_idc: 2
2024-06-17 09:47:48.042 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      V  ret=0 c=0a [
                                                                                                    ]
2024-06-17 09:47:48.095 18756-19237 IJKMEDIA                cn.lgwl.iot.ele                      D  nal_unit_type: 1, nal_ref_idc: 2
2024-06-17 09:47:48.103 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30567, dts 2037800000
2024-06-17 09:47:48.103 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43881, dts 2037757098
2024-06-17 09:47:48.103 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 30567, dts 2037800000
2024-06-17 09:47:48.103 18756-19228 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 43882, dts 2037803537
2024-06-17 09:47:48.152 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      D  ffp_toggle_buffering_l: start
2024-06-17 09:47:48.152 18756-18891 IJKMEDIA                cn.lgwl.iot.ele                      D  FFP_MSG_BUFFERING_START:
2024-06-17 09:47:48.152 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      V  Sending:
                                                                                                    PAUSE rtsp://192.168.1.209:554/Streaming/Channels/301 RTSP/1.0
                                                                                                    CSeq: 303452
                                                                                                    User-Agent: Lavf58.12.100
                                                                                                    Session: 1432801852
                                                                                                    Authorization: Digest username="admin", realm="bbbda2952459926bed004ae0", nonce="16c6f1bf", uri="rtsp://192.168.1.209:554/Streaming/Channels/301", response="795e493e858bfe9f88150109f3dd2856", algorithm="MD5"
                                                                                                    
                                                                                                    --
2024-06-17 09:47:48.152 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      V  ret=0 c=00 [
2024-06-17 09:47:48.152 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      V  Sending:
                                                                                                    PAUSE rtsp://192.168.1.209:554/Streaming/Channels/301 RTSP/1.0
                                                                                                    CSeq: 303453
                                                                                                    User-Agent: Lavf58.12.100
                                                                                                    Session: 1432801852
                                                                                                    Authorization: Digest username="admin", realm="bbbda2952459926bed004ae0", nonce="16c6f1bf", uri="rtsp://192.168.1.209:554/Streaming/Channels/301", response="795e493e858bfe9f88150109f3dd2856", algorithm="MD5"
                                                                                                    
                                                                                                    --
2024-06-17 09:47:48.152 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      V  ret=0 c=00 [
2024-06-17 09:47:48.152 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      E  rtsp://admin:a1234567@192.168.1.209:554/Streaming/Channels/301: error while seeking
2024-06-17 09:47:48.152 18756-18891 IJKMEDIA                cn.lgwl.iot.ele                      D  ijkmp_get_msg: FFP_MSG_SEEK_COMPLETE
2024-06-17 09:47:48.152 18756-18891 IJKMEDIA                cn.lgwl.iot.ele                      D  FFP_MSG_SEEK_COMPLETE:
2024-06-17 09:47:48.152 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      V  ret=0 c=0a [
                                                                                                    ]
2024-06-17 09:47:48.152 18756-18893 IJKMEDIA                cn.lgwl.iot.ele                      D  ffp_toggle_buffering_l: end
2024-06-17 09:47:48.152 18756-18891 IJKMEDIA                cn.lgwl.iot.ele                      D  FFP_MSG_BUFFERING_END:
2024-06-17 09:47:48.161 18756-19238 IJKMEDIA                cn.lgwl.iot.ele                      D  nal_unit_type: 1, nal_ref_idc: 2

@CarGuo
Copy link
Owner

CarGuo commented Jun 17, 2024

推荐用 exo 模式的 rtsp 去试试,ijk 软解模式多播 rtsp 感觉更大问题是它断流后重连不上了

@Don0429
Copy link
Author

Don0429 commented Jun 17, 2024

推荐用 exo 模式的 rtsp 去试试,ijk 软解模式多播 rtsp 感觉更大问题是它断流后重连不上了

设置下面这个是吧
PlayerFactory.setPlayManager(Exo2PlayerManager.class);//EXO模式

我设置过,也会出现这个问题呢,这样初始化

请大佬帮看下options配置是否正确,非常感谢,调试一周了

public static void init(){
        PlayerFactory.setPlayManager(Exo2PlayerManager.class);//EXO模式
//        setExoPlayerCacheMode();
        setShowType(GSYVideoType.SCREEN_MATCH_FULL);
        setGSYVideoPlayerOptions();
    }

且每隔5秒调用下这个,怕长时间播放内存等资源递增
GSYVideoManager.instance().clearAllDefaultCache(getActivity());

@CarGuo
Copy link
Owner

CarGuo commented Jun 17, 2024

clearAllDefaultCache 不用调用,没关系的,Exo2PlayerManager.class 不需要 options , 用 exo 的好处是为了你可以更方便通过 media3-exoplayer-rtsp 的源码去定位问题

@Don0429
Copy link
Author

Don0429 commented Jun 17, 2024

改用EXO模式,也出现这种转圈情况:
image
zuo左边视频是RTSP流(大概十几分钟就出现转圈,比较快),右边是demo中的一个视频地址(大概久一点才会暂停转圈(设置了循环播放的))

一直是这种日志,也没看到报什么错误

2024-06-17 13:41:46.776 11531-11692 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 66353, dts 4423533333
2024-06-17 13:41:46.776 11531-11692 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 95254, dts 4423514558
2024-06-17 13:41:46.776 11531-11692 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 66353, dts 4423533333
2024-06-17 13:41:46.776 11531-11692 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 95255, dts 4423560998
2024-06-17 13:41:46.819 11531-11673 lgwl_FrVid...orFragment cn.lgwl.iot.ele                      E  clearAllDefaultCache...
2024-06-17 13:41:46.836 11531-11706 IJKMEDIA                cn.lgwl.iot.ele                      D  nal_unit_type: 1, nal_ref_idc: 2
2024-06-17 13:41:46.837 11531-11692 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 66354, dts 4423600000
2024-06-17 13:41:46.837 11531-11692 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 95255, dts 4423560998
2024-06-17 13:41:46.837 11531-11692 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 66354, dts 4423600000
2024-06-17 13:41:46.837 11531-11692 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 95256, dts 4423607438
2024-06-17 13:41:46.903 11531-11709 IJKMEDIA                cn.lgwl.iot.ele                      D  nal_unit_type: 1, nal_ref_idc: 2
2024-06-17 13:41:46.908 11531-11692 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 66355, dts 4423666667
2024-06-17 13:41:46.908 11531-11692 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 95256, dts 4423607438
2024-06-17 13:41:46.908 11531-11692 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 66355, dts 4423666667
2024-06-17 13:41:46.908 11531-11692 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 95257, dts 4423653878
2024-06-17 13:41:46.908 11531-11692 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 66355, dts 4423666667
2024-06-17 13:41:46.908 11531-11692 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 95258, dts 4423700317
2024-06-17 13:41:46.969 11531-11692 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 66356, dts 4423733333
2024-06-17 13:41:46.969 11531-11710 IJKMEDIA                cn.lgwl.iot.ele                      D  nal_unit_type: 1, nal_ref_idc: 2
2024-06-17 13:41:46.969 11531-11692 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 95258, dts 4423700317
2024-06-17 13:41:46.970 11531-11692 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 66356, dts 4423733333
2024-06-17 13:41:46.970 11531-11692 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 95259, dts 4423746757
2024-06-17 13:41:47.036 11531-11700 IJKMEDIA                cn.lgwl.iot.ele                      D  nal_unit_type: 1, nal_ref_idc: 2
2024-06-17 13:41:47.041 11531-11692 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 0, sample 66357, dts 4423800000
2024-06-17 13:41:47.041 11531-11692 IJKMEDIA                cn.lgwl.iot.ele                      V  stream 1, sample 95259, dts 4423746757

@CarGuo
Copy link
Owner

CarGuo commented Jun 17, 2024

所以要 debug 源码看看情况

@Don0429
Copy link
Author

Don0429 commented Jun 19, 2024

所以要 debug 源码看看情况

没找到什么原因,我的集成方式应该没问题吧,也使用EXO模式了

@CarGuo
Copy link
Owner

CarGuo commented Jun 19, 2024

集承应该没问题的,不过我也猜不出来什么情况,或者换个设备环境看看?

@Don0429
Copy link
Author

Don0429 commented Jun 19, 2024

来什么情况,或者换个设备环境看

换了小米10S,华为平板M6,RK3588(6T算力性能应该没问题)设备也都一样呢

@CarGuo
Copy link
Owner

CarGuo commented Jun 19, 2024

实在猜测不出来,刚测试了一个视频,一小时放着,没发现类似问题····

@CarGuo
Copy link
Owner

CarGuo commented Jun 19, 2024

说起来海康,我记得它的以前好像有过 rtp 包并不标准,服务需要 rtcp 保活,有些需要发送信令保活,类似于需要对链接作保活~不过好像有点久远了,好像是定时设置什么 option 去作

@CarGuo
Copy link
Owner

CarGuo commented Jun 19, 2024

另外可以试试把 rtsp 转 rtmp 测试下,实在没想起来有什么

@Don0429
Copy link
Author

Don0429 commented Jun 19, 2024

实在猜测不出来,刚测试了一个视频,一小时放着,没发现类似问题····

您是用摄像头的RTSP流做视频源测试的吗?NVR好像不支持转化为RTMP,这个还得加多媒体服务器吧,就比较麻烦了。
据了解目前就这个框架比较新且全,没找到其他视频播放框架,不然可以对比测试下,或者您有推荐吗

非常感谢您的耐心解答

@CarGuo
Copy link
Owner

CarGuo commented Jun 20, 2024

不是摄像头的 rtsp,普通 rtsp,我公司的 nvr 都是转到云 GB28181 协议之后远程······如果针对 rtsp ,你也可以看看 ZLMediaKit 或者 VLC

@ouzs
Copy link

ouzs commented Jun 20, 2024

@Don0429 @CarGuo 我也遇到画面卡住现象,在卡之前会出现错帧花屏先是延迟,然后过卡死。错误如下
image

@ouzs
Copy link

ouzs commented Jun 20, 2024

@Don0429 我有个疑问,你设置了不缓冲。为什么日志里还能看到缓冲的现象。是因为拖动进度条了?直播的场景不应该能拖动吧
//是否开启缓冲 设置无packet缓存 尝试减小或关闭预缓冲(1开启,0关闭)(谨慎设置,可能会增加卡顿风险)(一般直播项目会开启,达到秒开的效果,不过带来了播放丢帧卡顿的体验)
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "packet-buffering", 0));
image

@CarGuo
Copy link
Owner

CarGuo commented Jun 20, 2024

@ouzs 看起来是断流了,或者是包数据累计异常,另外 @Don0429 的缓冲,可能是因为找不到下一帧数据,所以“被迫”进入“缓冲”

@Don0429
Copy link
Author

Don0429 commented Jun 20, 2024

list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "packet-buffering", 0));

我也看到这个了,一度怀疑是不是设置的option没生效,但也没找到问题所在,是不是因为我还设置了丢包处理导致缓冲的

@1217079729
Copy link

楼主这个问题解决了吗,我也用ijkplayer播放rtsp视频流发现暂停了无法恢复

@Don0429
Copy link
Author

Don0429 commented Aug 12, 2024

楼主这个问题解决了吗,我也用ijkplayer播放rtsp视频流发现暂停了无法恢复

还没有,放弃了,改用EasypusherPro,但久了也会有闪退,定时刷新重启,有好的方案也麻烦同步下,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants