From bdfebadb0d8f241dea056417cb14ce314c0c4ae9 Mon Sep 17 00:00:00 2001 From: TheTroll Date: Wed, 17 Mar 2010 19:27:09 +0100 Subject: Generate video logo and print info --- bin/backend.php | 7 ++++--- bin/files.php | 27 +++++++++++++-------------- bin/jsonapi.php | 12 ++++++++++++ bin/session.php | 7 +++++++ 4 files changed, 36 insertions(+), 17 deletions(-) diff --git a/bin/backend.php b/bin/backend.php index 3ed2dcb..87a5f7b 100755 --- a/bin/backend.php +++ b/bin/backend.php @@ -6,6 +6,7 @@ if (file_exists('../config.php')) include ('../config.php'); else include ('../config_default.php'); +include ('../getid3/getid3.php'); include ('./utils.php'); include ('./files.php'); include ('./streaminfo.php'); @@ -50,9 +51,9 @@ switch ($action) break; case ("getVidInfo"): - $tree = file_get_contents("textfiles/getVidInfo.txt"); - print $tree; - break; + $tree = getVidInfo($_REQUEST['file']); + print $tree; + break; case ("getStreamInfo"): $tree = getStreamInfo($_REQUEST['session']); diff --git a/bin/files.php b/bin/files.php index f39ee98..ba82d21 100755 --- a/bin/files.php +++ b/bin/files.php @@ -2,22 +2,21 @@ function mediagetinfostream($stream) { + $info = array(); + // Get info $getid3 = new getID3; $fileinfo = $getid3->analyze($stream); - $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'] ."
"; - - return array($title, $info); + $info['name'] = basename($stream); + $info['desc'] = ""; + $info['duration'] = sec2hms($fileinfo['playtime_seconds']); + $info['format'] = $fileinfo['fileformat']; + $info['video'] = $fileinfo['video']['codec']; + $info['audio'] = $fileinfo['audio']['codec']; + $info['resolution'] = $fileinfo['video']['resolution_x'] ."x" .$fileinfo['video']['resolution_y']; + + return $info; } function mediagentb($stream, $dest) @@ -64,12 +63,12 @@ function mediagentb($stream, $dest) } if ($file) - exec("cp \"" .$file ."\" ram/stream-tb-tmp.jpg; " .$ffmpegpath ." -y -i ram/stream-tb-tmp.jpg -s " .$resx ."x" .$resy ." " .$dest ." ; rm ram/stream-tb-tmp.jpg"); + exec("cp \"" .$file ."\" ../ram/stream-tb-tmp.jpg; " .$ffmpegpath ." -y -i ../ram/stream-tb-tmp.jpg -s " .$resx ."x" .$resy ." " .$dest ." ; rm ../ram/stream-tb-tmp.jpg"); else exec($ffmpegpath ." -y -i \"" .$stream ."\" -an -ss 00:00:05.00 -r 1 -vframes 1 -s " .$resx ."x" .$resy ." -f mjpeg " .$dest); if (!file_exists($dest)) - exec('cp logos/nologoMEDIA.png ' .$dest); + exec('cp ../logos/nologoMEDIA.png ' .$dest); } function mediagetwidth($file) diff --git a/bin/jsonapi.php b/bin/jsonapi.php index 0c3b350..0f922c2 100755 --- a/bin/jsonapi.php +++ b/bin/jsonapi.php @@ -75,6 +75,18 @@ function getRecInfo($rec) return json_encode($ret); } +function getVidInfo($file) +{ + $ret = array(); + + // Generate logo + generatelogo('vid', $file, '../ram/temp-logo.png'); + + $ret['program'] = mediagetinfostream($file); + + return json_encode($ret); +} + function startBroadcast($type, $url, $mode) { $ret = array(); diff --git a/bin/session.php b/bin/session.php index 8e3e727..ccf12fe 100755 --- a/bin/session.php +++ b/bin/session.php @@ -140,6 +140,13 @@ function sessiongetinfo($session) list($channame, $info['name'], $info['desc'], $info['recorded']) = vdrgetrecinfo($url); break; case 'vid': + $infovid = mediagetinfostream($url); + $info['desc'] = $infovid['desc']; + $info['duration'] = $infovid['duration']; + $info['format'] = $infovid['format']; + $info['video'] = $infovid['video']; + $info['audio'] = $infovid['audio']; + $info['resiolution'] = $infovid['resiolution']; break; } -- cgit v1.2.3