How to get video and audio streams from web cameras with Java?

久未见 提交于 2020-01-12 05:30:09

问题


How can I get video and audio streams from web cameras with Java (in a cross-platform way)?

For example, we have a computer with 3-4 USB web cameras; we want to get their streams and make them visible in the user interface. How can we perform such a thing? I need code for a simple app which would find ALL cameras on the computer and let us select camera to wach. Can any one, please share such one?


回答1:


With java media framework JMF or FMJ

Here is an example with JVM




回答2:


I see your comment about the solution needing to be "pure" java, but this is really "nearly" impossible. You will need to use some sort of native library for accessing the devices, with that being stated; I suggest that you look at Xuggler as your solution. Xuggler supports Windows, Mac, and Linux and they also offer example code for handling audio and video. Lastly the library is FREE. Webcam capture example: http://xuggle.googlecode.com/svn/trunk/java/xuggle-xuggler/src/com/xuggle/xuggler/demos/DisplayWebcamVideo.java

While Xuggle does not have an example of microphone capture, you can find samples on the mailing list or you could use code written by the packet-mulitbroadcaster project found here: https://code.google.com/p/packet-multibroadcaster/




回答3:


You can try my solution. It uses OpenCV to capture the image and jetty server to transmit it via WebSocket. The example has three classes and it will be easy to understand. Now I can send only video, but I'm working on audio aswell.




回答4:


I'd use flex. It can be relatively easily integrated with java backend.

UPD:

Pure Java needed

Then you should consider JavaFX solutions. I'm not a big expert in javafx, I've only written some basic test applications, but I'm sure it's a modern way of solving described problem with pure java.



来源:https://stackoverflow.com/questions/2525278/how-to-get-video-and-audio-streams-from-web-cameras-with-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!