6

Since JavaFX2.0 has a media view is it somehow possible to live stream the camera feed into the Media component in real time? Since there is no camera API I am unaware of how to make this happen. Can we use another Java library to work with the camera and then stream the video in the MediaView

So is it possible, and if yes then how can we do it. May be by using any JavaAPI for camera and then streaming the video into the MediaView?

Jacob Schoen
  • 13,416
  • 15
  • 79
  • 100
Shiv Kumar Ganesh
  • 3,701
  • 8
  • 40
  • 75
  • http://fmj-sf.net/ is one java based api which I found while browsing Stack Overflow but I am still not sure of it. And its only one part of the entire question(Just to get the API for Java Based Application so as to capture video or stuff) – Shiv Kumar Ganesh Jul 03 '12 at 08:50
  • 1
    http://stackoverflow.com/questions/115835/what-is-the-best-method-to-capture-images-from-a-live-video-device-for-use-by-a This answer also provides some information on the required thing. But not at all related to JavaFX. But still seems to be a bit more focused. – Shiv Kumar Ganesh Jul 03 '12 at 08:52
  • Not sure if you ever got an answer (and this isn't really one), but you may want to take a look at the [Supported Protocols](http://docs.oracle.com/javafx/2/api/javafx/scene/media/package-summary.html#SupportedProtocols). – Jacob Schoen Jul 05 '12 at 19:05
  • @jschoen Thanks for pointing this out. :) I did not get an answer.Trying out some hacks though.Will update if things work out from the link provided :) thanks again – Shiv Kumar Ganesh Jul 05 '12 at 19:13
  • Read This http://stackoverflow.com/questions/2525278/how-to-get-video-and-audio-streams-from-web-cameras-with-java Hope it helps :) – Code2Interface Jul 20 '12 at 11:13

2 Answers2

1

There is a Java library called Xuggle that is an open source solution for streaming video into Java applications. It is built on top of the ffmpeg libraries.

In my experience it will work with some implementations of the MPEG-2 and MPEG-4 codecs, but not others. If you were not aware, there are something like 800 different versions of those codecs and some of them end up sticking packets on the front, or in the middle, or at the end in order to force you to use their decoders when displaying the video. Up to, and perhaps including, the new JavaFX code there has been very little robust support for streaming video into Java.

You may want to explore doing something like embedding an instance of VLC in a JPanel and displaying that to your user. There are also libraries that attempt to allow some interaction between Flash and Java that could be used to approach this issue.

Good Luck!

Matt N
  • 146
  • 5
0

It seems that in 2.0 you still cannot attach an external source for the video/audio streams. You need to create a file and provide an uri to this file to play video in the MediaView. Not acceptable for the capture video from the camera. I did not do this in JavaFX 2.0 but in 1.3 we used to deliver just an image to the ImageView writing our own capturer/streamer. Possibly you can do this with any 3rd party lib.

LeonidVlad
  • 83
  • 7