gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 11:12:43 27 4
gpt4 key购买 nike

   { 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();
}

日志错误:

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

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

SLF4J:见 http://www.slf4j.org/codes.html#StaticLoggerBinder了解更多详情。

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

错误是“无法加载库 'libvlc':在资源路径 (C:\Users\Adam\http\VLC STREAM\bin;E:\Adam\Desktop) 中找不到 JNA native 支持 (win32-amd64/libvlc.dll)\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)”。

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

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

有许多不同的方法可以指定在哪里可以找到 native 库:
  • 包括 NativeLibrary.addSearchPath("libvlc", "");在应用程序代码的开头。
  • 包括 System.setProperty("jna.library.path", "");在应用程序代码的开头。
  • 启动应用程序时在命令行上指定 -Djna.library.path=。
  • 添加到系统搜索路径(并重新启动)。

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

    最后,无法混合 CPU 架构 - 无法加载 64 位 Java 虚拟机
    32 位 native 库。

    日志中可能会提供更多信息。
    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)

    库:

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

    我不知道

    最佳答案

    在这种情况下,错误消息非常完整且很有帮助——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).


    您可以尝试许多选项,我看不到任何证据表明它们已在您提供的代码中使用。
    如果它仍然无法正常工作,那么您的架构可能是错误的(根据我的经验,这是失败的最常见原因) - 如果您安装了 64 位 JDK,那么您将需要 64 位 VLC,同样需要 32 位JDK 仅适用于 32 位 VLC。

    关于java - vlcj 在尝试创建服务器流时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30113450/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com