Java 如何设置与DVR的连接并解码数据?

Java 如何设置与DVR的连接并解码数据?,java,android,Java,Android,我的系统由一个数字录像机(dvr)和两个摄像头组成,它们与dvr相连。dvr还可以作为服务器(连接到LAN)。该系统包括一个android应用程序,我在其中输入有关服务器、端口、用户名和密码的信息(我可以使用服务器软件添加帐户)。该应用程序从摄像机中传输视频。我也可以通过http(仅IE)连接dvr,然后显示activeX应用程序 我要做的是编写类似的应用程序,但我遇到了一个问题——如何从dvr获取视频流?我不是Java专家,尝试连接dvr,但没有成功 这是我的密码: import java.n

我的系统由一个数字录像机(dvr)和两个摄像头组成,它们与dvr相连。dvr还可以作为服务器(连接到LAN)。该系统包括一个android应用程序,我在其中输入有关服务器、端口、用户名和密码的信息(我可以使用服务器软件添加帐户)。该应用程序从摄像机中传输视频。我也可以通过http(仅IE)连接dvr,然后显示activeX应用程序

我要做的是编写类似的应用程序,但我遇到了一个问题——如何从dvr获取视频流?我不是Java专家,尝试连接dvr,但没有成功

这是我的密码:

import java.net.*;
import java.io.*;

public class VideoStream
{

final static int BUFFER_SIZE = 1024000;
public static void main(String[] args) throws Exception 
{
    Authenticator.setDefault(new Authenticator()
    {
        protected  PasswordAuthentication  getPasswordAuthentication()
        {
            System.out.println("Authenticatting...");
            PasswordAuthentication p=new PasswordAuthentication("login", "password".toCharArray());
        return p;       
        }
    });
    Socket s = new Socket();
    String host = "192.168.80.107"; //192.168.80.107
    PrintWriter s_out = null;
    BufferedReader s_in = null;
    BufferedInputStream bufferedInputStream = null;

    try
    {
        s.connect(new InetSocketAddress(host, 34599));
        System.out.println("Is connected? : " + s.isConnected());

        s_out = new PrintWriter(s.getOutputStream(), true);
        s_in = new BufferedReader(new InputStreamReader(s.getInputStream()));
        //bufferedInputStream = new BufferedInputStream(s.getInputStream());
    }
    catch(UnknownHostException e)
    {
        e.printStackTrace();
        System.exit(1);
    }
    catch(Exception e)
    {
        e.printStackTrace();
        System.exit(1);
    }

    byte[] b = new byte[BUFFER_SIZE];
    //bufferedInputStream.read(b);

    int bytesRead = 0;
    System.out.println("Reading... \n");
    while((bytesRead = s_in.read()) > 0)
    {
        System.out.println(s_in.readLine());
    }
    System.out.println("Done");
}
我尝试了不同的端口(TCP和android应用程序)。套接字与服务器连接,但当我尝试使用read()方法(即使是在while循环之外)时,它“挂起”。验证器也不起作用

有关dvr的一些信息:

  • 协议支持:TCP/IP、UDP、SMTP、NTP、DHCP、DDNS
  • 视频压缩:H.264
  • 操作系统:linux

  • 非常感谢您的建议。

    对于初学者,我建议您查看一下现有应用程序的工作原理,尝试查找发送到DVR的内容,并尝试复制它,您可能需要先发送一些命令才能打开streamingHi我尝试使用iOS上的套接字连接来执行此操作,但我不知道如何传递该套接字的用户名和密码。请尝试使用VLC()连接DVR。如果任何受支持的协议都能工作,那么尝试使用绑定V4L4J()使用Video4Linux收集流。它使用FFMPEG,因此支持许多编解码器。如果流在TCP/IP下工作,有很多获取流的例子。我将使用wireshark截获通信,查看您发送什么(如果有)和接收什么,然后从那里开始。我正在研究V4L4J项目。您知道vMEye应用程序如何使用用户名和密码连接到DVR吗?我尝试使用RTSP,但它似乎没有使用RTSP连接到DVR。