【问题标题】:Receiving video stream from an IP camera on android从 android 上的 IP 摄像头接收视频流
【发布时间】:2012-05-21 12:52:19
【问题描述】:

我有一个 IP 摄像机,它以 MJPEG 格式传输视频。现在我的目标是接收它并将其显示在我自己的自定义 android 应用程序中。为此,我在 android 平台上有三种编程选择:

  1. 使用内置的 Anrdroid MediaPlayer 类
  2. 在原生 C 中使用 FFMPEG 库并通过 JNI 访问它
  3. 在android上使用GStreamer端口接收流

所以请提出一个更好的解决方案?

我没有使用 FFMPEG 或 GS​​treamer 的经验。那么这样做有什么可行性呢?

【问题讨论】:

  • 添加一些细节,我想在三星 Galaxy Tab 10.1(运行 android 3.2 蜂窝)上接收流,并且 IP 摄像机正在流式传输 RTSP 视频(MPEG-4 中的 TCP over UDP) URL 和指定的端口号。现在建议从列表中选择一个选项...
  • 为了更新进度,我尝试了带有指定格式 URL 的选项 1(使用 MediaPlayer)来流式传输 RTSP。但它会崩溃并抛出 IOException “准备失败。:状态 = 0x1”。有什么想法吗??
  • 为了验证是否支持特定的流,我检查了 android 网站,我还安装了一些 android 应用程序,如 VPlayer 和 IPCamViewer 来检查流。他们可以毫无问题地玩它。这意味着支持视频格式,那么问题出在哪里?
  • 我遇到了类似的情况,如果您能够解决,请告诉我解决方案。完美的解决方案是仅使用 Gstreamer,但我一直在构建和编译 Gstreamer。
  • 我发现了以下 [关于流式 MJPEG 的主题][1] [1]:stackoverflow.com/questions/3205191/android-and-mjpeg/… 看看这是否对您有帮助。

标签: android ffmpeg android-mediaplayer gstreamer ip-camera


【解决方案1】:

使用gstreamer

我在 beagleboard 上使用过 gstreamer,它具有 1GHz 处理器,可以以 30 fps 的速度从 2 个摄像头拍摄图像,而 CPU 处理能力非常低。

Gstreamer 能够合并图像、添加字符串、更改格式。并在流中轻松呈现您想要的内容。您唯一需要做的就是互相添加black boxes

您可以动态和静态地添加黑盒。

如果您不打算更改流取决于程序中的输入,我建议使用static one。但我不确定它是否适用于android..

【讨论】:

    【解决方案2】:

    要测试第三个选项 (gstreamer),您可以使用此应用程序:https://play.google.com/store/apps/details?id=pl.effisoft.rpicamviewer2。您还可以使用以下代码从您的代码中打开 gstreamer 预览:

    Intent intent = new Intent("pl.effisoft.rpicamviewer2.PREVIEW");
    int camera =0;
    
    //--------- Basic settings
    intent.putExtra("full_screen", true);
    
    intent.putExtra("name"+camera, "My pipeline name");
    intent.putExtra("host"+camera, "192.168.0.1");
    intent.putExtra("port"+camera, 5000);
    intent.putExtra("description"+camera, "My pipeline description");
    intent.putExtra("uuid"+camera, UUID.randomUUID().toString() );
    intent.putExtra("aspectRatio"+camera, 1.6);
    intent.putExtra("autoplay"+camera, true);
    
    //--------- Enable advanced mode
    intent.putExtra("advanced"+camera, true);   //when advanced=true, then     custom_pipeline will be played
                                            //when advanced=false, then pipeline will be generated from host, port (use only for backward compatibility with previous versions)
    intent.putExtra("custom_pipeline"+camera, "videotestsrc ! warptv ! autovideosink");
    
    //--------- Enable application extra features
    intent.putExtra("extraFeaturesEnabled"+camera, false);
    
    //--------- Add autoaudiosink to featured pipeline
    intent.putExtra("extraFeaturesSoundEnabled"+camera, false);
    
    //--------- Scale Video Stream option
    intent.putExtra("extraResizeVideoEnabled"+camera, false);
    intent.putExtra("width"+camera, 320);       //used only when extraResizeVideoEnabled=true
    intent.putExtra("height"+camera, 200);      //used only when extraResizeVideoEnabled=true
    
    //--------- Add plugins
    ArrayList<String> plugins = new ArrayList<String>();
    intent.putExtra("plugins"+camera, plugins);
    
    intent.setPackage("pl.effisoft.rpicamviewer2");
    startActivityForResult(intent, 0);
    

    【讨论】:

      猜你喜欢
      • 2015-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-22
      相关资源
      最近更新 更多