Repository navigation
Closed
flutter/packages
#12360Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 2.5Found to occur in 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6Found to occur in 2.6has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: video_playerThe Video Player pluginThe Video Player pluginpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyAndroid applications specificallyteam-androidOwned by Android platform teamOwned by Android platform teamtriaged-androidTriaged by Android platform teamTriaged by Android platform team
Description
Steps to Reproduce
- flutter create
bug - add the video_player plugin
- Run the code sample
Expected results:
the same size on iOS and android
Actual results:
height is correct but width is wrong
iOS
flutter: ======== Size(782.8, 1080.0)android
[+1825 ms] I/flutter ( 5846): ======== Size(1696.0, 1080.0)Code sample
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: const PlayAnimation(),
);
}
}
class PlayAnimation extends StatefulWidget {
const PlayAnimation({Key? key}) : super(key: key);
@override
_PlayAnimationState createState() => _PlayAnimationState();
}
class _PlayAnimationState extends State<PlayAnimation> {
late VideoPlayerController _controller;
@override
void initState() {
super.initState();
_controller = VideoPlayerController.network(
'https://user-images.githubusercontent.com/18373253/144225439-90bb67fe-69f0-43c8-bad6-cfd066844eb6.mp4',
/// real size: 782 x 1080
);
_controller.setLooping(true);
_controller.initialize().then((_) {
debugPrint("======== ${_controller.value.size}");
/// output: ======== Size(1696.0, 1080.0)
setState(() {
_controller.play();
});
});
}
_getVideoBackground() {
return _controller.value.isInitialized
? AspectRatio(
aspectRatio: 391 / 540,
child: VideoPlayer(_controller),
)
: Container();
}
@override
Widget build(BuildContext context) {
return Center(
child: _getVideoBackground(),
);
}
@override
void dispose() {
super.dispose();
_controller.dispose();
}
}
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 2.5Found to occur in 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6Found to occur in 2.6has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: video_playerThe Video Player pluginThe Video Player pluginpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyAndroid applications specificallyteam-androidOwned by Android platform teamOwned by Android platform teamtriaged-androidTriaged by Android platform teamTriaged by Android platform team

Activity
danagbemava-nc commentedon Dec 1, 2021
Hi @codenoobforreal, thanks for filing the issue.
Please provide a sample video for reproduction. Also, please specify which version of
video_playeryou're using.Thank you
codenoobforreal commentedon Dec 1, 2021
hi @danagbemava-nc,nice to hear that.I am using video_player: ^2.2.5.
video below.
loading-animation.mp4
danagbemava-nc commentedon Dec 1, 2021
Hi @codenoobforreal , one more question, is this issue on
androidoriOS?Please provide the output of
flutter run -vas well.The output is likely to be huge, so please put it into a .txt file and attach it here.
Thank you
codenoobforreal commentedon Dec 1, 2021
android device: MI 8 SE
log.txt
maheshj01 commentedon Dec 2, 2021
Probably related to #51250
danagbemava-nc commentedon Dec 2, 2021
I did a bit digging into the
video_playersource and I noticed the size is created at this pointsize initialization in plugin
https://github.com/flutter/plugins/blob/702fada379f3b7b70a0b3af9879aa0629a1533b6/packages/video_player/video_player_platform_interface/lib/method_channel_video_player.dart#L108
and these values are from exoplayer on the native side
width and height from native side
https://github.com/flutter/plugins/blob/702fada379f3b7b70a0b3af9879aa0629a1533b6/packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java#L274
If you look at the logs, you'll notice this somewhere in there
codec information
which is coming from
exoplayer, you'll notice that the width is reported as1696which matches what you got. So I decided to look into it further to see if anyone had reported this toexoplayerand I found this GH thread google/ExoPlayer#3690, so I decided to try what was stated in google/ExoPlayer#3690 (comment) with a native android application.The value is closer to what expected it to be. It looks like the
pixelWidthHeightRatiois not being taken into account when retrieving thewidthandheight. I don't know why that is the case, labelling for further insight.code samples
native sampleExoTest.zip
flutter samplelogs
run_log_android.txt
run_log_ios.txt
flutter doctor -v
13 remaining items
tangTdc123 commentedon Dec 7, 2023
TimYusR commentedon May 8, 2025
Seems like its not a duplicate.
I have 2 videos.
First is horizontal, captured by iPhone, has
MOVformat. The videoController.value returnsSize(1280, 720)for it.Second is vertical, captured by Android Emulator API 35, has
MP4format. In that case videoController.value returnsSize(1280, 720), which is not correct because its vertical. And my vertical video stretches by width in video_player.The above appears on Android Emulator API 35.
On my Xiaomi Redmi Note 8, Android 11, vertical videos of any format are randomly rotated.
First horizontal video screen
Secoind vertical video screen
Videos rotated screens
[video_player_android] Report display size for anamorphic video (flut…
[video_player_android] Report display size for anamorphic video (flut…
[video_player_android] Report display size for anamorphic video (flut…
github-actions commentedon Sep 16, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.