-2
   { 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: Defaulting to no-operation (NOP) logger implementation

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

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.

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)".

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:

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

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

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

  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.

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.

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

Adam
  • 65
  • 1
  • 10

1 Answers1

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!

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

Quoting from your question:

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).

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.

Community
  • 1
  • 1
Michael Berry
  • 70,193
  • 21
  • 157
  • 216