-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[video_player] [android] Width from VideoPlayerValue.size is wrong #94234
Comments
Hi @codenoobforreal, thanks for filing the issue. Please provide a sample video for reproduction. Also, please specify which version of Thank you |
hi @danagbemava-nc,nice to hear that.I am using video_player: ^2.2.5. loading-animation.mp4 |
Hi @codenoobforreal , one more question, is this issue on Please provide the output of The output is likely to be huge, so please put it into a .txt file and attach it here. Thank you |
android device: MI 8 SE |
Probably related to #51250 |
I did a bit digging into the size initialization in plugin return VideoEvent(
eventType: VideoEventType.initialized,
duration: Duration(milliseconds: map['duration']),
size: Size(map['width']?.toDouble() ?? 0.0,
map['height']?.toDouble() ?? 0.0),
); and these values are from exoplayer on the native side width and height from native sideif (exoPlayer.getVideoFormat() != null) {
Format videoFormat = exoPlayer.getVideoFormat();
int width = videoFormat.width;
int height = videoFormat.height;
int rotationDegrees = videoFormat.rotationDegrees;
// Switch the width/height if video was taken in portrait mode
if (rotationDegrees == 90 || rotationDegrees == 270) {
width = exoPlayer.getVideoFormat().height;
height = exoPlayer.getVideoFormat().width;
}
event.put("width", width);
event.put("height", height);
} If you look at the logs, you'll notice this somewhere in there codec information[ ] D/CCodec ( 5846): } and output: AMessage(what = 0x00000000) = {
[ ] D/CCodec ( 5846): int32_t android._color-format = 2135033992
[ ] D/CCodec ( 5846): int32_t android._video-scaling = 1
[ ] D/CCodec ( 5846): Rect crop(0, 0, 1695, 1079)
[ ] D/CCodec ( 5846): int32_t color-standard = 1
[ ] D/CCodec ( 5846): int32_t color-range = 2
[ ] D/CCodec ( 5846): int32_t color-transfer = 3
[ ] D/CCodec ( 5846): int32_t height = 1080
[ ] D/CCodec ( 5846): int32_t max-height = 1080
[ ] D/CCodec ( 5846): int32_t max-width = 1696
[ ] D/CCodec ( 5846): string mime = "video/raw"
[ ] D/CCodec ( 5846): int32_t rotation-degrees = 0
[ ] D/CCodec ( 5846): int32_t sar-height = 1
[ ] D/CCodec ( 5846): int32_t sar-width = 1
[ ] D/CCodec ( 5846): int32_t width = 1696
[ ] D/CCodec ( 5846): int32_t android._dataspace = 260
[ ] D/CCodec ( 5846): int32_t color-format = 2130708361
[ ] D/CCodec ( 5846): } which is coming from D/test: height: 1080
D/test: width: 1696
D/test: pixelWidthHeightRatio: 0.46153846
width * pixelWidthHeightRatio: 782.7692 The value is closer to what expected it to be. It looks like the code samples
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();
}
}
flutter doctor -v[✓] Flutter (Channel stable, 2.5.3, on macOS 11.6 20G165 darwin-arm, locale en-GB)
• Flutter version 2.5.3 at /Users/nexus/dev/sdks/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 18116933e7 (7 weeks ago), 2021-10-15 10:46:35 -0700
• Engine revision d3ea636dc5
• Dart version 2.14.4
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/nexus/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 13.0, Build version 13A233
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[☠] IntelliJ IDEA Community Edition (the doctor check crashed)
✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at https://github.com/flutter/flutter/issues.
✗ FormatException: Unexpected extension byte (at offset 5)
• #0 _Utf8Decoder.convertSingle (dart:convert-patch/convert_patch.dart:1788:7)
#1 Utf8Decoder.convert (dart:convert/utf.dart:318:42)
#2 InputStream.readString (package:archive/src/util/input_stream.dart:199:30)
#3 new ZipDirectory.read (package:archive/src/zip/zip_directory.dart:40:30)
#4 ZipDecoder.decodeBuffer (package:archive/src/zip_decoder.dart:19:30)
#5 ZipDecoder.decodeBytes (package:archive/src/zip_decoder.dart:14:12)
#6 IntelliJPlugins._findPluginXml (package:flutter_tools/src/intellij/intellij.dart:130:44)
#7 IntelliJPlugins._readPackageVersion (package:flutter_tools/src/intellij/intellij.dart:141:40)
#8 IntelliJPlugins.validatePackage (package:flutter_tools/src/intellij/intellij.dart:63:35)
#9 IntelliJValidator.validate (package:flutter_tools/src/intellij/intellij_validator.dart:103:15)
#10 asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:111:32)
#11 asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:109:18)
#12 _rootRun (dart:async/zone.dart:1428:13)
#13 _CustomZone.run (dart:async/zone.dart:1328:19)
#14 _runZoned (dart:async/zone.dart:1863:10)
#15 runZonedGuarded (dart:async/zone.dart:1851:12)
#16 runZoned (dart:async/zone.dart:1782:12)
#17 asyncGuard (package:flutter_tools/src/base/async_guard.dart:109:3)
#18 Doctor.startValidatorTasks (package:flutter_tools/src/doctor.dart:200:9)
#19 Doctor.diagnose (package:flutter_tools/src/doctor.dart:304:47)
#20 DoctorCommand.runCommand (package:flutter_tools/src/commands/doctor.dart:50:47)
#21 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1274:12)
<asynchronous suspension>
#22 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1125:27)
<asynchronous suspension>
#23 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#24 CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#25 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:288:9)
<asynchronous suspension>
#26 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#27 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:236:5)
<asynchronous suspension>
#28 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
<asynchronous suspension>
#29 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#30 main (package:flutter_tools/executable.dart:92:3)
<asynchronous suspension>
[✓] VS Code (version 1.62.3)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.29.0
[✓] Connected device (4 available)
• sdk gphone arm64 (mobile) • emulator-5554 • android-arm64 • Android 11 (API 30) (emulator)
• iPhone 13 (mobile) • 7515F01A-C1B6-456E-8559-8D2383D3719D • ios • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 11.6 20G165 darwin-arm
• Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.55
! Doctor found issues in 1 category. [✓] Flutter (Channel master, 2.6.0-12.0.pre.883, on macOS 11.6 20G165 darwin-arm, locale en-GB)
• Flutter version 2.6.0-12.0.pre.883 at /Users/nexus/dev/sdks/flutters
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 049ea73c4d (3 hours ago), 2021-12-01 20:19:02 -0800
• Engine revision c2fcadef89
• Dart version 2.16.0 (build 2.16.0-56.0.dev)
• DevTools version 2.8.0
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/nexus/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.0)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[☠] IntelliJ IDEA Community Edition (the doctor check crashed)
✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at https://github.com/flutter/flutter/issues.
✗ FormatException: Unexpected extension byte (at offset 5)
• #0 _Utf8Decoder.convertSingle (dart:convert-patch/convert_patch.dart:1789:7)
#1 Utf8Decoder.convert (dart:convert/utf.dart:351:42)
#2 InputStream.readString (package:archive/src/util/input_stream.dart:207:30)
#3 new ZipDirectory.read (package:archive/src/zip/zip_directory.dart:40:30)
#4 ZipDecoder.decodeBuffer (package:archive/src/zip_decoder.dart:19:30)
#5 ZipDecoder.decodeBytes (package:archive/src/zip_decoder.dart:14:12)
#6 IntelliJPlugins._findPluginXml (package:flutter_tools/src/intellij/intellij.dart:130:44)
#7 IntelliJPlugins._readPackageVersion (package:flutter_tools/src/intellij/intellij.dart:141:40)
#8 IntelliJPlugins.validatePackage (package:flutter_tools/src/intellij/intellij.dart:63:35)
#9 IntelliJValidator.validate (package:flutter_tools/src/intellij/intellij_validator.dart:103:15)
#10 asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:111:32)
#11 asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:109:18)
#12 _rootRun (dart:async/zone.dart:1426:13)
#13 _CustomZone.run (dart:async/zone.dart:1328:19)
#14 _runZoned (dart:async/zone.dart:1861:10)
#15 runZonedGuarded (dart:async/zone.dart:1849:12)
#16 runZoned (dart:async/zone.dart:1780:12)
#17 asyncGuard (package:flutter_tools/src/base/async_guard.dart:109:3)
#18 Doctor.startValidatorTasks (package:flutter_tools/src/doctor.dart:198:9)
#19 Doctor.diagnose (package:flutter_tools/src/doctor.dart:302:47)
#20 DoctorCommand.runCommand (package:flutter_tools/src/commands/doctor.dart:50:48)
#21 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1320:12)
<asynchronous suspension>
#22 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1161:27)
<asynchronous suspension>
#23 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#24 CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#25 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9)
<asynchronous suspension>
#26 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#27 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
<asynchronous suspension>
#28 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
<asynchronous suspension>
#29 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#30 main (package:flutter_tools/executable.dart:94:3)
<asynchronous suspension>
[✓] VS Code (version 1.62.3)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.29.0
[✓] Connected device (4 available)
• sdk gphone arm64 (mobile) • emulator-5554 • android-arm64 • Android 11 (API 30) (emulator)
• iPhone 13 (mobile) • 7515F01A-C1B6-456E-8559-8D2383D3719D • ios • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 11.6 20G165 darwin-arm
• Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.55
! Doctor found issues in 1 category. |
I found that the width and height of the video are only obtained once during initialization, but this does not meet my expectations. If it is a live broadcast and the width and height of the video will change, there will be a problem with the aspect ratio at this time. I hope his width High is real time. |
flutter/flutter#94234 참조. size 갱신 안되는 버그 존재해서 더이상 진행불가. 적응형 스트리밍은 이미 적용되어있음.
Steps to Reproduce
bug
Expected results:
the same size on
iOS
andandroid
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
Logs
The text was updated successfully, but these errors were encountered: