Video Capture

In previous chapters, we have covered image capture and audio capture. Now we'll turn our attention to video capture. In this chapter, we'll explore capturing video using Android's built-in Camera application via an intent. We'll look at the formats and codecs that Android supports for video capture, and finally we'll build a custom video capture application.

It is becoming cliché, but as previously discussed, often the quickest and easiest way to perform some function on Android is to leverage an existing application that can be triggered by an intent from our application. Using the built-in Camera application to record video, triggered by an intent, is no exception.

Within the android.provider.MediaStore class is a constant named ACTION_VIDEO_CAPTURE, which contains the string " VIDEO_CAPTURE". This string is registered by the Camera application as an intent filter and will therefore be activated by an intent sent via the Content.startActivity or Context.startActivityForResult methods. Other applications may also register the same string, which would result in the user being prompted to choose which application he or she would like to use to perform the action.

Intent captureVideoIntent = new Intent(android.provider.MediaStore.^ ACTION_VIDEO_CAPTURE);

startActivityForResult(captureVideoIntent, VIDEO_CAPTURED);

VIDEO_CAPTURED is a constant that should be defined as a class variable and is used to recognize when the Camera application returns a result to our activity via a call to our onActivityResult method:

public static int VIDEO_CAPTURED = 1;

The intent that is passed back to our activity in the onActivityResult method (data in the following code example) contains a Uri to the video file that was created by the Camera application.

+1 0


  • Donna
    How to record video using MediaStore.ACTION_VIDEO_CAPTURE in android?
    7 years ago

Post a comment