How can I capture a video recording on Android?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Here is a simple video recording example using the MediaRecorder:
It's from my book: Pro Android Media: Developing Graphics, Music, Video, and Rich Media Apps for Smartphones and Tablets
Also, do not forget to include these permissions in manifest:
The above example will work if you are using rear camera. If you are using front camera, you will have to adjust some things:
First off, you will need to add new permission in the manifest.
<uses-feature android:name="android.hardware.camera.front" android:required="false" />
In your
initRecorder
method, instead ofYou need to use:
because
CamcorderProfile.QUALITY_HIGH
is reserved for the rear camera.You will also have to set the video size for mediarecorder as it is in your surface view.
Here is the full example of recording video from front camera with a small preview display:
Android.manifest
activity_camera.xml
CameraActivity.java
This demo will helpful for you....
video.xml
Your Main Activity: Video.java
MediaMetadataRetriever Class
You record audio and video using the same MediaRecorder class. It's pretty simple. Here's an example.
For the benefit of searchers, this example will give you an active preview, with a start/stop button for recording. It was modified from this android blog and seems fairly reliable.
java class (VideoWithSurfaceVw)
activity (activity_video_with_surface_vw)
Here is another example which is working
camera_surface.xml
And of course include these permission in manifest: