Camera2 app based on mediarecorder records videos of low quality. Does anybody know why?

290 Views Asked by At

I have been developing a camera app using camera 2 and taking codes from these video series: https://www.youtube.com/watch?v=69J2ycNCtpE&lc=z23lu3jo4xuwzjataacdp43bf4ywaag5x2tpbiljkf1w03c010c I had to update the codes with the run time permissions.

The video quality I obtain is terrible and I do not know why. I tried playing with the output format, the video encoder, the bitrate (according to what I found on other answers) but the quality does not change and it is much worse when compared to the original camera application. When comparing two similar videos with the same length, the resolutions are the same (1080x1920) but the video size resulting from this app is 0.95 MB while the one of the video taken with the original camera app is 12 MB. Clearly, there is something not working, but I do not know what. PS: this phenomenon does not seem to happen to the tutorial guy when he tries the app on his phone. Any help will be much appreciated!

2

There are 2 best solutions below

1
On BEST ANSWER

If you try the official video recording sample, Camera2Video, does it also record poor video?

If so, there's likely a device bug that causes it to ignore the configured video quality. If Camera2Video works OK, then see what it does differently from your own app.

0
On

I recommend you see this sample https://github.com/googlesamples/android-Camera2Basic

Maybe with this configuration could resolve

// For still image captures, we use the largest available size.
            Size largest = Collections.max(
                    Arrays.asList(map.getOutputSizes(ImageFormat.JPEG)),
                    new CompareSizesByArea());
            mImageReader = ImageReader.newInstance(largest.getWidth(), largest.getHeight(),
                    ImageFormat.JPEG, /*maxImages*/2);
            mImageReader.setOnImageAvailableListener(
                    mOnImageAvailableListener, mBackgroundHandler);