[英]RTSP client in Java - link doesn't work
I am writing simple rtsp client. 我正在编写简单的rtsp客户端。 I wanna play video from my IP camera. 我想从我的IP摄像头播放视频。
I can see preview of my camera when I open this link in VLC. 当我在VLC中打开此链接时,我可以看到我的相机的预览。
rtsp://@192.168.1.10:554/user=admin_password=tlJwpbo6_channel=1_stream=0.sdp?real_stream
But I can't open this link in java. 但我无法在java中打开此链接。 I have only black screen. 我只有黑屏。 Here is my code. 这是我的代码。
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import uk.co.caprica.vlcj.binding.LibVlc;
import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
import uk.co.caprica.vlcj.mrl.RtspMrl;
import uk.co.caprica.vlcj.runtime.RuntimeUtil;
import com.sun.jna.Native;
import com.sun.jna.NativeLibrary;
public class Main {
private final EmbeddedMediaPlayerComponent mediaPlayerComponent;
public static void main(final String[] args) {
NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "C:\\Program Files\\VideoLAN\\VLC");
Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new Main(args);
}
});
}
private Main(String[] args) {
JFrame frame = new JFrame("vlcj Tutorial");
mediaPlayerComponent = new EmbeddedMediaPlayerComponent();
frame.setContentPane(mediaPlayerComponent);
frame.setLocation(100, 100);
frame.setSize(1920, 1080);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
String address ="C:\\Users\\TheKing\\Desktop\\onviff\\src\\example.mp4";
address = new RtspMrl().host("@192.168.1.10").port(554).path("/user=admin_password=tlJwpbo6_channel=1_stream=0.sdp?real_stream").value();
System.out.println(address);
mediaPlayerComponent.getMediaPlayer().playMedia(address);
}
}
My player works because I tested it with simple mp4 file. 我的播放器工作,因为我用简单的mp4文件测试它。
How should I open my rtsp stream ? 我该如何打开我的rtsp流?
After 10 hours of research I found solution for that... Code is Okey here, but there is another mix-up. 经过10个小时的研究,我找到了解决方案...代码在这里很好,但还有另一个混淆。
This configuration works for me 这个配置适合我
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.