Android audio and video in-depth eight small video recording (with source download)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.