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 <noreply@anthropic.com>
This commit is contained in:
GitHub CopilotandClaude Haiku 4.5 committed 2026-03-26 15:26:50 +01:00
1 parent 1bc9223665
commit 29888c9b2a
1 file changed
+2 -2
@@ -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)';