Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 222
Rella Avatar asked Feb 04 '23 05:02

Rella


2 Answers

With java media framework JMF or FMJ

Here is an example with JVM

like image 60
Enrique Avatar answered Feb 05 '23 21:02

Enrique


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/

like image 33
Paul Gregoire Avatar answered Feb 05 '23 20:02

Paul Gregoire