From ddfac19c811720c53a895850d900fa6a05827a16 Mon Sep 17 00:00:00 2001 From: x270880x Date: Wed, 12 Aug 2026 09:08:20 +0300 Subject: [PATCH] Announce the rotated resolution, so portrait streams are not pillarboxed VideoEncoder stores width/height exactly as prepareVideoEncoder received them and keeps rotation separately; at 90 or 270 it configures the codec as height x width. A portrait broadcast prepared with (1920, 1080, rotation = 90) therefore produces 1080x1920 frames, while getVideoResolution() reported 1920x1080. That pair goes straight into onMetaData: GenericStream.kt:111 val resolution = super.getVideoResolution() RtmpStream.kt:73 val resolution = super.getVideoResolution() MultiStream.kt:188 val resolution = super.getVideoResolution() so every portrait broadcast through the newer API told the server it was landscape. Players trust onMetaData: YouTube opens a 16:9 window and pillarboxes the vertical picture, which is what our users reported. MultiCamera1/2 already swapped at their call sites (MultiCamera2.kt:197-201), so only the newer classes were affected. Fixed in getVideoResolution() rather than at the three call sites, so anything else reading it gets the shape that is actually on the wire. Verified on a Samsung SM-A065F: prepared 1920x1080 with rotation 90, the encoder emits 1080x1920 (confirmed from the SPS of the captured stream), and the metadata now matches instead of claiming landscape. --- library/src/main/java/com/pedro/library/base/StreamBase.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/com/pedro/library/base/StreamBase.kt b/library/src/main/java/com/pedro/library/base/StreamBase.kt index 8b21c40024..773249e251 100644 --- a/library/src/main/java/com/pedro/library/base/StreamBase.kt +++ b/library/src/main/java/com/pedro/library/base/StreamBase.kt @@ -503,7 +503,11 @@ abstract class StreamBase( return glInterface.surfaceTexture } - protected fun getVideoResolution() = Size(videoEncoder.width, videoEncoder.height) + protected fun getVideoResolution(): Size { + val portrait = videoEncoder.rotation == 90 || videoEncoder.rotation == 270 + return if (portrait) Size(videoEncoder.height, videoEncoder.width) + else Size(videoEncoder.width, videoEncoder.height) + } protected fun getVideoFps() = videoEncoder.fps