内容简介:应用程序,我在其中放置有关服务器,端口,用户名和密码的信息(我可以使用服务器软件添加帐户).该应用程序从相机流式传输视频我也可以通过http(只有IE)与dvr连接,然后显示activeX应用程序.我要做的是编写类似的应用程序,但我遇到了一个问题 – 如何从dvr获取视频流?我不是Java专家,尝试连接dvr,但没有成功.这是我的代码:
我的系统由一台数字视频录像机(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
我会非常感谢任何建议.
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- Netty-解码器架构与常用解码器
- Glide 缓存与解码复用
- 音频解码 Audio Converter
- golang之Json编码解码
- 解码器 与 编码器
- WeIdentity 源码分析 | 狗哥解码(一)
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
The Book of CSS3
Peter Gasston / No Starch Press / 2011-5-13 / USD 34.95
CSS3 is the technology behind most of the eye-catching visuals on the Web today, but the official documentation can be dry and hard to follow. Luckily, The Book of CSS3 distills the heady technical la......一起来看看 《The Book of CSS3》 这本书的介绍吧!