Announce the rotated resolution so portrait streams are not pillarboxed - #2182
Merged
pedroSG94 merged 1 commit intoAug 12, 2026
Merged
Conversation
Owner
|
Hello, Thank you for the PR, but please, remove the comment in the code. |
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.
x270880x
force-pushed
the
fix/announce-rotated-resolution
branch
from
August 12, 2026 13:15
fa5aae5 to
ddfac19
Compare
Contributor
Author
|
Done — comment removed, the diff is now the code change only. The reasoning stays in the commit message, as you suggested. Thanks for looking at it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A portrait broadcast tells the RTMP server it is landscape.
VideoEncoderstoreswidth/heightexactly asprepareVideoEncoderreceived them and keepsrotationseparately — at 90 or 270 it configures the codec asheight x width(VideoEncoder.java:136-141). So a stream prepared with(1920, 1080, rotation = 90)really produces 1080x1920 frames, whilegetVideoResolution()returns 1920x1080.That pair goes straight into
onMetaData:GenericStream.kt:111RtmpStream.kt:73MultiStream.kt:188Players trust
onMetaData. YouTube opens a 16:9 window and pillarboxes the vertical picture — black bars down both sides — which is exactly what our users reported for vertical streams.MultiCamera1/2already handle this at the call site:so only the newer classes are affected. I fixed it inside
getVideoResolution()instead of repeating the swap three times, so anything else reading it also gets the shape that is actually on the wire.Measured on a Samsung SM-A065F, camera in portrait: prepared 1920x1080 with rotation 90, captured stream carries 1080x1920 frames (read from the SPS), and the announced resolution now matches instead of claiming landscape.