简体   繁体   English

从Java中的mjpeg流读取和显示视频

[英]Read and display video from mjpeg stream in java

I use the following code to broadcast live mjpeg stream from my webcam. 我使用以下代码从网络摄像头广播实时mjpeg流。

import com.github.sarxos.webcam.Webcam;
import com.github.sarxos.webcam.WebcamStreamer;


public class MjpegStreamingExample {

public static void main(String[] args) throws InterruptedException {
      Webcam w = Webcam.getDefault();
      new WebcamStreamer(8080, w, 0.5, true);
       do {
         Thread.sleep(5000);
       } while (true);
}

How can i receive this live stream and display it with java in another computer? 我如何接收此实时流并在另一台计算机上用Java显示它?

I believe this code example is what you are after: 我相信您所追求的是这个代码示例:

IpCamDevice ipcam = new B7210("B7210", "114.32.216.24");
ipcam.setAuth(new IpCamAuth("demo", "demo"));
ipcam.setSize(B7210.SIZE_QVGA);

IpCamDriver driver = new IpCamDriver();
driver.register(ipcam);

Webcam.setDriver(driver);

WebcamPanel panel = new WebcamPanel(Webcam.getDefault());
panel.setFPS(0.5); // 1 frame per 2 seconds

JFrame f = new JFrame("Night Tree Somewhere");
f.add(panel);
f.pack();
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

So WebcamStreamer makes the stream available on some stream (port 8080 in your case) and then the below code you enter the IP address of the cam you are after. 因此,WebcamStreamer使该流在某些流(在您的情况下为端口8080)上可用,然后在下面的代码中输入要添加的凸轮的IP地址。

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

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