java - vlcj在尝试创建服务器流时出错

时间:2022-03-19 01:11:48
   { 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();
}

LOG ERROR:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".

SLF4J:无法加载类“org.slf4j.impl.StaticLoggerBinder”。

SLF4J: Defaulting to no-operation (NOP) logger implementation

SLF4J:默认为无操作(NOP)记录器实现

SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

SLF4J:有关详细信息,请参阅http://www.slf4j.org/codes.html#StaticLoggerBinder。

Streaming 'd:\a.mp4' to ':sout=#duplicate{dst=std{access=http,mux=ts,dst=127.0.0.1:5555}}' Exception in thread "main" java.lang.RuntimeException: Failed to load the native library.

将'd:\ a.mp4'流式传输到':sout = #re duplicate {dst = std {access = http,mux = ts,dst = 127.0.0.1:5555}}'线程“main”中的异常java.lang.RuntimeException :无法加载本机库。

The error was "Unable to load library 'libvlc': JNA native support (win32-amd64/libvlc.dll) not found in resource path (C:\Users\Adam\http\VLC STREAM\bin;E:\Adam\Desktop\vlcj-3.7.0\jna-3.5.2.jar;E:\Adam\Desktop\vlcj-3.7.0\platform-3.5.2.jar;E:\Adam\Desktop\vlcj-3.7.0\slf4j-api-1.7.10.jar;E:\Adam\Desktop\vlcj-3.7.0\vlcj-3.7.0.jar;E:\Adam\Desktop\apache-logging-log4j.jar)".

错误是“无法加载库'libvlc':资源路径中找不到JNA本机支持(win32-amd64 / libvlc.dll)(C:\ Users \ Adam \ http \ VLC STREAM \ bin; E:\ Adam \ Desktop \ vlcj-3.7.0 \ JNA-3.5.2.jar; E:\亚当\桌面\ vlcj-3.7.0 \平台3.5.2.jar; E:\亚当\桌面\ vlcj-3.7.0 \ SLF4J -API-1.7.10.jar; E:\亚当\桌面\ vlcj-3.7.0 \ vlcj-3.7.0.jar; E:\亚当\桌面\ Apache的测井log4j.jar)”。

The required native libraries are named "libvlc.dll" and "libvlccore.dll".

所需的本机库名为“libvlc.dll”和“libvlccore.dll”。

In the text below represents the name of the directory containing "libvlc.dll" and "libvlccore.dll"...

在下面的文本中表示包含“libvlc.dll”和“libvlccore.dll”的目录的名称...

There are a number of different ways to specify where to find the native libraries:

有许多不同的方法可以指定在何处查找本机库:

  1. Include NativeLibrary.addSearchPath("libvlc", ""); at the start of your application code.

    包括NativeLibrary.addSearchPath(“libvlc”,“”);在应用程序代码的开头。

  2. Include System.setProperty("jna.library.path", ""); at the start of your application code.

    包含System.setProperty(“jna.library.path”,“”);在应用程序代码的开头。

  3. Specify -Djna.library.path= on the command-line when starting your application.

    在启动应用程序时在命令行上指定-Djna.library.path =。

  4. Add to the system search path (and reboot).

    添加到系统搜索路径(并重新启动)。

If this still does not work, then it may be necessary to explicitly add the native library directory to the operating system configuration - e.g. on Linux this might mean setting the LD_LIBRARY_PATH environment variable, or adding configuration to the "/etc/ld.so.conf" file or the "/etc/ld.so.conf.d" directory. Of these options, setting LD_LIBRARY_PATH is the only one that would not require root privileges.

如果这仍然不起作用,则可能需要将本机库目录显式添加到操作系统配置中 - 例如,在Linux上,这可能意味着设置LD_LIBRARY_PATH环境变量,或将配置添加到“/etc/ld.so.conf”文件或“/etc/ld.so.conf.d”目录。在这些选项中,设置LD_LIBRARY_PATH是唯一不需要root权限的选项。

Finally, it is not possible to mix CPU architectures - it is not possible for a 64-bit Java Virtual Machine to load 32-bit native libraries.

