与Android libvlc播放RTP流时减少延迟

问题描述 投票:2回答:1

我使用LibVLC版本3.0.0打进来的MPEG2TS流通过RTP在Android上。代码如下:

SurfaceView playerView; //Initialized somewhere before    

LibVLC libVlc = new LibVLC(context, arrayListOf("--file-caching=150", "--network-caching=150",
                    "--clock-jitter=0", "--live-caching=150", "--clock-synchro=0",
                    "-vvv", "--drop-late-frames", "--skip-frames"));
MediaPlayer player = new MediaPlayer(libVlc);
IVLCVout vout = player.getVLCVout();
vout.setVideoView(playerView);
vout.attachViews();
Media media = new Media(libVlc, Uri.parse("rtp://@:" + UDP_PORT + "/"));
player.setMedia(media);
player.play();

这确实起到流,但是有2秒左右的延迟。我肯定知道的延迟可以减少到约300毫秒其他一些球员可以在此延迟播放。哪些选项我应该用它来减少这种延迟?我明白,我将不得不贸易质量,但我怎么做它摆在首位?

java android vlc libvlc
1个回答
5
投票

还有就是从2秒〜延迟减小到200毫秒〜方式

解:

 ArrayList<String> options = new ArrayList<>();
 options.add("--file-caching=2000");
 options.add("-vvv");

 LibVLC mLibVLC = new LibVLC(getApplicationContext(), options);
 MediaPlayer mMediaPlayer =  new MediaPlayer(mLibVLC);

 Media media = new Media(mLibVLC, Uri.parse("rtsp://192.168.0.1:1935/myApp/myStream"));
        media.setHWDecoderEnabled(true, false);
        media.addOption(":network-caching=150");
        media.addOption(":clock-jitter=0");
        media.addOption(":clock-synchro=0");

 mMediaPlayer.setMedia(media);
 mMediaPlayer.play();

希望这可以帮助您! =)

© www.soinside.com 2019 - 2024. All rights reserved.