title: How to capture video in Android?
body: <p>I would like to create a video recorder and so far haven't figured out how to set parameters in order to successfully go through MediaRecorder.prepare() method.</p>
  
  <p>Executing the following method</p>
  
  <pre><code>public void start() throws IOException{
      String state = android.os.Environment.getExternalStorageState();
      if(!state.equals(Environment.MEDIA_MOUNTED))
      {
          throw new IOException("SD card is not mounted. It is " + state + ".");
      }
      File directory = new File(path).getParentFile();
      if(!directory.exists() &amp;&amp; !directory.mkdirs())
      {
          throw new IOException("Path to file could not be created.");
      }
  
      recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
      recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
      recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);
      recorder.setVideoFrameRate(15);
      recorder.setVideoSize(176, 144);
      recorder.setOutputFile(path);
      recorder.prepare();
      recorder.start();
      this.state = VideoRecorderState.STATE_RECORDING;
  }
  </code></pre>
  
  <p>it throws an exception on line <code>recorder.prepare().</code></p>
  
  <p>How to set parameters in order to be able to capture video?</p>