java - 使用java进行axis ip摄像机直播

标签 java ip-camera

我有axis m1114 ip 摄像机

我想使用java显示实时流媒体以及录制流媒体。我尝试了以下代码,但帧速率非常低

请建议一些 api 为我提供更多帧速率和录制功能。

import java.io.File;
import java.net.URL;
import com.googlecode.javacpp.Loader;
import com.googlecode.javacv.*;
import com.googlecode.javacv.cpp.*;
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
import static com.googlecode.javacv.cpp.opencv_calib3d.*;
import static com.googlecode.javacv.cpp.opencv_objdetect.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import javax.imageio.ImageIO;
import  demo.authenticator.MyAuthenticator;
import java.net.Authenticator;
import java.net.MalformedURLException;
import org.jcodec.api.SequenceEncoder;
public class Demo {
    public static void main(String[] args) throws IOException {

        CanvasFrame CamWindow = new CanvasFrame("Camera");
        int i=0,j=0;

        URL url = null ;
        SequenceEncoder encoder=new SequenceEncoder(new File("video.mp4"));
        try {
            // Create a new URL object from the URL-string of our camera.
            url = new URL("http://192.168.168.92/axis-cgi/jpg/image.cgi");
        } catch (MalformedURLException m) {
            m.getMessage();
        }

        // Check if this camera requires authentication.
        // If so, then create and set the authenticator object.

            MyAuthenticator authenticator = new MyAuthenticator("root",
                        "pass");
    Authenticator.setDefault(authenticator);

    Long stime=System.currentTimeMillis();
        while(true){
            i++;
        //InputStream is = url.openStream();
        BufferedImage image = ImageIO.read(url);

        CamWindow.showImage(image);
     //   is.close();

       /* if(i<100)
        {
           encoder.encodeImage(image);
        }
        else 
        {
            if(j==0)
            {
                encoder.finish();
                j++;
                System.out.println("video saved");
                System.out.println((System.currentTimeMillis()-stime)/1000+"seconds");
            }

        }*/
        System.out.println((System.currentTimeMillis()-stime));
        }
    }
}

最佳答案

安讯士相机 API 位于:http://www.axis.com/files/manuals/vapix_video_streaming_52937_en_1307.pdf

你需要使用这个: http:///axis-cgi/mjpg/video.cgi

而不是您现在拥有的图像 URL。从安讯士相机获取静态图像会非常不稳定。您需要使用它吐出的 Motion JPEG feed。

关于java - 使用java进行axis ip摄像机直播,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20417795/

相关文章:

从 RTSP MJPEG 流构建 JPEG 图像

java - 在使用 Java/Kotlin 进行编程时,推荐使用 Tail recursion 还是 Iterative 版本?性能上有区别吗?

java - 以下代码在 Eclipse 中工作,但是当我转换为 Maven 项目时,此代码给出错误

java - javafx 中的动画菜单栏

java - 如何在 Java 中使用 spring.cloud 反序列化/序列化 Azure 服务总线

python - Python 3 IP网络摄像头字节错误

c++ - OpenCV IP 摄像机应用程序崩溃 [h264 @ 0xxxxx] 访问单元中缺少图片

java - Hibernate 多对多双向 - 双向 @JsonManagedReference 和 @JsonBackReference

java - 从网络摄像机捕获视频

linux - RTSP 流转 ffmpeg 问题