fijkplayer icon indicating copy to clipboard operation
fijkplayer copied to clipboard

The video latency increases to long time

Open ProFive opened this issue 3 years ago • 0 comments

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] I tried to live stream from the camera and saw the video latency increase for a long time. The first open application is around 2-3 seconds. In 5 mins video latency increases to 10 -20 seconds In 10 mins video latency increase to 30 -40 seconds

Describe the solution you'd like A clear and concise description of what you want to happen. How to improve video latency static is around 2-3 seconds?

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

The config player options:

FijkOption fijkOption = new FijkOption();
//Live low latency https://www.jianshu.com/p/d6a5d8756eec
fijkOption.setHostOption("request-screen-on", 1);
// await player?.setOption(FijkOption.hostCategory, "request-audio-focus", 1);
fijkOption.setHostOption("enable-snapshot", 1);
//RTSP
fijkOption.setFormatOption("rtsp_transport", "tcp");
fijkOption.setFormatOption("rtsp_flags", "prefer_tcp");
fijkOption.setPlayerOption("start-on-prepared", 1);
fijkOption.setFormatOption("http-detect-range-support", 0);
fijkOption.setPlayerOption("enable-position-notify", 1);
//make fast open player
//Requirements: The first opening speed is fast, the delay does not matter, low is also acceptable
//First opening speed: within 500ms.
//https://github.com/jdpxiaoming/ijkrtspdemo
fijkOption.setFormatOption("max-buffer-size", 0);
fijkOption.setPlayerOption("min-frames", 2);
fijkOption.setFormatOption("buffer_size", 1024);
fijkOption.setFormatOption("max-fps", 30);
fijkOption.setFormatOption("infbuf", 1);
fijkOption.setFormatOption("analyzemaxduration", 100);
// fijkOption.setPlayerOption("reorder_queue_size", 0);
if (isPlayerNew) {
  // 6 seconds, cover the duration of 1 video gop.
  fijkOption.setFormatOption("analyzeduration", 6000000);
  //max_cached_duration > GOP * 2
  fijkOption.setPlayerOption("max_cached_duration", 3000);
  if (Platform.isIOS) {
    // 10MB for frame probe
    fijkOption.setFormatOption("probesize", 10000000*10);
  } else {
    // 1MB for frame probe
    fijkOption.setFormatOption("probesize", 10000000);
  }
} else {
  fijkOption.setFormatOption("analyzeduration", 100);
  fijkOption.setPlayerOption("max_cached_duration", 300);
  if (Platform.isIOS) {
    fijkOption.setFormatOption("probesize", 1024*20);
  } else {
    fijkOption.setFormatOption("probesize", 1024);
  }
}

if (Platform.isIOS) {
  fijkOption.setPlayerOption("videotoolbox", 0);
} else {
  fijkOption.setPlayerOption("opensles", 0);
  fijkOption.setPlayerOption("mediacodec", 0);
  fijkOption.setPlayerOption("mediacodec-hevc", 0);
  fijkOption.setPlayerOption("mediacodec-all-videos", 0);
}
fijkOption.setFormatOption("flush_packets", 1);
fijkOption.setPlayerOption("fast", 1);
fijkOption.setPlayerOption("mediacodec-handle-resolution-change", 0);
fijkOption.setPlayerOption("packet-buffering", 0);
fijkOption.setCodecOption("skip_frame", 0);
fijkOption.setPlayerOption("framedrop", 1);
fijkOption.setCodecOption("skip_loop_filter", 48);
//Empty the dns cache to prevent DNS problems when the playback is switched (key code)
fijkOption.setFormatOption("dns_cache_clear", 1);
// await player?.setOption(FijkOption.formatCategory, "dns_cache_timeout", -1);
fijkOption.setFormatOption("timeout", 0);
fijkOption.setFormatOption("acodec", "pcm_alaw"); // avoid probe
fijkOption.setCodecOption("ar", 8000); // avoid probe Set the audio sample rate (in Hz). 
fijkOption.setCodecOption("ac", 1); // avoid probe
fijkOption.setFormatOption("sample_fmt", "s16"); // avoid probe
fijkOption.setFormatOption("vcodec", "h264"); // avoid probe
fijkOption.setFormatOption("video_size", "1920x1080"); // avoid probe
fijkOption.setFormatOption("pixel_format", "yuv420p"); // avoid probe
fijkOption.setFormatOption("max_delay", "0");
fijkOption.setFormatOption("err_detect", "8");
// await player?.setOption(FijkOption.playerCategory, "sync", "ext");
fijkOption.setFormatOption("fflags", "nobuffer");
// await player?.setOption(FijkOption.formatCategory, "reorder_queue_size", 0);
// await player?.setOption(FijkOption.formatCategory, "avioflags", "direct");
fijkOption.setCodecOption("g", 60);

ProFive avatar Oct 27 '22 10:10 ProFive