title: Getting current frame from android vlc media player
body: <p>I'm using <a href="https://code.videolan.org/videolan/vlc-android" rel="nofollow noreferrer">VLC-Android</a> in order to play H264 RTSP live stream in my android application, the following code successfully renders the stream video onto the surface view:</p>
  
  <pre><code>MediaPlayer mMediaPlayer = new MediaPlayer(VLCInstance.get());
  SurfaceView mSurfaceView = (SurfaceView) findViewById(R.id.player);
  
  final IVLCVout vlcVout = Constants.mMediaPlayer.getVLCVout();
  vlcVout.detachViews();
  vlcVout.setVideoView(mSurfaceView);
  vlcVout.setWindowSize(mSurfaceDims.getWidth(), mSurfaceDims.getHeight());
  vlcVout.attachViews();
  mSurfaceView.setKeepScreenOn(true);
  
  Media media = new Media(VLCInstance.get(), Uri.parse(path));
  mMediaPlayer.setMedia(media);
  mMediaPlayer.play();
  </code></pre>
  
  <p><strong>VLCInstance.java:</strong></p>
  
  <pre><code>package bi.anpr.vlc;
  
  import android.content.Context;
  import android.util.Log;
  
  import org.videolan.libvlc.LibVLC;
  import org.videolan.libvlc.util.VLCUtil;
  
  public class VLCInstance {
      public final static String TAG = "VLC/Util/VLCInstance";
  
      private static LibVLC sLibVLC = null;
  
      /** A set of utility functions for the VLC application */
      public synchronized static LibVLC get() throws IllegalStateException {
          if (sLibVLC == null) {
              final Context context = VLCApplication.getAppContext();
              if(!VLCUtil.hasCompatibleCPU(context)) {
                  Log.e(TAG, VLCUtil.getErrorMsg());
                  throw new IllegalStateException("LibVLC initialisation failed: " + VLCUtil.getErrorMsg());
              }
  
              try{
                  sLibVLC = new LibVLC(context);
              }catch (Throwable e){
                  e.printStackTrace();
              }
  
          }
          return sLibVLC;
      }
  
      public static synchronized void restart(Context context) throws IllegalStateException {
          if (sLibVLC != null) {
              sLibVLC.release();
              sLibVLC = new LibVLC(context);
          }
      }
  }
  </code></pre>
  
  <p>The problem is that the <code>org.videolan.libvlc.MediaPlayer</code> renders the video on the SurfaceView after calling play() without any event that helps you to grab the current frame on the view, where i need to get the current frame each interval of time to perform some image processing on it. </p>
  
  <p><strong>So is it possible using <code>vlc-android-sdk</code> to grab current frame, into a buffered image or an <code>OpenCV Mat</code>, while playing live streams or local video resources?</strong></p>
  
  <p>Note that it is possible with java (desktop vlcj) through the <strong>DirectMediaPlayer</strong> class. </p>
  
  <p>Thanks in advance!!</p>