简体   繁体   English

如何在没有jmf的情况下在java中构建视频聊天程序?

[英]how to build a video chat program in java without jmf?

I want to create a C/S chat program in java using socket, and now I want to add online video-chat feature to it. 我想使用socket在java中创建一个C / S聊天程序,现在我想为它添加在线视频聊天功能。 After google I found jmf and followed some tutorials, but I don't really like it because every client must install jmf and register webcam( or other audio devices). 谷歌之后我找到了jmf并且遵循了一些教程,但我并不喜欢它,因为每个客户端都必须安装jmf并注册网络摄像头(或其他音频设备)。

So I looking forward to an alternative lib without jmf and found libs like (juv, xuggle), and then works well. 所以我期待一个没有jmf的替代lib,并找到像(juv,xuggle)这样的库,然后效果很好。 Unfortunately, they can only drive the webcam, can't access the audio device. 不幸的是,他们只能驾驶网络摄像头,无法访问音频设备。

Can anyone give me some advice? 谁能给我一些建议?

I have recently been looking at webcam options and I settled on using GStreamer. 我最近一直在寻找网络摄像头选项,我决定使用GStreamer。 It does need separate native libraries but you may be able to bundle these with your program (check the license). 它确实需要单独的本机库,但您可以将它们与您的程序捆绑在一起(检查许可证)。

The good news is that it has built in video and audio streaming. 好消息是它内置了视频和音频流。 The bad news is that it takes a bit of time to get your head around as it is incredibly flexible. 坏消息是它需要一些时间来解决它,因为它非常灵活。 Here is an example of setting up streams from the command line on Windows. 以下是在Windows上从命令行设置流的示例。

Send video:
gst-launch ksvideosrc ! queue ! video/x-raw-yuv,width=320,height=240,framerate=4/1 ! videorate ! videoscale ! ffmpegcolorspace ! queue ! smokeenc ! queue ! udpsink host=[TARGET_IP_ADDRESS] port=5000

Receive video:
gst-launch udpsrc port=5000 ! smokedec ! autovideosink

Send audio:
gst-launch audiotestsrc ! audioconvert ! audio/x-raw-int,channels=1,depth=16,width=16,rate=44100 ! rtpL16pay  ! udpsink host=[TARGET_IP_ADDRESS] port=5001

Receive audio:
gst-launch udpsrc port=5001 ! "application/x-rtp,media=(string)audio, clock-rate=(int)44100, width=16, height=16, encoding-name=(string)L16, encoding-params=(string)1, channels=(int)1, channel-positions=(int)1, payload=(int)96" ! rtpL16depay ! audioconvert ! audioresample ! directsoundsink

The sound streams are adapted from the answer here: 声音流来自这里的答案:

moving audio over a local network using GStreamer 使用GStreamer在本地网络上移动音频

For Linux change ksvideosrc to v4l2src and directsoundsink to alsasink. 对于Linux,将ksvideosrc更改为v4l2src并将directsoundsink更改为alsasink。 Anything possible on the command line is possible from within Java using the gstreamer-java library: 可以在Java中使用gstreamer-java库在命令行上执行任何操作:

http://code.google.com/p/gstreamer-java/ http://code.google.com/p/gstreamer-java/

And here are some more useful links: 这里有一些更有用的链接:

GStreamer Manual GStreamer手册

Cheat Sheet 备忘单

Webcam Examples 网络摄像头示例

Streaming Info 流媒体信息

You Can also use OpenCV in order to implement Client Server. 您还可以使用OpenCV来实现Client Server。 OpenCV provides numerous functionalities helping in the capturing of the video. OpenCV提供了许多功能,有助于捕获视频。 http://docs.opencv.org/java/2.4.2/org/opencv/highgui/VideoCapture.html#VideoCapture(int) http://docs.opencv.org/java/2.4.2/org/opencv/highgui/VideoCapture.html#VideoCapture(int)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM