10

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?

Mycoola
  • 1,135
  • 1
  • 8
  • 29
Bhanu Kiran
  • 645
  • 1
  • 8
  • 14
  • To add few details, I want to receive the stream on Samsung Galaxy Tab 10.1 (running android 3.2 honeycomb) and the IP Camera is streaming RTSP video (TCP over UDP in MPEG-4) with a particular URL and on a speicified port no. Now do suggest an option from the list ... – Bhanu Kiran May 23 '12 at 06:16
  • To update the progress, I have tried the option 1 (using MediaPlayer) with URL in the specified format to stream the RTSP. But it crashes throwing an IOException "Prepare failed.: status=0x1". Any ideas on that ?? – Bhanu Kiran May 23 '12 at 06:53
  • To verify if the particular stream is supported or not, I have checked the android website and I have also installed a few android apps like VPlayer and IPCamViewer to check the stream. They are able to play it without any problem. That means the video format is supported, so where else could the problem lie ? – Bhanu Kiran May 23 '12 at 07:20
  • I'm stuck in a similar situation, can you please let me know the solution, if you were able to fix it. Perfect solution is to use Gstreamer only but I'm stuck in building and compiling Gstreamer. – abhy Jul 25 '12 at 08:25
  • @abhy , do you have the GStreamer code to do the same ? I have explored that option too, could build the library from the [these](http://gstreamer.freedesktop.org/wiki/GstreamerAndroid_InstallInstructions) instructions. But couldn't get the code working.... if u have it share it with me and I could validate this alternative. Otherwise both of us are wasting our time .... – Bhanu Kiran Jul 26 '12 at 08:56
  • Hey! Thanks for replying. I'm working on that Androgenizer link only that you specified above. BTW, this is what you are looking for: http://gstreamer.freedesktop.org/modules/gst-android.html Also, I'm not able to get how to connect things with Androgenizer. If I follow the Androgenizer instructions do you think we need to write JNI classes of our own or it will be built automatically. For your reference I also found VLC code http://wiki.videolan.org/AndroidCompile , don't know whether it will be helpful or not. – abhy Jul 27 '12 at 09:54
  • @ajeetvijayvergiya ... yes your help is very much appreciated .. could you post a working copy of the code .. this has a been a worry since very long !!! – Bhanu Kiran Oct 29 '12 at 06:34
  • 1
    I found the following [topic on streaming MJPEG][1] [1]: http://stackoverflow.com/questions/3205191/android-and-mjpeg/3305276#3305276 See if this helps you. – Chris Margonis Apr 13 '13 at 06:22
  • Did u try loading the url in webview ? if so u can integrate a simple webview to stream the video. – Emel Elias Aug 18 '14 at 12:26
  • Use this http://stackoverflow.com/questions/3205191/android-and-mjpeg it might be help you – Vaishali Sutariya Aug 22 '14 at 09:14
  • @abhy, I got it working under C++. If you want I can share the code. – Bhanu Kiran Sep 22 '14 at 06:17
  • @BhanuChalla Hey! Great to know you made it. It will be great if you share the code or you can put it up in pastebin or if it's huge you can put it up on git. Not required now though at my side but may be it will be of help to someone else or maybe to me in future. I appreciate you take care of old threads. Thanks. – abhy Sep 30 '14 at 07:16
  • @abhy, sure will do it. Thank you. – Bhanu Kiran Sep 30 '14 at 10:25

2 Answers2

2

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..

ibrahim demir
  • 421
  • 3
  • 16
1

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);
zuko
  • 664
  • 1
  • 8
  • 16