Page 1 of 1

[partially solved] convert video (system cmd problem)

Posted: Sun Aug 19, 2007 7:50 pm
by benyboi
hello,

im trying to use ffmpeg...

using this php code for running commands works:

Code: Select all

<?php
echo '<pre>';

// Outputs all the result of shellcommand "ls", and returns
// the last output line into $last_line. Stores the return value
// of the shell command in $retval.
$last_line = system('ipconfig', $retval);

// Printing additional info
echo '
</pre>
<hr />Last line of the output: ' . $last_line . '
<hr />Return value: ' . $retval;
?>
but when i put
D:\inetpub\software\ffmpeg\bin\ffmpeg.exe -i test.wmv out.avi
for the command it just wont run?

im running latest apache, php and mysql.

whats wrong?

thanks,
ben

Posted: Mon Aug 20, 2007 6:59 am
by benyboi
i tried setting permissions on ffmpeg.exe but that doesnt sort it...

Posted: Mon Aug 20, 2007 7:06 am
by VladSun
1. What do you have in the error logs?
2. Use full path for test.wmv and out.avi files.

Posted: Mon Aug 20, 2007 7:13 am
by benyboi
noooo way!

you are a genious! it works :D

wait - how can i make it run in the background? so that the php loads even thought the video is still converting. and so i dont get the 30 second limit thing (i dont want to change that in php.ini)

thanks for you help

Posted: Mon Aug 20, 2007 7:32 am
by VladSun
Untested!

Code: Select all

 
<?php
 
  $runCommand = "YOUR COMMAND AND ITS PARAMS HERE";
 
  if(isset($_SERVER['PWD'])//*nix (aka NOT windows)
  {
    $nullResult = `$runCommand > /dev/null &`;
  }
  else //windowz
  {
    $WshShell = new COM("WScript.Shell");
    $oExec = $WshShell->Run($runCommand, 7, false);
  }
 
?>
 

Posted: Mon Aug 20, 2007 8:24 am
by feyd
I would check PHP_OS (it's a constant) over a $_SERVER variable. ;)

Posted: Mon Aug 20, 2007 8:33 am
by VladSun
feyd wrote:I would check PHP_OS (it's a constant) over a $_SERVER variable. ;)
Yeah, it would be better. That was the first example found by google ;)