Jump to content

Parse error: syntax error, unexpected T_STRING


diddy1234

Recommended Posts

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

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]

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.