From f21f44e53101b753a79f82ed66526e93ea77c618 Mon Sep 17 00:00:00 2001 From: Daniel Neto <me@danielneto.com> Date: Fri, 22 Nov 2024 13:59:20 -0300 Subject: [PATCH] Update --- .../standAloneFiles/kill_ffmpeg_restream.php | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/plugin/Live/standAloneFiles/kill_ffmpeg_restream.php b/plugin/Live/standAloneFiles/kill_ffmpeg_restream.php index 8bb858631596..0b7975e81d5b 100644 --- a/plugin/Live/standAloneFiles/kill_ffmpeg_restream.php +++ b/plugin/Live/standAloneFiles/kill_ffmpeg_restream.php @@ -50,6 +50,27 @@ function formatLastModifiedTime($timestamp) { return date('Y-m-d H:i:s', $timestamp); } +function _humanFileSize($size, $unit = "") { + if ((!$unit && $size >= 1 << 40) || $unit == "TB") { + return number_format($size / (1 << 40), 2) . "TB"; + } + + if ((!$unit && $size >= 1 << 30) || $unit == "GB") { + return number_format($size / (1 << 30), 2) . "GB"; + } + + if ((!$unit && $size >= 1 << 20) || $unit == "MB") { + return number_format($size / (1 << 20), 2) . "MB"; + } + + if ((!$unit && $size >= 1 << 10) || $unit == "KB") { + return number_format($size / (1 << 10), 2) . "KB"; + } + + return number_format($size) . " bytes"; +} + + // Get all log files for FFmpeg restreamers $logFiles = glob($logDir . 'ffmpeg_restreamer_*.log'); @@ -63,10 +84,10 @@ function formatLastModifiedTime($timestamp) { $lastModified = filemtime($logFile); if ($filesize > $maxSize) { - echo "kill_ffmpeg_restream.php The file too large logFiles $logFile {$filesize}".PHP_EOL; + echo "kill_ffmpeg_restream.php The file too large logFiles $logFile "._humanFileSize($filesize).PHP_EOL; continue; }else{ - echo "kill_ffmpeg_restream.php logFiles $logFile {$filesize}".PHP_EOL; + echo "kill_ffmpeg_restream.php logFiles $logFile "._humanFileSize($filesize).PHP_EOL; } $lastModifiedFormatted = formatLastModifiedTime($lastModified);