最后,不可能混合使用CPU架构 - 64位Java虚拟机无法加载32位本机库。

More information may be available in the log.

日志中可能提供了更多信息。

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)  

LIB:

http://zapodaj.net/ed5de522e2b3e.jpg.html

I have no idea

我不知道

1 个解决方案

#1


The error message is very complete and helpful in this case - VLCJ couldn't find the DLL files that it needs to run, so you need to tell it where they are!

在这种情况下,错误消息是非常完整和有用的 - VLCJ无法找到它需要运行的DLL文件,因此您需要告诉它它们在哪里!

Your image shows that you have added the correct Java libraries, it says nothing about libvlc.dll and libvlccore.dll.

您的图像显示您已添加了正确的Java库,它没有说明libvlc.dll和libvlccore.dll。

Quoting from your question:

引用你的问题:

The required native libraries are named "libvlc.dll" and "libvlccore.dll".

所需的本机库名为“libvlc.dll”和“libvlccore.dll”。

In the text below represents the name of the directory containing "libvlc.dll" and "libvlccore.dll"...

在下面的文本中表示包含“libvlc.dll”和“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.

包括NativeLibrary.addSearchPath(“libvlc”,“”);在应用程序代码的开头。

Include System.setProperty("jna.library.path", ""); at the start of your application code.

包含System.setProperty(“jna.library.path”,“”);在应用程序代码的开头。

Specify -Djna.library.path= on the command-line when starting your application.

在启动应用程序时在命令行上指定-Djna.library.path =。

Add to the system search path (and reboot).

添加到系统搜索路径(并重新启动)。

There are a number of options you have there to try, I can't see any evidence of them being used in the code that you've provided.

您有很多选项可供尝试,我看不到任何证据表明它们已在您提供的代码中使用。

If it still doesn't work then chances are you have the wrong architecture (and this is the most common reason for failure in my experience) - if you have a 64 bit JDK installed then you will need 64 bit VLC, likewise a 32 bit JDK will only work with 32 bit VLC.

如果它仍然不起作用,那么你可能有错误的架构(这是我经验失败的最常见原因) - 如果你安装了64位JDK,那么你将需要64位VLC,同样是32​​位JDK仅适用于32位VLC。

#1


The error message is very complete and helpful in this case - VLCJ couldn't find the DLL files that it needs to run, so you need to tell it where they are!

在这种情况下,错误消息是非常完整和有用的 - VLCJ无法找到它需要运行的DLL文件,因此您需要告诉它它们在哪里!

Your image shows that you have added the correct Java libraries, it says nothing about libvlc.dll and libvlccore.dll.

您的图像显示您已添加了正确的Java库,它没有说明libvlc.dll和libvlccore.dll。

Quoting from your question:

引用你的问题:

The required native libraries are named "libvlc.dll" and "libvlccore.dll".

所需的本机库名为“libvlc.dll”和“libvlccore.dll”。

In the text below represents the name of the directory containing "libvlc.dll" and "libvlccore.dll"...

在下面的文本中表示包含“libvlc.dll”和“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.

包括NativeLibrary.addSearchPath(“libvlc”,“”);在应用程序代码的开头。

Include System.setProperty("jna.library.path", ""); at the start of your application code.

包含System.setProperty(“jna.library.path”,“”);在应用程序代码的开头。

Specify -Djna.library.path= on the command-line when starting your application.

在启动应用程序时在命令行上指定-Djna.library.path =。

Add to the system search path (and reboot).

添加到系统搜索路径(并重新启动)。

There are a number of options you have there to try, I can't see any evidence of them being used in the code that you've provided.

您有很多选项可供尝试,我看不到任何证据表明它们已在您提供的代码中使用。

If it still doesn't work then chances are you have the wrong architecture (and this is the most common reason for failure in my experience) - if you have a 64 bit JDK installed then you will need 64 bit VLC, likewise a 32 bit JDK will only work with 32 bit VLC.

如果它仍然不起作用,那么你可能有错误的架构(这是我经验失败的最常见原因) - 如果你安装了64位JDK,那么你将需要64位VLC,同样是32​​位JDK仅适用于32位VLC。