You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 80da2cf
Browse filesBrowse the repository at this point in the historyBrowse files
[video_player_android] Report display size for anamorphic video (flutter#12360)
`VideoSize.pixelWidthHeightRatio` was never read, so videos stored with non-square pixels (anamorphic content) reported their **coded** size instead of their **display** size. `VideoPlayerValue.size` therefore carried the wrong aspect ratio and such videos rendered stretched.
Example of a real affected file: coded `1080x720` with a `3:8` pixel aspect ratio displays as `405x720`, but `size` was reported as `1080x720` — a 2.67x horizontal stretch.
This scales the reported width by the pixel aspect ratio, which is what media3's own [`PlayerView`](https://github.com/androidx/media/blob/release/libraries/ui/src/main/java/androidx/media3/ui/PlayerView.java) does:
```java
float videoAspectRatio = (height == 0 || width == 0) ? 0 : (width * videoSize.pixelWidthHeightRatio) / height;
```
Both event listeners are updated:
- **Texture path** — ExoPlayer reports a `pixelWidthHeightRatio` that already accounts for any applied rotation (`MediaCodecVideoRenderer` inverts it for 90°/270°), so the ratio is applied to the reported width regardless of the rotation correction.
- **Platform view path** — `Format.pixelWidthHeightRatio` describes the unrotated frame, so the ratio is applied *before* the existing width/height swap.
The scaling is skipped unless the ratio is greater than 0 and not 1, so playback of ordinary square-pixel video is byte-for-byte unchanged.
Verified on a physical anamorphic sample (`1080x720`, SAR `3:8`) on Android 15: previously stretched, now rendered at the correct 9:16 display aspect. iOS is unaffected — `video_player_avfoundation` already reports `presentationSize`, which is pixel-aspect corrected, which is why this bug is Android-only.
*(No before/after screenshots: the sample videos available to me are private medical content and cannot be published.)*
Fixesflutter#132934Fixesflutter#94234
## Pre-Review Checklist
[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
Copy file name to clipboardExpand all lines: packages/video_player/video_player_android/CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,7 @@
1
+
## 2.12.2
2
+
3
+
* Fixes a [bug](https://github.com/flutter/flutter/issues/132934) where videos with a pixel aspect ratio other than 1.0 (anamorphic content) reported their coded size instead of their display size, causing them to be rendered stretched.
4
+
1
5
## 2.12.1
2
6
3
7
* Updates pigeon dev_dependency to ^27.3.2 for analyzer 14 compatibility.
Copy file name to clipboardExpand all lines: packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/platformview/PlatformViewExoPlayerEventListener.java
Copy file name to clipboardExpand all lines: packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/texture/TextureExoPlayerEventListener.java
Copy file name to clipboardExpand all lines: packages/video_player/video_player_android/android/src/test/java/io/flutter/plugins/videoplayer/PlatformViewExoPlayerEventListenerTest.java
+60Lines changed: 60 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -77,4 +77,64 @@ public void onPlaybackStateChangedReadyInPortraitMode270DegreesSwapsWidthAndHeig
Copy file name to clipboardExpand all lines: packages/video_player/video_player_android/android/src/test/java/io/flutter/plugins/videoplayer/TextureExoPlayerEventListenerTest.java
+57Lines changed: 57 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -124,4 +124,61 @@ public class TextureExoPlayerEventListenerTest {
0 commit comments