vlc android sdk,vlc-android-sdk - cannot view RTSP live video

问题

I've been working on an Android application that shows live streaming video via RTSP.

Assuming I have a well-functioning RTSP server that passes h264 packets, and to view the stream we should connect to rtsp://1.2.3.4:5555/stream

So I tried to use the native MediaPlayer\VideoView, but no luck (the video was stuck after 2-3 seconds of playback, so I loaded mrmaffen's vlc-android-sdk (can be found here) and used the following code:

ArrayList options = new ArrayList();

options.add("--no-drop-late-frames");

options.add("--no-skip-frames");

options.add("-vvv");

videoVlc = new LibVLC(options);

newVideoMediaPlayer = new org.videolan.libvlc.MediaPlayer(videoVlc);

final IVLCVout vOut = newVideoMediaPlayer.getVLCVout();

vOut.addCallback(this);

vOut.setVideoView(videoView); //videoView is a pre-defined view which is part of the layout

vOut.attachViews();

newVideoMediaPlayer.setEventListener(this);

Media videoMedia = new Media (videoVlc, Uri.parse(mVideoPath));

newVideoMediaPlayer.setMedia(videoMedia);

newVideoMediaPlayer.play();

The problem is that I see a blank screen.

Keep in mind that when I put a RTSP link with audio stream only, it works fine.

Is someone familliar with this sdk and have an idea about this issue?

Thanks in advance

回答1:

I play rtsp streaming with following code

try {

Uri rtspUri=Uri.parse("rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov");

final MediaWrapper mw = new MediaWrapper(rtspUri);

mw.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);

mw.addFlags(MediaWrapper.MEDIA_VIDEO);

MediaWrapperListPlayer.getInstance().getMediaList().add(mw);

VLCInstance.getMainMediaPlayer().setEventListener(this);

VLCInstance.get().setOnHardwareAccelerationError(this);

final IVLCVout vlcVout = VLCInstance.getMainMediaPlayer().getVLCVout();

vlcVout.addCallback(this);

vlcVout.setVideoView(mSurfaceView);

vlcVout.attachViews();

final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);

final String aout = VLCOptions.getAout(pref);

VLCInstance.getMainMediaPlayer().setAudioOutput(aout);

MediaWrapperListPlayer.getInstance().playIndex(this, 0);

} catch (Exception e) {

Log.e(TAG, e.toString());

}

When you get playing event, you need enable video track.

private void onPlaying() {

stopLoadingAnimation();

VLCInstance.getMainMediaPlayer().setVideoTrackEnabled(true);

}

This may be helpful for you

回答2:

Try adding this option:

--rtsp-tcp

来源:https://stackoverflow.com/questions/34633273/vlc-android-sdk-cannot-view-rtsp-live-video

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值