Closed ghost closed 6 years ago
If work on 640x480 could be for multiple reason but normally:
You are not selecting a correct resolution for camera. You have getResolutionsBack() and getResolutionsFront() to know your cameras resolutions supported.
You are selecting a width or height that is not multiple of 16 that in some devices could crash but the normal result is a bad image (360 / 16 = 22.5). This normally is a error in MediaTek encoders.
But I don't understand why crash in AudioEncoder... Can you tell me device model and Android API?
You are right !!!
List
tmpList = camera.getParameters().getSupportedVideoSizes(); width = tmpList.get(5).width; height = tmpList.get(5).height;
i use this code to get width and hieght for each device(Sony SO-02G android 5, Sony SO-01H android 6, NEXUS 6 android 8). but review screen stretched
List<Camera.Size> tmpList = camera.getParameters().getSupportedVideoSizes();
Is not correct. You should use:
List<Camera.Size> tmpList = camera.getParameters().getSupportedPreviewSizes();
Because you are streaming from preview. For preview stretched the solution is set to your view same aspect ratio than your stream resolution. Example:
With stream resolution 640x480:
640 / 480 = 1.33333.
So you should select 1.3333 pixel of width each 1 pixel of height
Valid resolution example: 1333.33x1000
Where 1333.33 is 1000(random height) * 1.33333
640x360:
640 / 360 = 1.77778
Valid resolution example: 1280x720
i see, thanks
(1) But when i start with stream resolution 640x360 and preview resolution 1280x720(or w / h = 1.77778), server got:
(2) if stream and preview are same resolution, it will work fine, but hight resolution is stream too slow (good in 640x360 or 640x480), if preview resolution set 640x360 or 640x480, app can crash
ps: i dont know (1) is error of server or app
ah, when i use NEXUS 6 android 8, stream and preview are reverse, it will normal if rotation set 270(portraint), 180(landscape), but if do this others device will reverse >_<
No. When I said set your view same aspect ratio is set layout params to your view not use startPreview method of my library. Anyway you can use AutoFitTextureView class instance of SurfaceView or other option and this will resize preview for you. I think image error is because 360 is not multiple of 16 and that get a error in rotation methods. You can check it if you set rotation to 0 you should get a normal image. Nexus 6 error could be a hardware problem (I'm not sure but normally all device should see fine with 90 orientation in portrait and 0 in landscape for back camera and rotate it 180 for front camera) correct like in Nexus 5X that have camera with wrong orientation.
I don't know what happen, but still work in 640x480 >_<