Back to the original issue (adding an Android surface as an additional display), after making the change to the gradle files to get the project to build in 2020.2.0f1, the rendering to the extra display appears to work. The MediaCodec encoder is seeing updates to the input surface and producing encoded h264 output.
The summary for those just catching up and for future developers searching for these errors:
-
The feature to add an Android surface as an additional display appears to require Unity 2020.2.0f1. It does not appear to work correctly in Unity 2019.4.11f1 (I tried for days to get it working), even though the feature was added back in the Unity 5.x series.
-
If upgrading to Unity 2020.2.0f1 from an earlier Unity project that has a custom Android gradle file, change the existing
noCompress
line in theaaptOptions
section (or add it if it is missing) to the following
noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')