TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   ffmpeg converting using a cronjob (http://www.talkphp.com/general/2800-ffmpeg-converting-using-cronjob.html)

oMIKEo 05-13-2008 09:46 PM

ffmpeg converting using a cronjob
 
Hi,

I'm making some progress with ffmpeg but need some help working out why i cant run the same code using php as when i run in ssh.

Here is the php:
PHP Code:

$dir_root "../../var/www/html/uploads/media/";
$temp_new substr($o_newname0strripos($o_newname'.'));

$output exec ("ffmpeg -i ".$dir_root.'o_'.$o_newname." -s qvga -y ".$dir_root.'n_'.$temp_new.".flv");
echo(
$output); 

its a bit of a mess but its basically getting the input video, setting the size to 320x240 (qvga) and then outputting it as a .flv. When i use that output in ssh it works fine but when i run the above script it doesnt seem to do anything.

ffmpeg is located: /usr/bin/ffmpeg
website is location: /var/www/html/

Here is an example of what i paste into ssh:
Code:

ffmpeg -i ../../var/www/html/uploads/media/o_l2mWwMYOmDhuieDpNnb.avi -s qvga -y ../../var/www/html/uploads/media/n_l2mWwMYOmDhuieDpNnb.flv
is there any way to get some error checking in there or get an output back from the exec/ffmpeg command?

Regards,
Michael

drewbee 05-14-2008 02:03 PM

exec will only return the last line which in this case might be a blank line.

Is safemode on? If safemode is on, exec will not work.


You could also try PHP: shell_exec - Manual

I believe shell_exec returns all output as a string.

drewbee 05-14-2008 02:10 PM

Also, after reading the manual, exec can return values, you just need to specify it;
PHP Code:

exec('whoami'$array$returnStatus);
echo 
print_r($array); 


oMIKEo 05-14-2008 04:24 PM

ok i changed the script to do this:

PHP Code:

$output exec ("ffmpeg -i ".$dir_root.'o_'.$o_newname." -s qvga -y ".$dir_root.'n_'.$temp_new.".flv",$arrayOutput$returnOutput);

echo 
print_r($arrayOutput); 
echo 
'<br />';
echo 
print_r($returnOutput); 

and got the following:
PHP Code:

Array ( ) 1
11 

Any idea what that means?

I then tried this:
PHP Code:

$output shell_exec("ffmpeg -i ".$dir_root.'o_'.$o_newname." -s qvga -y ".$dir_root.'n_'.$temp_new.".flv");
echo 
"<pre>$output</pre>"

i didnt get an onscreen output but the code read <pre></pre> thats was it.

Thanks for your help!

PS: safe mode is not turned on.

drewbee 05-14-2008 07:23 PM

Hmm, not sure.

Does the PHP user have access to run ffmpeg? There may be a potential permissions problem.

That does tell me that nothing is being returned from the command line though;

What happens when you do just exec 'whoami'? See if that returns any information in the array.


All times are GMT. The time now is 09:42 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0