在 Android (MJEPG) 上获取 IP Cam 视频流 [英] Getting IP Cam video stream on Android (MJEPG)

查看:18
本文介绍了在 Android (MJEPG) 上获取 IP Cam 视频流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在 3 人小组中进行一个 AndAR 项目.我负责将视频流式传输到 Android 手机中.我给自己买了一台 D-Link DCS-920 IP 摄像头,我发现它使用 MJPEG 编解码器进行实时视频流,而网络服务器使用 Jview 来查看实时流.据我所知,Android 操作系统不支持 MJPG 文件类型,所以我想出了一个主意,我没有使用 ImageView,而是使用 WebView 来流式传输视频.我已经实现了一个非常简单的概念并且它有效!但问题是,刷新率很糟糕.我获取视频图像(例如:http://192.168.1.10/image.jpg)以在 WebView 上查看并实现一个 Timer 来控制刷新率(假设将其设置为 30fps,即每 33 毫秒刷新一次)但它只能达到 500 毫秒的间隔,我注意到任何较低的间隔都不会更平滑,有时图像不会加载并且连接不稳定(例如:掉线).这可能是我刷新的速度比它可以接收的速度快吗?但是在网络服务器 Jview 上它没有问题!试图找到 jview 的源代码,但我没有希望.无论如何这是我写的代码

I am currently doing an AndAR project in group of 3. I'm the person who's in charge of video streaming into the Android phone. I got ourselves a D-Link DCS-920 IP camera and I found out that it uses MJPEG codec for the live video stream and the webserver uses Jview to view the live stream. As far as I know MJPG is not a supported file type for Android OS so I've came out with an idea, instead of using ImageView, I use WebView to stream the video. I've implemented a very simple concept and it works! But the problem is, refresh rate is terrible. I get the video image (eg: http://192.168.1.10/image.jpg) to view on the WebView and implement a Timer to control the refresh rate (supposed to set it to 30fps, which is refresh every 33ms) but it can only go up to 500ms interval, any lower interval I notice it will not be any smoother,sometimes the image wont load and connection is unstable (eg: dropped). Could this be I'm refreshing at a rate faster than it can receive? But over on the webserver Jview it has no problem! was trying to find the source code for the jview but I have no hope. Anyway here's the code I've written

package org.example.test;

import java.util.Timer;
import java.util.TimerTask;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;

public class Webview extends Activity {

public WebView webView;
public Timer autoUpdate;
public String url;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);    

        webView = (WebView) findViewById(R.id.webview);
        webView.getSettings();
        final EditText urlText = (EditText) findViewById(R.id.urlText);

        //Buttons//////////////////------------
        final Button connectB = (Button)findViewById(R.id.connectButton);
        connectB.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
            //Actions goes here
          url = urlText.getText().toString();
          webView.loadUrl(url);
          timerSetup();
         }
        });
        final Button exitB = (Button)findViewById(R.id.exitButton);
     exitB.setOnClickListener(new View.OnClickListener() {
      public void onClick(View v) {
       //Actions goes here
       finish();
      }
     });
   }

    //refresh timer//////////////-----------------
    public void timerSetup(){
     autoUpdate = new Timer();
     autoUpdate.schedule(new TimerTask() {
      @Override
      public void run() {
       runOnUiThread(new Runnable() {
        @Override
     public void run() {
         //Actions goes here
         webView.loadUrl(url);
        }
       });
      }
     }, 0, 500);//refresh rate time interval (ms)
    }
}

无论如何我可以以至少 15fps 的速度接收视频流/具有更快的刷新率?是否有任何诸如 MJPEG 查看器/源代码之类的东西可以用来显示这些图像?

Is there anyway I can get the video stream in by at least 15fps/have a faster refresh rate? Are there any such thing as MJPEG viewer/source code that I can use to display these images?

这是应用程序的屏幕截图http://s945.photobucket.com/albums/ad295/kevinybh/?action=view&current=video.jpg(点数不够发图片):(

here's the screenshot of the app http://s945.photobucket.com/albums/ad295/kevinybh/?action=view&current=video.jpg (not enough points to post pictures) :(

我只需要制作大约 15-30fps 的视频流.任何建议/帮助将不胜感激:) 谢谢!

I just need to make the video stream around 15-30fps. any suggestions/help would be very deeply appreciated :) Thanks!

推荐答案

您可以使用 Raspberry PI 代替 Arduino,它应该有足够的 CPU 能力来控制车辆并同时转换视频流.当然,您需要将所有 Arduino 软件移植到 Raspberry ...

Instead of an Arduino you could use a Raspberry PI, it should have enough CPU power to control the vehicle and to convert the video stream at the same time. Sure, you'll need to port all of your Arduino software to Raspberry...

这篇关于在 Android (MJEPG) 上获取 IP Cam 视频流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