{ String media = "d:\\a.mp4";
String options = formatHttpStream("127.0.0.1", 5555);
System.out.println("Streaming '" + media + "' to '" + options + "'");
MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory(args[0]);
HeadlessMediaPlayer mediaPlayer = mediaPlayerFactory.newHeadlessMediaPlayer();
mediaPlayer.playMedia(media, options);
Thread.currentThread().join();
}
private static String formatHttpStream(String serverAddress, int serverPort) {
StringBuilder sb = new StringBuilder(60);
sb.append(":sout=#duplicate{dst=std{access=http,mux=ts,");
sb.append("dst=");
sb.append(serverAddress);
sb.append(':');
sb.append(serverPort);
sb.append("}}");
return sb.toString();
}
at uk.co.caprica.vlcj.binding.LibVlcFactory.create(LibVlcFactory.java:198)
at uk.co.caprica.vlcj.player.MediaPlayerFactory.<init>(MediaPlayerFactory.java:256)
at StreamHttp.main(StreamHttp.java:11)
最佳答案
在这种情况下,错误消息非常完整且很有帮助——VLCJ 找不到它需要运行的 DLL 文件,所以你需要告诉它它们在哪里!
您的图像显示您已添加正确的 Java 库,它没有说明 libvlc.dll 和 libvlccore.dll。
引用你的问题:
The required native libraries are named "libvlc.dll" and "libvlccore.dll".
In the text below represents the name of the directory containing "libvlc.dll" and "libvlccore.dll"...
There are a number of different ways to specify where to find the native libraries:
Include NativeLibrary.addSearchPath("libvlc", ""); at the start of your application code.
Include System.setProperty("jna.library.path", ""); at the start of your application code.
Specify -Djna.library.path= on the command-line when starting your application.
Add to the system search path (and reboot).
https://stackoverflow.com/questions/30113450/