I am using ffmpeg to convert video, this is a sample script:
$str='/home/transla1/bin/ffmpeg -i /home/transla1/public_html/
cybertube/web/uploads/video/31_AK000005.AVI -s 240x180 -b 100k -ar
22050 -y /home/transla1/public_html/cybertube/web/uploads/video/
generated/31_70_AK000005. AVI.flv
';
//exec($str);
runExternal($st r,$code);
echo $code ;
function runExternal( $cmd, &$code ) {
// echo "command" . $cmd;
$descriptorspec = array(
0 =array("pipe", "r"), // stdin is a pipe that the
child will read from
1 =array("pipe", "w"), // stdout is a pipe that the
child will write to
2 =array("pipe", "w") // stderr is a file to write to
);
$pipes= array();
$process = proc_open($cmd, $descriptorspec , $pipes);
$output= "";
if (!is_resource($ process)) return false;
#close child's input
fclose($pipes[0]);
stream_set_bloc king($pipes[1],false);
stream_set_bloc king($pipes[2],false);
fclose($pipes[1]);
fclose($pipes[2]);
$code=proc_clos e($process);
}
It works fine in Command line, when I use "php test.php", it runs
well. But in browser, just gave error 127. I tried to use system() or
exec(), both works in command line only, not in browser.
I can run this script in my local computer under apache, no problem,
but when I put it in shared hosting server, it failed to run in
browser.
I guess the script is not executed or the script just skipped.
I am really in urgent need of this solution. Can anyone give me any
help on how to deal with it?
Thanks in advance
$str='/home/transla1/bin/ffmpeg -i /home/transla1/public_html/
cybertube/web/uploads/video/31_AK000005.AVI -s 240x180 -b 100k -ar
22050 -y /home/transla1/public_html/cybertube/web/uploads/video/
generated/31_70_AK000005. AVI.flv
';
//exec($str);
runExternal($st r,$code);
echo $code ;
function runExternal( $cmd, &$code ) {
// echo "command" . $cmd;
$descriptorspec = array(
0 =array("pipe", "r"), // stdin is a pipe that the
child will read from
1 =array("pipe", "w"), // stdout is a pipe that the
child will write to
2 =array("pipe", "w") // stderr is a file to write to
);
$pipes= array();
$process = proc_open($cmd, $descriptorspec , $pipes);
$output= "";
if (!is_resource($ process)) return false;
#close child's input
fclose($pipes[0]);
stream_set_bloc king($pipes[1],false);
stream_set_bloc king($pipes[2],false);
fclose($pipes[1]);
fclose($pipes[2]);
$code=proc_clos e($process);
}
It works fine in Command line, when I use "php test.php", it runs
well. But in browser, just gave error 127. I tried to use system() or
exec(), both works in command line only, not in browser.
I can run this script in my local computer under apache, no problem,
but when I put it in shared hosting server, it failed to run in
browser.
I guess the script is not executed or the script just skipped.
I am really in urgent need of this solution. Can anyone give me any
help on how to deal with it?
Thanks in advance
Comment