diddy1234 Posted March 31, 2010 Share Posted March 31, 2010 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 Link to comment https://forums.phpfreaks.com/topic/197173-parse-error-syntax-error-unexpected-t_string/ Share on other sites More sharing options...
trq Posted March 31, 2010 Share Posted March 31, 2010 $time = exec("/usr/local/bin/ffmpeg -i $file 2>&1 | grep Duration | cut -d ' ' -f 4 | sed s/,//"); Link to comment https://forums.phpfreaks.com/topic/197173-parse-error-syntax-error-unexpected-t_string/#findComment-1034966 Share on other sites More sharing options...
diddy1234 Posted April 1, 2010 Author Share Posted April 1, 2010 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] Link to comment https://forums.phpfreaks.com/topic/197173-parse-error-syntax-error-unexpected-t_string/#findComment-1035125 Share on other sites More sharing options...
diddy1234 Posted April 2, 2010 Author Share Posted April 2, 2010 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 Link to comment https://forums.phpfreaks.com/topic/197173-parse-error-syntax-error-unexpected-t_string/#findComment-1035847 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.