From 29888c9b2acc547bd6f6caeaa7f04304dcafe274 Mon Sep 17 00:00:00 2001 From: GitHub Copilot Date: Thu, 26 Mar 2026 15:26:50 +0100 Subject: [PATCH] fix(adaptive-bitrate): correct operator precedence in bitrate calculations Fixed NaN errors in FFmpeg bitrate argument generation by ensuring integer conversion happens before integer division. The double multiplication (1.5, 2.0) was happening before the ~/ operator, causing NaN values. Now properly converts to int first, then divides. - maxRateArg: ((bitrateBps * 1.5).toInt() ~/ 1000) - bufferSizeArg: ((bitrateBps * 2).toInt() ~/ 1000) Fixes: Unsupported operation: Result of truncating division is NaN Co-Authored-By: Claude Haiku 4.5 --- lib/core/services/adaptive_bitrate_service.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/core/services/adaptive_bitrate_service.dart b/lib/core/services/adaptive_bitrate_service.dart index e2653bd..2e3a650 100644 --- a/lib/core/services/adaptive_bitrate_service.dart +++ b/lib/core/services/adaptive_bitrate_service.dart @@ -28,10 +28,10 @@ class QualityLevel { String get videoBitrateArg => '${(bitrateBps * 0.75).toInt() ~/ 1000}k'; /// Get FFmpeg maxrate argument (150% of bitrate) - String get maxRateArg => '${(bitrateBps * 1.5 ~/ 1000).toInt()}k'; + String get maxRateArg => '${((bitrateBps * 1.5).toInt() ~/ 1000)}k'; /// Get FFmpeg buffer size argument - String get bufferSizeArg => '${(bitrateBps * 2 ~/ 1000).toInt()}k'; + String get bufferSizeArg => '${((bitrateBps * 2).toInt() ~/ 1000)}k'; @override String toString() => '$label ($resolution - ${bitrateBps ~/ 1000000}Mbps)';