Address of this project, request start
Https://github.com/979451341/Audio-and-video-learning-materials/tree/master/%E5%B0%8F%E8%A7%86%E9%A2%91%E5%BD%95%E5%88%B6
This project I feel bad, because before the screen with a lot of code, and this really realize the video screen function of the Code 100 lines are not
There is also about the entire interface UI is doing well, but about how the interface is implemented I will not say, directly say how to implement the code of the video screen
First, the camera how to give data Surfaceview, so that the screen display camera shot of things, this before said much, not mention
1. Recording screen
This time how to give the video data to Mediarecorder, two lines will be
Mmediarecorder.setcamera (Mcamera);
Mmediarecorder.setpreviewdisplay (Msurfaceholder.getsurface ());
Setting audio and video formats for two data sources
Mmediarecorder.setvideosource (MediaRecorder.VideoSource.CAMERA);
Mmediarecorder.setaudiosource (MediaRecorder.AudioSource.MIC);
Set the resolution to show the size of the screen
Set the resolution of the video
Mmediarecorder.setvideosize (Mprofile.videoframewidth, mprofile.videoframeheight);
Set the rate of encoding
Mmediarecorder.setaudioencodingbitrate (44100);
if (Mprofile.videobitrate > 2 1024x768 1024) {
Mmediarecorder.setvideoencodingbitrate (2 1024x768 1024);
} else {
Mmediarecorder.setvideoencodingbitrate (mprofile.videobitrate);
}
Set the frame rate for video playback
Mmediarecorder.setvideoframerate (mprofile.videoframerate);
This is the format of the audio and video encoding
Mmediarecorder.setaudioencoder (MediaRecorder.AudioEncoder.AAC);
Mmediarecorder.setvideoencoder (MediaRecorder.VideoEncoder.H264);
Set the path to the output file
Mmediarecorder.setoutputfile (Mrecordfile.getabsolutepath ());
The flaw in this project is that it is not possible to add special effects while recording a screen, but the code is short and suitable for a specific purpose.
Android audio and video in-depth eight small video recording (with source download)