java技术,通过WEB方式来 远程直播网络摄像头监控的视频

nevergiveup0924 2010-10-08 02:06:20
如题:
如何使用java技术,通过Web方式来实时监控网络摄像头的视频并进行录制呢?希望大侠们能指点迷津~
在此拜谢~~~
...全文
8004 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
aj_zLc 2010-12-29
  • 打赏
  • 举报
回复
最近也在学习这方面的资料,谢谢分享
mrshelly 2010-10-20
  • 打赏
  • 举报
回复
在视频头上做个视频流广播应该就行了. 至于监控管理, 则需要自己做好控制协议. 这个不推荐个人开发. 主流一些的, 可以使用 FMS 以及 MS 的 Media Stream Server 相关产品.

如果对于实时性要求不是很高. 一般的视频头都带有 远程HTTP图片获取功能的. 这时的监控与视频保存, 则仅为图片的处理了.

这也是成本最低的做法.
syz 2010-10-11
  • 打赏
  • 举报
回复
JMF不好用吧? 看看JMF好象有标准的代码例子,虽然简单点,但功能和效率不好.
可一看看MS的平台.
Jay_+wqq_635731323 2010-10-09
  • 打赏
  • 举报
回复
学习学习
nevergiveup0924 2010-10-09
  • 打赏
  • 举报
回复
空指针问题出现的愿意就是获取不到连接的视频设备,我用的是网络摄像头,通过IP明明可以访问的!
pingjiuzhou 2010-10-09
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 nevergiveup0924 的回复:]
上面是我在网上搜到的applet方式获取摄像头的源码,运行时出现空指针错误!
[/Quote]
哪出现空指针撒? 看看问题在哪呗
nevergiveup0924 2010-10-09
  • 打赏
  • 举报
回复
上面是我在网上搜到的applet方式获取摄像头的源码,运行时出现空指针错误!
nevergiveup0924 2010-10-09
  • 打赏
  • 举报
回复
有人研究过吗?我在网上搜了很多资料,说是可以用JMF可以实现,可是我把网络视频设备通过IP访问时,出现空指针错误!代码如下:希望各位高手能不吝赐教~~

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.Transparency;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.PixelGrabber;
import java.io.File;
import java.io.IOException;
import java.util.Vector;

import javax.imageio.ImageIO;
import javax.media.Buffer;
import javax.media.CaptureDeviceInfo;
import javax.media.CaptureDeviceManager;
import javax.media.Format;
import javax.media.MediaLocator;
import javax.media.NoPlayerException;
import javax.media.control.FrameGrabbingControl;
import javax.media.format.RGBFormat;
import javax.media.format.VideoFormat;
import javax.media.protocol.DataSource;
import javax.media.protocol.PushBufferDataSource;
import javax.media.util.BufferToImage;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;

import jmapps.jmstudio.CaptureDialog;
import jmapps.ui.PlayerFrame;
import jmapps.util.CDSWrapper;
import jmapps.util.JMFUtils;

