Android IP Camera

1.1k views Asked by At

I'm looking for a good working solution to integrate an IP-Cameras video stream in my Android App. At the moment i am using the "Axis P1214-E" which has a good image quality, but i couldn't get a "LIVE" stream from it. Either the stream is very laggy or it's a few seconds delayed (sometimes even more) or the stream is shutting down after awhile. What i tried so far:

  • Using a SurfaceView to get the MJPEG Stream as described in this post: Android and MJPEG Problem: Lagging

  • Using a WebView to get the RTSP stream:

public class MainActivity extends Activity {

 private static final String TAG = "VideoViewExample.MainActivity";
 private static final String RTSP_URL = "rtsp://ip/axis-media/media.amp"; 
 
 
 private VideoView videoView;
 private MediaController mediaController;

 private OnPreparedListener opl;

 private int position = 0;

 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        if(savedInstanceState != null)
            position = savedInstanceState.getInt("POSITION");
        
        
        videoView = (VideoView) findViewById(R.id.videoView);        
      
        
        opl = new OnPreparedListener() {
   
   @Override
   public void onPrepared(MediaPlayer mp) {
        
    videoView.seekTo(position);
    
    if (position == 0) {
     videoView.start();
    }
    else {
     
     videoView.pause();
    }    
   }
  };
        
        if (mediaController == null){
         mediaController = new MediaController(this);
        }
        
        mediaController.setAnchorView(videoView);
        
        AsyncTask<Void, Void, Void> at = new AsyncTask<Void, Void, Void>() {

   @Override
   protected Void doInBackground(Void... params) {
    try{
           videoView.setMediaController(mediaController);              
              videoView.setVideoURI(Uri.parse(RTSP_URL));
          } catch (Exception e) {
           Log.d(TAG, e.getMessage());
          }
                  
          videoView.requestFocus();
          videoView.setOnPreparedListener(opl);          
          
    return null;
   }
         
  };
        at.execute();
         
    }
    
    @Override
    protected void onPause() {
        position = videoView.getCurrentPosition();
        super.onPause();
    }
    
    @Override
    public void onSaveInstanceState(Bundle outState) {
     
     super.onSaveInstanceState(outState);
     outState.putInt("POSITION", position);      
        
    }

}
Problem: Good video Quality, but delayed.

  • Using external frameworks like FFMPEG and GSTREAMER (Only some examples so far) Problem: Also very laggy and/or delayed.

Now i'm running out of ideas to get this working. It's very important for my Application that the stream is live and not lagging. I'm developing on a "Banana Pi" board with Android 4.2.2 (4.4 is possible as well).

Does anybody know how to get this working? Or maybe should i use an other camera? Do you have any suggestions that would work well with android?

Thanks in advance

Christian

0

There are 0 answers