I am trying to create a simple java code that captures video stream and store it in the hard disk. I have downloaded xuggler 3.2 jar file in order to do so. In fact I have add to my eclipse project the following jar files:
xuggle-xuggler-3.4.jar
webcam-capturer-0.3.10.jar
bridj-0.6.2.jar
slf4j-api-1.7.2.jar
slf4j-simple-1.7.2.jar
My code is the following:
public static void main(String [] args) throws InterruptedException{
File file = new File("output.ts");
IMediaWriter writer = ToolFactory.makeWriter(file.getName());
Dimension size = WebcamResolution.QVGA.getSize();
writer.addVideoStream(0, 0, ICodec.ID.CODEC_ID_H264, size.width, size.height);
Webcam webcam = Webcam.getDefault();
webcam.setViewSize(size);
webcam.open(true);
long start = System.currentTimeMillis();
for (int i = 0; i < 50; i++) {
System.out.println("Capture frame " + i);
BufferedImage image = ConverterFactory.convertToType(webcam.getImage(), BufferedImage.TYPE_3BYTE_BGR);
IConverter converter = ConverterFactory.createConverter(image, IPixelFormat.Type.YUV420P);
IVideoPicture frame = converter.toPicture(image, (System.currentTimeMillis() - start) * 1000);
frame.setKeyFrame(i == 0);
frame.setQuality(0);
writer.encodeVideo(0, frame);
// 10 FPS
Thread.sleep(100);
}
writer.close();
System.out.println("Video recorded in file: " + file.getAbsolutePath());
}
The problem is that I am receiving the following error when I am trying to run the code:
[main] ERROR com.xuggle.ferry.JNILibraryLoader - Could not load library: xuggle-ferry; version: 3; Visit
http://www.xuggle.com/xuggler/faq/ to find common solutions to this problem
Exception in thread "main" java.lang.UnsatisfiedLinkError: no xuggle-ferry in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)