Unity-Technologies / com.unity.webrtc

WebRTC package for Unity
Other
738 stars 185 forks source link

[REQUEST]: Mediacodec support more aspect ratios other than 1:1. #984

Closed avicarpio closed 8 months ago

avicarpio commented 9 months ago

Is your feature request related to a problem?

At the moment only 1:1 aspect ratio is supported for Mediacodec (Android), so if I try to send any other resolution that is 16:9, 4:3, etc. the WebRTC plugin crashes with the error:

2023/09/26 15:58:17.984 1809 2990 Error org.webrtc.Logging HardwareVideoEncoder: MediaCodec is only tested with resolutions that are 16x16 aligned.

This makes the plugin not usable on Android unfortunately, since this type of aspect ratio is almost never used, and less when what you want to share is the camera or some device of the style that uses 4:3 or 16:9 ratios.

Describe the solution you'd like

I would like to be able to use all aspect ratios, or at least, the most common ones: 16:9, 4:3, 18:9.

Describe alternatives you've considered

I think it's a pretty basic operation, which is to send the camera content over WebRTC, and this bug/feature lack causes it not to be possible, so I haven't found any valid alternative.

Additional context

I've seen that flutter had the same problem and they managed to fix it https://github.com/flutter-webrtc/flutter-webrtc/issues/880

karasusan commented 9 months ago

@avicarpio Wow, how to fixed the issue by flutter team?

avicarpio commented 9 months ago

Sorry but I don't know. It just seems to be fixed in some time between the 2.8.1 and 2.10.3 versions as a user said https://github.com/flutter-webrtc/flutter-webrtc/issues/880#issuecomment-1066618800

Another reference of this bug on the chromium forum https://bugs.chromium.org/p/chromium/issues/detail?id=1084702

karasusan commented 9 months ago

Solution is here https://github.com/flutter-webrtc/flutter-webrtc/issues/889

karasusan commented 9 months ago

Strange. We have already enabled the enable_h264_high_profile flag.

https://github.com/Unity-Technologies/com.unity.webrtc/blob/main/Plugin~/WebRTCPlugin/Android/AndroidCodecFactoryHelper.cpp#L36

karasusan commented 9 months ago

@avicarpio This alignment is already removed in libwebrtc in this March. https://source.chromium.org/chromium/_/webrtc/src.git/+/5c978cb2628904afd588015dd4ca3522e1319ad0

This issue is already fixed on version M116, so please wait to release next version in next month.

karasusan commented 9 months ago

memo: WRS-488

avicarpio commented 9 months ago

Wow good news! Thank you @karasusan!

avicarpio commented 8 months ago

Hi @karasusan, do you know when will be 3.0.0-pre.7 ready? I thought that it would be realeased at 30th september, but I still don't see it. Thank you!