swing+vlc实现播放rtsp流视频

下载配置文件

1.到vlc官网下载最新版的vlc http://www.videolan.org/
下载安装完成后,打开文件夹
swing+vlc实现播放rtsp流视频_第1张图片
复制到项目根目录vlc文件夹中
2.到VLCJ官网下载对应版本的VLCJ http://capricasoftware.co.uk/projects/vlcj
3.到https://www.slf4j.org/下载最新版本的slf4j
4.导入vlc和slf4j中的jar包:jna-5.2.0.jar,jna-platform-5.2.0.jar,slf4j-api-1.7.28.jar,slf4j-nop-1.7.28.jar,vlcj-3.12.1.jar

代码

private VLCDemo()
{
	JFrame frame = new JFrame("vlcDemo");

	EmbeddedMediaPlayerComponent mediaPlayerComponent = new EmbeddedMediaPlayerComponent();

	mediaPlayerComponent.setSize(1280, 960);
	frame.getContentPane().setLayout(null);
	frame.add(mediaPlayerComponent);

	frame.setLocation(100, 100);
	frame.setSize(1440, 1024);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setVisible(true);


	MediaPlayer player = mediaPlayerComponent.getMediaPlayer();

	String[] options =
		{"video-filter=motionblur",  "network-caching=200", "no-plugins-cache"};

	player.playMedia("rtsp://admin:[email protected]:554/Streaming/Channels/102?transportmode=unicast",options);

	player.stop();

	player.start();



}

public static void main(String[] args) {
	NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "vlc");
	Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
	new VLCDemo();
}

你可能感兴趣的:(swing+vlc实现播放rtsp流视频)