Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Format fps value

Neeraj Guptad6a970274c58
diff --git a/mobile/lib/models/ffmpeg/ffprobe_props.dart b/mobile/lib/models/ffmpeg/ffprobe_props.dart
index a95eff9e2f..575382a409 100644
--- a/mobile/lib/models/ffmpeg/ffprobe_props.dart
+++ b/mobile/lib/models/ffmpeg/ffprobe_props.dart
@@ -115,7 +115,7 @@ class FFProbeProps {
for (final stream in streams) {
for (final key in stream.keys) {
if (key == FFProbeKeys.rFrameRate) {
- result.fps = stream[key];
+ result.fps = _formatFPS(stream[key]);
parsedData[key] = result.fps;
} else if (key == FFProbeKeys.codedWidth) {
result.codecWidth = stream[key].toString();
@@ -220,6 +220,19 @@ class FFProbeProps {
return size != null ? formatFileSize(asciiLocale, size) : value;
}
+ static String? _formatFPS(dynamic value) {
+ if (value == null) return null;
+ int? t = int.tryParse(value.split('/')[0]);
+ int? b = int.tryParse(value.split('/')[1]);
+ if (t != null && b != null) {
+ // return the value upto 2 decimal places. ignore even two decimal places
+ // if t is perfectly divisible by b
+ return (t % b == 0)
+ ? (t / b).toStringAsFixed(0)
+ : (t / b).toStringAsFixed(2);
+ }
+ }
+
static String _formatLanguage(String value) {
final language = Language.living639_2
.firstWhereOrNull((language) => language.iso639_2 == value);