π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Set aspect ratio of video
ashilkn31318f10d6da
diff --git a/mobile/lib/ui/viewer/file/video_widget_native.dart b/mobile/lib/ui/viewer/file/video_widget_native.dartindex 4754b4ba77..ba80325cf2 100644--- a/mobile/lib/ui/viewer/file/video_widget_native.dart+++ b/mobile/lib/ui/viewer/file/video_widget_native.dart@@ -20,6 +20,7 @@ import "package:photos/theme/ente_theme.dart";import "package:photos/ui/actions/file/file_actions.dart";import "package:photos/ui/viewer/file/thumbnail_widget.dart";import "package:photos/utils/dialog_util.dart";+import "package:photos/utils/exif_util.dart";import "package:photos/utils/file_util.dart";import "package:photos/utils/toast_util.dart";@@ -250,9 +251,24 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>setState(() {_filePath = url;});- // setAspectRatioFromVideoProps().then((_) {- // setState(() {});- // });+ _setAspectRatioFromVideoProps().then((_) {+ setState(() {});+ });+ }+ }++ Future<void> _setAspectRatioFromVideoProps() async {+ final videoProps = await getVideoPropsAsync(File(_filePath!));+ if (videoProps != null) {+ if (videoProps.width != null && videoProps.height != null) {+ aspectRatio = videoProps.width! / videoProps.height!;+ } else {+ _logger.info("Video props width and height are null");+ aspectRatio = 1;+ }+ } else {+ _logger.info("Video props are null");+ aspectRatio = 1;}}}diff --git a/mobile/lib/utils/exif_util.dart b/mobile/lib/utils/exif_util.dartindex d9bac85e6d..cbe09502e8 100644--- a/mobile/lib/utils/exif_util.dart+++ b/mobile/lib/utils/exif_util.dart@@ -58,6 +58,7 @@ Future<Map<String, IfdTag>?> getExifFromSourceFile(File originFile) async {Future<FFProbeProps?> getVideoPropsAsync(File originalFile) async {try {+ final stopwatch = Stopwatch()..start();final Map<int, StringBuffer> logs = {};final completer = Completer<MediaInformation?>();@@ -95,6 +96,8 @@ Future<FFProbeProps?> getVideoPropsAsync(File originalFile) async {return null;}final properties = await FFProbeUtil.getProperties(mediaInfo);+ _logger.info("getVideoPropsAsync took ${stopwatch.elapsedMilliseconds}ms");+ stopwatch.stop();return properties;} catch (e, s) {_logger.severe("Failed to getVideoProps", e, s);