Skip to content

Fix thumbnail rotation in getBitmap() - #331

Open
Seyun wants to merge 1 commit into
jonataslaw:masterfrom
Seyun:pr/fix-thumbnail-rotation
Open

Fix thumbnail rotation in getBitmap()#331
Seyun wants to merge 1 commit into
jonataslaw:masterfrom
Seyun:pr/fix-thumbnail-rotation

Conversation

@Seyun

@Seyun Seyun commented Jul 22, 2026

Copy link
Copy Markdown

What

getBitmap() (Android) extracts the poster frame via MediaMetadataRetriever.getFrameAtTime(), but never applied the video's rotation metadata to the resulting bitmap.

Why it matters

getFrameAtTime() returns the frame in its raw encoded orientation, ignoring the rotation flag — this is standard, well-documented Android behavior. Portrait recordings are frequently encoded with landscape raw dimensions plus a 90°/270° rotation flag, so the extracted thumbnail bitmap came out sideways even though the video itself plays back correctly rotated (players honor the rotation metadata; frame-grabbing via getFrameAtTime() does not).

Fix

Read METADATA_KEY_VIDEO_ROTATION alongside the frame and rotate the extracted bitmap with a Matrix to match the actual playback orientation before it's scaled/returned.

MediaMetadataRetriever.getFrameAtTime() returns the frame bitmap in its
raw encoded orientation without applying the video's rotation metadata.
For a portrait-recorded video (raw encoded landscape + 90/270 rotation
flag), this produced a landscape-looking thumbnail even though the
video itself plays back correctly rotated.

Read METADATA_KEY_VIDEO_ROTATION alongside the frame and rotate the
extracted bitmap to match before returning it.
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