Page 1 of 1
exec() problem.
Posted: Fri Oct 03, 2008 6:02 pm
by loozi
hello, I'm having some problems with exec() under windows.
this code works perfectly
Code: Select all
$r2 = exec('start /D C:\php\ffmpeg\ /B ffmpeg.exe -i testvid.wmv -vhook "./vhook/imlib2.dll -i log.png" -y testvidwm.wmv , $f);
but when I try doing this:
Code: Select all
$vidf = 'testvid.wmv';
$wmvid = 'testvidwm.wmv';
$wmfile = 'log.png';
$r2 = exec('start /D C:\php\ffmpeg\ /B ffmpeg.exe -i $vidf -vhook "./vhook/imlib2.dll -i $wmfile" -y $wmvid' , $f);
it just stops working, any ideas? thanks in advance

Re: exec() problem.
Posted: Sat Oct 04, 2008 3:11 am
by loozi
no one knows? why isn't exec() working properly with variables?
Re: exec() problem.
Posted: Sat Oct 04, 2008 3:28 am
by Drachlen
Try this:
Code: Select all
$vidf = 'testvid.wmv';
$wmvid = 'testvidwm.wmv';
$wmfile = 'log.png';
$r2 = exec('start /D C:\php\ffmpeg\ /B ffmpeg.exe -i '.$vidf.' -vhook "./vhook/imlib2.dll -i '.$wmfile.'" -y '.$wmvid , $f);
The importance here is that when a variable is surrounded by single quotes ('...') it is not parsed as a variable.
Example 1:
Code: Select all
$var = "world";
echo 'hello $var';
Output:
Example 2:
Code: Select all
$var = "world";
echo "hello $var";
Output:
The solution in your case is to simply break the string up so the variables can be interpreted properly.
Hope that helps.
Re: exec() problem.
Posted: Sat Oct 04, 2008 3:34 am
by loozi
Nevermind! works perfectly, was doing something wrong. Thanks Drachlen

.
Re: exec() problem.
Posted: Sat Oct 04, 2008 3:43 am
by Drachlen
Run this and paste what it says
Code: Select all
$vidf = 'testvid.wmv';
$wmvid = 'testvidwm.wmv';
$wmfile = 'log.png';
$out = array();
$return = 0;
$r2 = exec('start /D C:\php\ffmpeg\ /B ffmpeg.exe -i '.$vidf.' -vhook "./vhook/imlib2.dll -i '.$wmfile.'" -y '.$wmvid , $out, $return);
echo "return: ".$return;
print_r($out);
Edit: Okay, great.
Good luck.