From 5779611e7d547302ed9847448acce65e07439b3d Mon Sep 17 00:00:00 2001 From: TheTroll Date: Fri, 26 Feb 2010 17:06:09 +0100 Subject: Display more media info (#268) Display thumbs with the right A/R (#269) --- includes/inc_files.php | 21 +++++++++++++++++---- includes/inc_utils.php | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/includes/inc_files.php b/includes/inc_files.php index c2d2f14..b625a7c 100755 --- a/includes/inc_files.php +++ b/includes/inc_files.php @@ -10,14 +10,27 @@ function mediagetinfostream($stream = "") $getid3 = new getID3; $fileinfo = $getid3->analyze($stream); - $title = $fileinfo['fileformat']; - $info = $fileinfo['playtime_string']; + $title = "Media:"; + $info = "Duration: " .sec2hms($fileinfo['playtime_seconds']) ."
"; + if ($fileinfo['fileformat']) + $info .= "Format: " .$fileinfo['fileformat'] ."
"; + if ($fileinfo['video']['codec']) + $info .= "Video: " .$fileinfo['video']['codec'] ."
"; + if ($fileinfo['audio']['codec']) + $info .= "Audio: " .$fileinfo['audio']['codec'] ."
"; + if ($fileinfo['video']['resolution_x']) + $info .= "Resolution: " .$fileinfo['video']['resolution_x'] ."x" .$fileinfo['video']['resolution_y'] ."
"; // Extract a thumbnail exec("rm ram/stream-tb.*"); - $path = dirname($stream); + // Get the right Y resolution + if ($fileinfo['video']['resolution_y'] && $fileinfo['video']['resolution_x']) + $resy = ($fileinfo['video']['resolution_y'] * 180) / $fileinfo['video']['resolution_x']; + else + $resy = 100; + if (file_exists(substr($stream, 0, -4) .".tbn")) exec("cp \"" .substr($stream, 0, -4) .".tbn\" ram/stream-tb-tmp.jpg; " .$ffmpegpath ." -y -i ram/stream-tb-tmp.jpg -s 128x180 ram/stream-tb.jpg"); else if (file_exists($path ."/poster.jpg")) @@ -25,7 +38,7 @@ function mediagetinfostream($stream = "") else if (file_exists($path ."/folder.jpg")) exec($ffmpegpath ." -y -i \"" .$path ."/folder.jpg\" -s 128x180 ram/stream-tb.jpg"); else - exec($ffmpegpath ." -y -i \"" .$stream ."\" -an -ss 00:00:05.00 -r 1 -vframes 1 -s 180x100 -f mjpeg ram/stream-tb.png"); + exec($ffmpegpath ." -y -i \"" .$stream ."\" -an -ss 00:00:05.00 -r 1 -vframes 1 -s 180x" .$resy ." -f mjpeg ram/stream-tb.png"); return array($title, $info); } diff --git a/includes/inc_utils.php b/includes/inc_utils.php index 071d8b0..82b57a6 100755 --- a/includes/inc_utils.php +++ b/includes/inc_utils.php @@ -56,5 +56,40 @@ function php2js ($var) return false; } +function sec2hms ($sec, $padHours = false) +{ + + // holds formatted string + $hms = ""; + + // there are 3600 seconds in an hour, so if we + // divide total seconds by 3600 and throw away + // the remainder, we've got the number of hours + $hours = intval(intval($sec) / 3600); + + // add to $hms, with a leading 0 if asked for + $hms .= ($padHours) + ? str_pad($hours, 2, "0", STR_PAD_LEFT). ':' + : $hours. ':'; + + // dividing the total seconds by 60 will give us + // the number of minutes, but we're interested in + // minutes past the hour: to get that, we need to + // divide by 60 again and keep the remainder + $minutes = intval(($sec / 60) % 60); + + // then add to $hms (with a leading 0 if needed) + $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT). ':'; + // seconds are simple - just divide the total + // seconds by 60 and keep the remainder + $seconds = intval($sec % 60); + + // add to $hms, again with a leading 0 if needed + $hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT); + + // done! + return $hms; + +} ?> -- cgit v1.2.3