title: How To: Android OpenCV VideoCapture with File
body: <p>I am trying to pass a video to the OpenCV VideoCapture class. However when I call the <code>VideoCapture.isOpened()</code> method it always returns <code>false</code>. I have tried two methods: </p>
  
  <ol>
  <li><p>Saving the video file to the internal memory, <code>context.getFilesDir()</code> => /data/data/package_name/files/VideoToAnalyze/Recording.mp4</p></li>
  <li><p>and also one to <code>environment.getExternalStorageDirectory()</code> => sdcard/appName/Recording.mp4. </p></li>
  </ol>
  
  <p>Nothing seems to work here. My question is how do I pass a video file (or what is the correct file path) to a VideoCapture OpenCV object? I've posted some code below as an example. Note that I don't get an error. The file is always found/exists, but when I call <code>isOpened()</code> I always get <code>false</code>.</p>
  
  <p>UPDATE:
  So it looks like everyone on the web is saying that OpenCV (I'm using 3.10) is lacking a ffmpeg backend and thus cannot process videos. I'm wondering does anyone know this as a fact ?? And is there a work around. Almost all other alternatives to process videos frame by frame is deathly slow.</p>
  
  <pre><code>String x = getApplicationContext().getFilesDir().getAbsolutePath();
  File dir = new File(x + "/VideoToAnalyze");
  if(dir.isDirectory()) {
         videoFile = new File(dir.getAbsolutePath() + "/Recording1.mp4");
  } else {
        // handle error
  }
  
  if(videoFile.exits(){
  
       String absPath = videoFile.getAbsolutePath();
       VideoCapture vc = new VideoCapture();
       try{
             vc.open(absPath);
       } catch (Exception e) {
         /// handle error
       }
  
       if(!vc.isOpened(){
           // this code is always hit
           Log.v("VideoCapture", "failed");
       } else {
           Log.v("VideoCapture", "opened");
  
  
      .....
  </code></pre>