Comments (2)
I've also faced this issue, I resolved this by maximum resolution of media recorder is 1080x720p, please maintain this ratio for recording, here is the method I customized for my requirement, hope it will help you.
/To maintain the aspect ratio 16:9 for record video/
/*
* In this sample, we choose a video size with 3x4 aspect ratio. Also, we don't use sizes
* larger than 1080p, since MediaRecorder cannot handle such a high-resolution video.
*
*
* In this method used for recording video in Landsacpe(WxH)=1080x720,Portrait(WxH)=720x1080.
*
* @param choices The list of available sizes
* @return The video size
*/
private Size chooseVideoSize(Size[] choices) {
for (Size size : choices) {
int orientation = getActivityContext.getResources().getConfiguration().orientation;
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
//if((size.getWidth()/16) == (size.getHeight()/9) && size.getWidth() <=720) {
if((size.getWidth()/16) == (size.getHeight()/9) && size.getWidth() <=3840 ) {
Log.e(TAG1, "chooseVideoSize:"+size);
return size;
}
} else {
if((size.getWidth()/16) == (size.getHeight()/9) && (size.getWidth() <=3840) ) {
//if((size.getWidth()/16) == (size.getHeight()/9) && size.getWidth() <=4480 ) {
Log.e(TAG1, "chooseVideoSize:"+size);
return size;
}else if((size.getHeight()/18) == (size.getWidth()/9) && ((size.getWidth() <=3840)||(size.getHeight()<=2160))) {
//if((size.getWidth()/16) == (size.getHeight()/9) && size.getWidth() <=4480 ) {
Log.e(TAG1, "chooseVideoSize:"+size);
return size;
}else if((size.getWidth()/19) == (size.getHeight()/9) && ((size.getWidth() <=3840)||(size.getHeight()<=2160))) {
Log.e(TAG1, "chooseOptimalSize:"+size+"-19:9");
return size;
}else if((size.getWidth()/19.5) == (size.getHeight()/9) && ((size.getWidth() <=3840)||(size.getHeight()<=2160))) {
Log.e(TAG1, "chooseOptimalSize:"+size+"-19.5:9");
return size;
}
}
}
// Log.e(TAG1, "chooseVideoSize:Couldn't find any suitable video size");
return choices[choices.length - 1];
}
from android-camera2video.
This sample has been migrated to a new location (check README for more information).
As recommended by GitHub, we are closing all issues and pull requests now that this older repo will be archived.
If you still see this issue in the updated repo, please reopen the issue/PR there. Thank you!
from android-camera2video.
Related Issues (20)
- Target Version Android Q Preview HOT 1
- Lock screen,unLock screen HOT 3
- setVideoFrameRate not work for me HOT 2
- NPE on StartPreview after stopRecording HOT 1
- Crash after stopping recording HOT 3
- Is there an alternate for setting video orientation of the output file? HOT 1
- update openCV
- How to add timestamp on each frame? HOT 1
- MediaRecorder and VideoSource.SURFACE, stop failed: -1007 HOT 2
- Changing Resolution to 4K
- Heating during capture HOT 1
- Video not playing on 7.0 and above HOT 6
- Video Pause/Resume... HOT 2
- the recorded video has a problem, it shows a screenshot that takes a time equal to whole of the video HOT 5
- Where is the video file getting stored? HOT 3
- Unable to set custom FPS HOT 1
- Why the videos i record always are horizontal HOT 1
- Camera freezes after unlocking the phone after a few minutes. HOT 1
- Rear camera showing solid green color, front camera is fine. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-camera2video.