Receiving video stream from an IP camera on android

我是研究僧i 提交于 2020-01-12 05:21:20

问题


I have an IP camera which is streaming video in MJPEG format. Now my aim is to receive it and display it in my own custom android app. For this I have three programming alternatives on android platform :

  1. Using inbuilt Anrdroid MediaPlayer class
  2. Using FFMPEG library in native C and accessing it through JNI
  3. Using GStreamer port on android to receive the stream

So please suggest a better solution?

I have no experience with FFMPEG or GStreamer. So what is the feasibility of doing this?


回答1:


Use gstreamer for it.

I have used gstreamer at beagleboard which has 1GHz processor for taking image from 2 cameras in 30 fps with very low CPU processing power.

Gstreamer able to merge images, add strings, change formats. And presents you what you want easily in stream. The only thing you need to do is adding black boxes each other.

You can add blackboxes with both dynamically and statically.

If you are not going to change your stream depends on input at your program I suggest to use static one. But I am not sure if it works at android..




回答2:


To test 3rd option (gstreamer) you can use this app: https://play.google.com/store/apps/details?id=pl.effisoft.rpicamviewer2. You can also open gstreamer preview from your code using following code:

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);


来源:https://stackoverflow.com/questions/10685625/receiving-video-stream-from-an-ip-camera-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!