Closed fahime-ghasemi closed 5 years ago
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/ /*
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];
}
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!
I added a fragment to sample app that has an ExoPlayer to play video that is recorded. At the end of stopRecordingVideo method, I passed the mNextVideoAbsolutePath variable to a new fragment to play it in exoplayer. but I got the following error.
2018-11-05 18:22:55.538 6128-6830/com.example.android.camera2video E/LoadTask: Unexpected exception loading stream java.lang.IllegalStateException: Top bit not zero: -696383949 at com.google.android.exoplayer2.util.ParsableByteArray.readUnsignedIntToInt(ParsableByteArray.java:389) at com.google.android.exoplayer2.extractor.mp4.AtomParsers.parseStbl(AtomParsers.java:174) at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.getTrackSampleTables(Mp4Extractor.java:455) at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.processMoovAtom(Mp4Extractor.java:390) at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.processAtomEnded(Mp4Extractor.java:358) at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.readAtomPayload(Mp4Extractor.java:349) at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.read(Mp4Extractor.java:180) at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:898) at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:379) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:762)
2018-11-05 18:22:58.550 6128-6829/com.example.android.camera2video E/ExoPlayerImplInternal: Source error. java.io.EOFException at com.google.android.exoplayer2.extractor.DefaultExtractorInput.readFromDataSource(DefaultExtractorInput.java:265) at com.google.android.exoplayer2.extractor.DefaultExtractorInput.readFully(DefaultExtractorInput.java:72) at com.google.android.exoplayer2.extractor.DefaultExtractorInput.readFully(DefaultExtractorInput.java:81) at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.readAtomPayload(Mp4Extractor.java:334) at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.read(Mp4Extractor.java:180) at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:898) at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:379) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:762)