fix: Bitrate display in Media Info (#556)

This commit is contained in:
matt-hb 2025-11-07 11:13:50 +01:00 committed by GitHub
parent b9c1e82b43
commit 2594a8463f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 3 deletions

View file

@ -0,0 +1,23 @@
// ignore_for_file: constant_identifier_names
extension BitrateFormats on int? {
String? get audioBitrateFormat {
final bitrate = this;
if (bitrate == null) return null;
return "${(bitrate / 1000).round()} kbps";
}
String? get videoBitrateFormat {
const int highBitrateCutoff = 10000000;
const int kb = 1000;
const int Mb = kb * kb;
final bitrate = this;
if (bitrate == null) return null;
if (bitrate >= highBitrateCutoff) {
return "${(bitrate / Mb).toStringAsFixed(1)} Mbps";
} else {
return "${(bitrate / kb).round()} kbps";
}
}
}