Decrease delay during streaming and live streaming methods

喜你入骨 提交于 2019-12-03 21:53:09

had same issue as you with huge stream delay (around 1.5 - 1.6 sec)

My setup is Android device which streams its camera over RTSP using libStreaming, receiving side is Android device using libVlc as media player. Now I found a solution to decrease delay to 250-300 ms. It was achieved by setting up libVlc with following parameters.

 mLibvlc = new LibVLC();
    mLibvlc.setVout(LibVLC.VOUT_ANDROID_WINDOW);
    mLibvlc.setDevHardwareDecoder(LibVLC.DEV_HW_DECODER_AUTOMATIC);
    mLibvlc.setHardwareAcceleration(LibVLC.HW_ACCELERATION_DISABLED);
    mLibvlc.setNetworkCaching(150);
    mLibvlc.setFrameSkip(true);
    mLibvlc.setChroma("YV12");
    restartPlayer();

private void restartPlayer() {
    if (mLibvlc != null) {
        try {
            mLibvlc.destroy();
            mLibvlc.init(this);
        } catch (LibVlcException lve) {
            throw new IllegalStateException("LibVLC initialisation failed: " + LibVlcUtil.getErrorMsg());
        }
    }
}

You can play with setNetworkCaching(int networkCaching) to customize a bit delay

Please let me know if it was helpful for you or you found better solution with this or another environment.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!