public class Demo001 extends PlayerFrame {
public Demo001() {
super(null, "视频捕获窗口");
}
DataSource dataSource;
private CaptureDeviceInfo infor;
private MediaLocator mediaLocator;

String str1 = "http://169.254.104.109:80";
String str2 = "http://169.254.104.109:80";

private String url = "http://169.254.104.109:80";

private Component com;

private JPanel panel;

private int captureCount = 0;

FrameGrabbingControl controlGrabber;

public void play() {
if (mediaPlayerCurrent.getState() != mediaPlayerCurrent.Started) {
mediaPlayerCurrent.start();
}
}

private void init() throws NoPlayerException, IOException {
// setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
String nameCaptureDeviceAudio = null;
String nameCaptureDeviceVideo = null;
CaptureDialog dialogCapture = new CaptureDialog(this, null);
dialogCapture.show();
if (dialogCapture.getAction() == CaptureDialog.ACTION_CANCEL)
return;
CaptureDeviceInfo cdi = dialogCapture.getAudioDevice();
if (cdi != null && dialogCapture.isAudioDeviceUsed())
nameCaptureDeviceAudio = cdi.getName();
cdi = dialogCapture.getVideoDevice();
if (cdi != null && dialogCapture.isVideoDeviceUsed())
nameCaptureDeviceVideo = cdi.getName();
dataSource = JMFUtils.createCaptureDataSource(nameCaptureDeviceAudio,
dialogCapture.getAudioFormat(), nameCaptureDeviceVideo,
dialogCapture.getVideoFormat());
DataSource cdswrapper = new CDSWrapper(
(PushBufferDataSource) dataSource);
dataSource = cdswrapper;
dataSource.connect();
open(dataSource);
JPanel controlPanel = new JPanel();
controlPanel.setName("controlPnael is here");
add(BorderLayout.SOUTH, controlPanel);
JButton capture = new JButton("Capture Image");
capture.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
mediaPlayerCurrent.stop();
Buffer bufferFrame;
BufferToImage bufferToImage;
Image image;
BufferedImage bi;
controlGrabber = (FrameGrabbingControl) mediaPlayerCurrent
.getControl("javax.media.control.FrameGrabbingControl");
bufferFrame = controlGrabber.grabFrame();
bufferToImage = new BufferToImage((VideoFormat) bufferFrame
.getFormat());
image = bufferToImage.createImage(bufferFrame);

File out = new File("capture" + (++captureCount) + ".png");
try {
bi = toBufferedImage(image);
ImageIO.write(bi, "png", out);
} catch (IOException e1) {
e1.printStackTrace();
}

mediaPlayerCurrent.start();

}
});

controlPanel.add(BorderLayout.CENTER, capture);

JButton playStop = new JButton("stop");
// add(BorderLayout.SOUTH,playControl);
playStop.addActionListener(new ActionListener() {

// @Override
public void actionPerformed(ActionEvent arg0) {
mediaPlayerCurrent.stop();

}
});
controlPanel.add(BorderLayout.EAST, playStop);

JButton playStart = new JButton("start");
// add(BorderLayout.SOUTH,playControl);
playStart.addActionListener(new ActionListener() {

// @Override
public void actionPerformed(ActionEvent arg0) {
// mediaPlayerCurrent.stop();
if (mediaPlayerCurrent.getState() != mediaPlayerCurrent.Started) {
mediaPlayerCurrent.start();
}
}
});
controlPanel.add(BorderLayout.WEST, playStart);
addWindowListener(new WindowAdapter() {

// @Override
public void windowClosing(WindowEvent e) {
mediaPlayerCurrent.close();
dataSource.disconnect();
System.out.println("exit.....");
System.exit(0);

}
});
}

public static boolean hasAlpha(Image image) {
// If buffered image, the color model is readily available
if (image instanceof BufferedImage) {
BufferedImage bimage = (BufferedImage) image;
return bimage.getColorModel().hasAlpha();
}
// Use a pixel grabber to retrieve the image's color model;
// grabbing a single pixel is usually sufficient
PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false);
try {
pg.grabPixels();
} catch (InterruptedException e) {
}

// Get the image's color model
ColorModel cm = pg.getColorModel();
return cm.hasAlpha();
}

