Skip to content

Fix subtitles rendered outside the video in portrait mode - #1861

Open
hoyahozz wants to merge 1 commit into
anilbeesetti:mainfrom
hoyahozz:main
Open

Fix subtitles rendered outside the video in portrait mode#1861
hoyahozz wants to merge 1 commit into
anilbeesetti:mainfrom
hoyahozz:main

Conversation

@hoyahozz

@hoyahozz hoyahozz commented Aug 5, 2026

Copy link
Copy Markdown

Cause

SubtitleView uses fillMaxSize() as a sibling of PlayerSurface. As a result, it is measured against the entire player, while only the video surface is resized with resizeWithContentScale.

Media3 positions subtitle cues as a fraction of the subtitle view's height. For a letterboxed video, that fraction is therefore applied to the full screen rather than to the visible video area, causing subtitles to appear below the picture.

Cues with an embedded fractional size, such as SSA/ASS cues, are also scaled by the same incorrect ratio and become oversized. Plain SRT cues keep their expected size because the app applies an absolute text size.

The issue is primarily visible in portrait mode. In landscape, the video height usually matches the subtitle view height, so the incorrect measurement is not noticeable.

Media3's PlayerView avoids this by placing SubtitleView inside exo_content_frame in exo_player_view.xml.

Fix

Measure the subtitle view against the visible video bounds instead of the entire player.

The calculated size uses the same ContentScale behavior as the video surface, but is clamped to the player bounds on each axis.

The clamp is required because resizeWithContentScale allows content to overflow the container. That behavior is correct for the video surface, but not for subtitles.

Without the clamp, CROP produced a subtitle view 4693 px wide on a 1080 px screen, causing both ends of the cue to render off-screen. HUNDRED_PERCENT can overflow horizontally as well, so the clamp must be applied independently to both axes.

Zoom, pan, and the Picture-in-Picture source rect remain applied only to the video surface. Subtitles therefore do not scale with pinch zoom, which preserves the existing behavior.

Before / after

Portrait mode, embedded ASS subtitles.

Before After
2_portrait_ass 2_portrait_ass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant