android - Preview resolution doesn't match codec resolution -


i'm trying stream video between devices. want support old devices possible. started mediarecorder class on gingerbread (api 10), had issues. now, i'm moving jelly bean (api 16) , mediacodec.

i'm feeding data codec in camera's previewcallback. have use same resolution preview, , codec. on of our testing devices, there no intersection between preview resolutions , codecs , resolutions.

so, how capture video on devices? know there createinputsurface in mediacodec, needs api 18, , i'll have cut away over 35 % of devices, inacceptable.

so how solve it?

code finding best possible resolution:

camcorderprofile bestprofile() {     final int[] profiles;     if (build.version.sdk_int >= build.version_codes.lollipop) {         profiles = new int[]{camcorderprofile.quality_high, camcorderprofile.quality_2160p, camcorderprofile.quality_1080p, camcorderprofile.quality_720p, camcorderprofile.quality_480p, camcorderprofile.quality_cif, camcorderprofile.quality_qcif, camcorderprofile.quality_low};     } else if (build.version.sdk_int >= build.version_codes.honeycomb) {         profiles = new int[]{camcorderprofile.quality_high, camcorderprofile.quality_1080p, camcorderprofile.quality_720p, camcorderprofile.quality_480p, camcorderprofile.quality_cif, camcorderprofile.quality_qcif, camcorderprofile.quality_low};     } else {         profiles = new int[]{camcorderprofile.quality_high, camcorderprofile.quality_low};     }     (final int p : profiles) {         try {             final camcorderprofile profile = camcorderprofile.get(p);             string encoder = encoderdebugger.debug(this, profile.videoframewidth, profile.videoframeheight).getencodername();             log.d(string.valueof(profile.videoframewidth + "*" + profile.videoframeheight), encoder);             return profile;         } catch (final runtimeexception re) {             log.e("profile", re.getlocalizedmessage());         }     }     return null; } 

encoderdebugger

btw, quality_cif (352×288) works on devices.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -