在安卓设备上接收来自IP摄像机的视频流

10

我有一台以MJPEG格式流式传输视频的IP摄像头。现在我想接收它并在自己的自定义Android应用程序中显示它。对此,我在Android平台上有三种编程选择:

  1. 使用内置的Anrdroid MediaPlayer类
  2. 使用本机C中的FFMPEG库并通过JNI访问它
  3. 使用Android上的GStreamer端口来接收流

所以,请建议一个更好的解决方案?

我没有使用FFMPEG或GStreamer的经验。那么实现这个的可行性如何?


1
我在流式传输MJPEG主题上找到了以下内容。看看这是否对你有帮助。 - Chris Margonis
使用这个链接 https://dev59.com/fHA75IYBdhLWcg3wm6Uj 可能会对你有所帮助。 - Vaishali Sutariya
@abhy,我已经在C++下让它工作了。如果你想的话,我可以分享代码。 - Bhanu Kiran
@BhanuChalla 嘿!很高兴知道你做到了。如果你能分享代码或者把它放在pastebin上,那就太好了。如果代码很大,你也可以把它放在git上。虽然现在我这边不需要,但是也许对其他人或者将来的我有帮助。感谢你关注旧的线程。谢谢。 - abhy
@abhy,好的,我会做的。谢谢。 - Bhanu Kiran
显示剩余8条评论
2个回答

2

使用gstreamer实现。

我曾经在拥有1GHz处理器的Beagleboard上使用gstreamer,以非常低的CPU处理能力,以30fps从2个摄像头拍摄图像。

Gstreamer可以合并图像、添加字符串、更改格式,并在流中轻松呈现您想要的内容。唯一需要做的就是将黑盒子彼此添加。

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

如果您的程序不会根据输入改变流,请使用静态方式。但我不确定它是否适用于Android..


1

要测试第三个选项(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);

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接