public static BufferedImage toBufferedImage(Image image) {
if (image instanceof BufferedImage) {
return (BufferedImage) image;
}

// This code ensures that all the pixels in the image are loaded
image = new ImageIcon(image).getImage();

// Determine if the image has transparent pixels; for this method's
// implementation, see e661 Determining If an Image Has Transparent
// Pixels
boolean hasAlpha = hasAlpha(image);

// Create a buffered image with a format that's compatible with the
// screen
BufferedImage bimage = null;
GraphicsEnvironment ge = GraphicsEnvironment
.getLocalGraphicsEnvironment();
try {
// Determine the type of transparency of the new buffered image
int transparency = Transparency.OPAQUE;
if (hasAlpha) {
transparency = Transparency.BITMASK;
}

// Create the buffered image
GraphicsDevice gs = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gs.getDefaultConfiguration();
bimage = gc.createCompatibleImage(image.getWidth(null), image
.getHeight(null), transparency);
} catch (HeadlessException e) {
// The system does not have a screen
System.err.println("The system does not have a screen!");
System.exit(-1);
}

if (bimage == null) {
// Create a buffered image using the default color model
int type = BufferedImage.TYPE_INT_RGB;
if (hasAlpha) {
type = BufferedImage.TYPE_INT_ARGB;
}
bimage = new BufferedImage(image.getWidth(null), image
.getHeight(null), type);
}

// Copy image to buffered image
Graphics g = bimage.createGraphics();

// Paint the image onto the buffered image
g.drawImage(image, 0, 0, null);
g.dispose();

return bimage;
}

private MediaLocator autoDetect() {// 自动识别功能函数
MediaLocator ml = null; // 视频采集设备对应的MediaLocator
VideoFormat currentFormat = null;// 用户定制获得视频采集设备支持的格式
Format setFormat = null;// 用户定制视频采集设备输出的格式
Format[] videoFormats = null;// 视频采集设备支持的所有格式
System.out.println("AutoDetect for VFW" + url);// VFW:微软的 Video for Windows
// 获得当前所有设备列表
System.out.println("-----" + url);
Vector deviceList = CaptureDeviceManager.getDeviceList(null);
System.out.println("-----");
CaptureDeviceInfo device = CaptureDeviceManager.getDevice(url);
if (deviceList != null) {
// 根据设备列表,找出可用设备名称
for (int i = 0; i < deviceList.size(); i++) {
try {
CaptureDeviceInfo di = (CaptureDeviceInfo) deviceList
.elementAt(i);
// 如果设备名称以vfw开头
if (di.getName().startsWith("vfw:")) {
// 获得所有支持RGB格式
videoFormats = di.getFormats();
for (int j = 0; j < videoFormats.length; j++) {
// 我们只需要第一种RGB格式
if (videoFormats[j] instanceof RGBFormat) {
currentFormat = (RGBFormat) videoFormats[i];
break;
}
}
if (currentFormat == null) {
System.err.println("Search For RGBFormat Failed");
System.exit(-1);
}
// 通过设备,获得MediaLocator,这个很重要
ml = di.getLocator();
}
} catch (Exception npe) {
System.err.println("Unable to get Processor for device");
System.exit(-1);
}
}
} else {
System.err.println("No Capture Device OK");
System.exit(-1);
}
mediaLocator = ml;
return ml;// 返回可用的设备medialocator
}

public static void main(String[] args) throws NoPlayerException,
IOException {
Demo001 demo = new Demo001();
demo.setSize(300, 400);
demo.autoDetect();
demo.init();
demo.play();
demo.setVisible(true);
}
}
loveunittesting 2010-10-09
  • 打赏
  • 举报
回复
这主要不是靠web技术。这需要控制硬件的,需要使用客户端应用程序来控制,要在网页上控制,也必须借助acitvex控件
覆水难收 2010-10-09
  • 打赏
  • 举报
回复
用gis
myhope88 2010-10-09
  • 打赏
  • 举报
回复
正想了解下呢
nevergiveup0924 2010-10-09
  • 打赏
  • 举报
回复
希望能结识更多的Java多媒体技术开发的朋友,请加入群:37209701
让我们共同探讨Java多媒体开发技术!随时欢迎你们的到来!
JavaMan 2010-10-08
  • 打赏
  • 举报
回复
正打算研究研究呢!
zhwh 2010-10-08
  • 打赏
  • 举报
回复
http://topic.csdn.net/t/20060424/15/4709463.html
dr_lou 2010-10-08
  • 打赏
  • 举报
回复
连硬件,传数据。
simaa0106 2010-10-08
  • 打赏
  • 举报
回复
百度下就行了。我记得有这样的代码

81,087

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