简体   繁体   中英

Android: How to record video using android.hardware.camera2 and MediaRecorder

I want to make video recording using android.hardware.camera2 . I have googled but not get any proper tutorial regarding this. There are some tutorial available for camera preview base on Camera which is now deprecated. Can anyone help me with latest sample code just for recording video with its preview which can be saved into sd card . I have just check GitHub and Google camera2Video example also but I need any simple solution which I can integrated into my project.

Look at this open-source project

WesleyElliott/Camera2-Video

There is working code, instead of sample by google

just for recording video with its preview which can be saved into sd card

If thats all you want you can simply use:

static final int REQUEST_VIDEO_CAPTURE = 1;

Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
     startActivityForResult(takeVideoIntent, REQUEST_VIDEO_CAPTURE);
}

Source


If you want to implement that yourself with the help of camera2. I would suggest to have a look at the sourcecode of googlesamples/android-Camera2Basic

Espacially at Camera2BasicFragment.java

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM