title: Android - Choosing between MediaRecorder, MediaCodec and Ffmpeg
body: <p>I am working on a video recording and sharing application for Android. The specifications of the app are as follows:-</p>
  
  <ul>
  <li>Recording a 10 second (maximum) video from inside the app (not using the device's camera app)</li>
  <li>No further editing on the video </li>
  <li>Storing the video in a Firebase Cloud Storage (GCS) bucket</li>
  <li>Downloading and playing of the said video by other users</li>
  </ul>
  
  <p>From the research, I did on SO and others sources for this, I have found the following (<strong>please correct me if I am wrong</strong>):-</p>
  
  <p>The three options and their respective features are:-</p>
  
  <p>1.<strong>Ffmpeg</strong></p>
  
  <ul>
  <li>Capable of achieving the above goal and has extensive answers and explanations on sites like SO, however </li>
  <li>Increases the APK size by 20-30mb (large library)</li>
  <li>Runs the risk of not working properly on certain 64-bit devices</li>
  </ul>
  
  <p>2.<strong>MediaRecorder</strong></p>
  
  <ul>
  <li>Reliable and supported by most devices</li>
  <li>Will store files in .mp4 format (unless converted to h264)</li>
  <li>Easier for playback (no decoding needed) </li>
  <li>Adds the mp4 and 3gp headers</li>
  <li>Increases latency according to <a href="https://stackoverflow.com/questions/13397863/use-mediacodec-for-h264-streaming">this question</a></li>
  </ul>
  
  <p>3.<strong>MediaCodec</strong></p>
  
  <ul>
  <li>Low level</li>
  <li>Will require MediaCodec, MediaMuxer, and MediaExtractor </li>
  <li>Output in h264 ( without using MediaMuxer for playback ) </li>
  <li>Good for video manipulations (though, not required in my use case)</li>
  <li>Not supported by pre 4.3 (API 18) devices</li>
  <li>More difficult to implement and code (my opinion - please correct me if I am wrong)</li>
  <li>Unavailability of extensive information, tutorials, answers or samples (Bigflake.com being the only exception)</li>
  </ul>
  
  <p>After spending days on this, I still can't figure out which approach suits my particular use case. Please elaborate on what I should do for my application. If there's a completely different approach, then I am open to that as well. </p>
  
  <p>My biggest criteria are that the video encoding process be as efficient as possible and the video to be stored in the cloud should have the lowest possible space usage without compromising on the video quality. </p>
  
  <p>Also, I'd be grateful if you could suggest the appropriate format for saving and distributing the video in Firebase Storage, and point me to tutorials or samples of your suggested approach.</p>
  
  <p>Thank you in advance! And sorry for the long read.</p>