Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Neto committed Nov 22, 2024
1 parent f65d17c commit f21f44e
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions plugin/Live/standAloneFiles/kill_ffmpeg_restream.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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);

Expand Down

0 comments on commit f21f44e

Please sign in to comment.