diff --git a/library/ajax/ffprobe_info.php b/library/ajax/ffprobe_info.php index 38ab0de20..864b49b33 100644 --- a/library/ajax/ffprobe_info.php +++ b/library/ajax/ffprobe_info.php @@ -67,7 +67,7 @@ if (isset($ffpInfo->streams)) { $result .= sprintf($lang['BITRATE'], humn_bitrate($stream->bit_rate)) . '
'; } if (!empty($stream->sample_rate)) { - $result .= sprintf($lang['SAMPLE_RATE'], $stream->sample_rate) . '
'; + $result .= sprintf($lang['SAMPLE_RATE'], humn_sample_rate($stream->sample_rate)) . '
'; } if (!empty($stream->channels)) { $result .= sprintf($lang['CHANNELS'], $stream->channels) . '
'; @@ -105,4 +105,39 @@ if (isset($ffpInfo->streams)) { $this->response['ffprobe_data'] = $result; } +/** + * Bitrate to human-readable format + * + * @param int $bitrate + * @param string $space + * @return string + */ +function humn_bitrate(int $bitrate, string $space = ' '): string +{ + if ($bitrate >= 1000000) { + $unit = 'Mbps'; + $bitrate /= 1000000; + } elseif ($bitrate >= 1000) { + $unit = 'kbps'; + $bitrate /= 1000; + } else { + $unit = 'bps'; + } + + return commify($bitrate, 2) . $space . $unit; +} + +/** + * Sample rate to human-readable format + * + * @param int $sample_rate + * @param string $space + * @return string + */ +function humn_sample_rate(int $sample_rate, string $space = ' '): string +{ + $unit = ''; + return commify($sample_rate, 2) . $space . $unit; +} + $this->response['file_index'] = $file_index; diff --git a/library/includes/functions.php b/library/includes/functions.php index b04ce7a92..aeb9e04d2 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -595,29 +595,6 @@ function humn_size($size, $rounder = null, $min = null, $space = ' ') return round($size, $rounder) . $space . $ext; } -/** - * Bitrate to human-readable format - * - * @param int $bitrate - * @param string $space - * @return string - */ -function humn_bitrate(int $bitrate, string $space = ' '): string -{ - if ($bitrate >= 1000000) { - $unit = 'Mbps'; - $bitrate /= 1000000; - } elseif ($bitrate >= 1000) { - $unit = 'kbps'; - $bitrate /= 1000; - } else { - $unit = 'bps'; - } - - $formattedBitrate = number_format($bitrate, 2); - return $formattedBitrate . $space . $unit; -} - function bt_show_ip($ip, $port = '') { global $bb_cfg;