我正在使用64位操作系统Windows 7,我有32位VLC版本1.1.8。
我添加了这些库
jna.jar
platform.jar
vlcj-1.1.5.1.jar
我无法使用jVlc
进行流式传输public class HelloVLC {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
System.out.println( WindowsRuntimeUtil.getVlcInstallDir());
NativeLibrary.addSearchPath("libvlc", "C:\\Program Files (x86)\\VideoLAN\\VLC");
String media = "dshow://";
String[] options = {" :dshow-vdev=Integrated Webcam :dshow-adev= :dshow-caching=200", ":sout = #transcode{vcodec=theo,vb=800,scale=0.25,acodec=vorb,ab=128,channels=2,samplerate=44100}:display :no-sout-rtp-sap :no-sout-standard-sap :ttl=1 :sout-keep"};
System.out.println("Streaming '" + media + "' to '" + options + "'");
MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory();
final HeadlessMediaPlayer mediaPlayer = mediaPlayerFactory.newMediaPlayer();
mediaPlayer.playMedia(media, options);
}
}
我收到错误Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'libvlc': The specified module could not be found.
请帮助。有没有办法让这个代码在64位操作系统中工作?
答案 0 :(得分:6)
您是否尝试过使用32位JVM运行它?
答案 1 :(得分:6)
如果您使用的是Windows 7,则在您的vlc安装中搜索文件libvlc.dll和libvlccore.dll文件,并将其路径添加到您编写的代码中 NativeLibrary.addSearchPath()也添加...
这在我的案例windows 7中起了作用。
NativeLibrary.addSearchPath(
RuntimeUtil.getLibVlcLibraryName(), ""c:/Program Files/VideoLAN/VLC/");
Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
LibXUtil.initialise();
答案 2 :(得分:0)
VLCj带有自动发现方法,独立于os,为JNA添加相关路径:搜索路径:
NativeDiscovery nd = new NativeDiscovery();
if (!nd.discover()) {
System.out.println("VLC not found");
System.exit(-1);
}
String vlcLibName = RuntimeUtil.getLibVlcName();
String vlcLibCoreName = RuntimeUtil.getLibVlcCoreName();
Native.loadLibrary(vlcLibName, LibVlc.class);
...等 有关如何加载VLC原生的详细教程,请参阅 http://capricasoftware.co.uk/#/projects/vlcj/tutorial/first-steps (另请参阅该教程中的前几个步骤)!