This commit is contained in:
Roman Kelesidis 2024-09-05 11:30:30 +07:00
commit 3d9e61389a
2 changed files with 36 additions and 24 deletions

View file

@ -67,7 +67,7 @@ if (isset($ffpInfo->streams)) {
$result .= sprintf($lang['BITRATE'], humn_bitrate($stream->bit_rate)) . '<br>'; $result .= sprintf($lang['BITRATE'], humn_bitrate($stream->bit_rate)) . '<br>';
} }
if (!empty($stream->sample_rate)) { if (!empty($stream->sample_rate)) {
$result .= sprintf($lang['SAMPLE_RATE'], $stream->sample_rate) . '<br>'; $result .= sprintf($lang['SAMPLE_RATE'], humn_sample_rate($stream->sample_rate)) . '<br>';
} }
if (!empty($stream->channels)) { if (!empty($stream->channels)) {
$result .= sprintf($lang['CHANNELS'], $stream->channels) . '<br>'; $result .= sprintf($lang['CHANNELS'], $stream->channels) . '<br>';
@ -105,4 +105,39 @@ if (isset($ffpInfo->streams)) {
$this->response['ffprobe_data'] = $result; $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 = '&nbsp;'): 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 = '&nbsp;'): string
{
$unit = '';
return commify($sample_rate, 2) . $space . $unit;
}
$this->response['file_index'] = $file_index; $this->response['file_index'] = $file_index;

View file

@ -595,29 +595,6 @@ function humn_size($size, $rounder = null, $min = null, $space = '&nbsp;')
return round($size, $rounder) . $space . $ext; 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 = '&nbsp;'): 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 = '') function bt_show_ip($ip, $port = '')
{ {
global $bb_cfg; global $bb_cfg;