Jump to content

diddy1234

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

diddy1234's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the reply. could you give a short example of where I would put that function in ? Would I use this 'urlencode' next to the $film and $dir variables ? thanks again for the reply.
  2. I was wondering if someone could help me. I have a script that gives a listing of a directory and files, however if the file has spaces the file is listed correctly but it does not appear to handle a selected file. so for example if a file is shown as 'test 123.txt' the selected file will be 'test' with the 123.txt chopped off. The same applies to directory names with spaces as well. How do i handle this ? The script is a mixture of what i found on the web and my own customisation to get a directory to be selectable. Thanks in advance. script :--- function ListFiles($path, $tdir) { // List files // $filearray=array(); $dirarray=array(); $dirs = scandir($tdir); $i=0; $l=0; foreach ($dirs as $file) { if($file != '.' && $file != '..') { if (is_dir($tdir . '/' . $file)) { // Is dir $dirarray[$l]=$file; $l++; } else { // Must be a file then, $filearray[$i]=$file; $i++; } } } // Put into order sort($filearray); sort($dirarray); echo "<table border=\"0\" cellspacing=\"0\">"; for($l=0; $l<sizeof($dirarray); $l++) { $dir=$dirarray[$l]; echo "Directory of: <a href=\"?mode=list&dir=" . $tdir . $dir . "\">" . $dir . "</a><br>"; } echo "<br>"; for($i=0; $i<sizeof($filearray); $i++) { $film = substr($filearray[$i], 0 , -4); echo "<tr>"; echo "<td><a href=\"?mode=player&dir=" . $tdir . "&film=" . $film . "\">" . $film . "</a></td>"; } echo "</table>"; }
  3. For anyone remotely interested, I managed to fix the problem by doing the following :- <?php $path = '/mnt/data/video/films/'; $filename = htmlspecialchars($_GET["file"]); $ext=strrchr($filename, "."); $file = $path . $filename; ob_start(); passthru("/usr/local/bin/ffmpeg -i \"". $file . "\" 2>&1"); $duration = ob_get_contents(); ob_end_clean(); preg_match('/Duration: (.*?),/', $duration, $matches); $duration = $matches[1]; list($hr,$m,$s) = explode(':', $duration); $duration_in_seconds = ( (int)$hr*3600 ) + ( (int)$m*60 ) + (int)$s; // a work around for now - need to remove when above works //$duration_in_seconds = 10800 //} ?> It only took one whole day to figure out (as my php coding skills are weak). RD
  4. Thanks for the quick reply Thorpe, unfortunatly this does not appear to work. I wonder if the correct code (with your fix) is in the wrong location of the script. I have attached the script. If someone could look it over that would be great. Php is not one of my strong points... Thanks again [attachment deleted by admin]
  5. hi When running the comand below i get - Parse error: syntax error, unexpected T_STRING in line 16 (which is the command below) command - $time = exec("/usr/local/bin/ffmpeg -i \"" . $file . "\" 2>&1 | grep "Duration" | cut -d ' ' -f 4 | sed s/,//") I understand the error means a syntax error so where have I gone wrong ? I have spent most of this eveing trying to figure out where I may have gone wrong but to no avail. thanks Rich
  6. So no one knows then ? Ok lets look at this a different way. How do I parse php variables into a bash script ? I would assume it can be done.
  7. well i got a bit further and the php script was parsing variables to the bash file (rec-gen.sh). I changed something (cant remember now) and the variables are no longer being parsed through Could someone look this over and correct me PHP file :- <? // this is the script to schedule a tv recording using //'channelname' for channel name //'starttime' for start time //'duration' is the recording duration //full path to record video. $path = '/programs'; //listen for input figures for input $channelname = htmlspecialchars($_GET["channelname"]); $starttime = htmlspecialchars($_GET["starttime"]); $duration = htmlspecialchars($_GET["duration"]); $cmd = 'export PATH="/usr/bin/"; /home/user/recorder/rec-gen.sh $channelname $starttime $duration 2>&1'; echo "<pre>".shell_exec($cmd)."</pre>"; // the above variables are not parsed out to rec-gen.sh echo "should correctly display the listed variables ==== "; echo $channelname; echo $starttime; echo $duration; ?> bash file for now is set to just echo out the variables :- echo -e "var1: $1, var2: $2, var3: $3" If I run the php script as "http://server1/tvcreate.php?channelname=ITV1&starttime=01:00&duration=90" I get var1: , var2: , var3: --------------this is the output from the script file but shows no values should correctly display the listed variables ==== ITV10090 ------------this is the output from the php script. This clearly shows that the php file is correctly displaying the input but is not parsing the variables to the bash script. So what am i doing wrong ? Thanks in advance.
  8. UPDATE: I have now managed to parse information through to the tvcreate.php file (attached). My only problem now is that I try to use the command at (to schedule a bash file to be ran at a set time) and I get the error :- You do not have permission to use at. How can I get the at command to run from the www-data user ? [attachment deleted by admin]
  9. Hi all I am currenlty in the process of creating a media server on a linux machine using Apache and PHP scripting. I'd imagine lots of people have already done this. The media server that I made is slightly different though. On my media server all media files are in xvid format (which cannot be streamed). However my media server on user selection of film transcodes on the fly into flv format using FFmpeg to do the transcoding on the fly (takes a bit of horse power but works sweet). Client pcs use fwplayer to play the video content. So far so good, howerver I am creating a php web page to schedule tv recordings (since the server has a tv card) and this is where my problem is. I create a webpage to schedule a tv recording 'scheduletvrecording.php' and this parses out the channel name and start time, duration etc. This works by calling 'tvcreate.php' file the web link shows as :- http://10.0.0.1/tvcreate.php?channelname=bbc1&starttime=1200&duration=90 The 'tvcreate.php' doesnt seem to recognise the values I am parsing into it. for now tvcreate.php should just create a test.txt file with the settings that i parsed from the 'schduletvrecording.php' web page. I know php executes on the server so i will plan to create a shell file with the recording settings and get at to schedule a time to record. I have tried various work arounds but so far got no where. id love some help on this as I am really stumped now. Thanks in advance. Rich [attachment deleted by admin]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.