java 摄像头,使用Java中的网络摄像头捕获视频

I am trying to capture video screenshot from a java application. I have donwloaded the sarxos/webcam-capture library. I have add to my project the executable jar. It is a little bit mess. I want to capture video from a simple javafx interface that I have created. The issue is that after installing the lib and slf4 then it required to install also xuggle. I add xuggle in the path and my code is the following:

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

However I am receiving the following:

Caused by: java.lang.UnsatisfiedLinkError: no xuggle-ferry in java.library.path

EDIT2 I also tried the jxcapture library. I add in my project all the necessary libs I run the following code: enter link description here, the code worked fine I manage to store the video, however in the end I am receiving the following error:

8614 [JNIWrapper.ShutdownHook] ERR

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值