422,754 Members | 2,224 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,754 IT Pros & Developers. It's quick & easy.

Urgent help please -- ffmepg proc_open return 127, no execution,

P: n/a
xhe
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($str,$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_blocking($pipes[1],false);
stream_set_blocking($pipes[2],false);

fclose($pipes[1]);
fclose($pipes[2]);
$code=proc_close($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
Jun 2 '08 #1
Share this Question
Share on Google+
6 Replies


P: n/a
xhe schreef:
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($str,$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_blocking($pipes[1],false);
stream_set_blocking($pipes[2],false);

fclose($pipes[1]);
fclose($pipes[2]);
$code=proc_close($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?
Hi,

Hard to tell, but here a few, not very original, suggestions:
--/home/transla1/bin/ffmpeg actually exists on your ISP? Are the
rights set right for the apache-user too?
--Does your ISP's php.ini maybe prevent you from executing in some
directories, or block exec()/proc_open()/etc?
--Do you have shell access on your ISP? If so, can you run it from the
shell as www-data/apache? (Possibly you need to ask your ISP, since I
don't expect you can sudo su www-data on a shared environment.)
--Make sure you see all errors, notices, etc.

Also, if you haven't tried already, Google: php ffmpeg error 127
It has a few hits that seems to be relevant, but which I didn't read in
detail. ;-)

Regards,
Erwin Moller
>
Thanks in advance
Jun 2 '08 #2

P: n/a
On 16 May, 05:46, xhe <hexuf...@gmail.comwrote:
I am using ffmpeg to convert video, this is a sample script:
<snip>
>
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.
999 times out of 1000 this is due to permissions problems - either
your webserver uid can't exec ffmpeg or it can't write the output.
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.
It highly possible that your shared host webserver is running chroot -
the binary will have a completeky different path if the webserver can
see it at all (more likely it, and its required libs, will be outside
the jail).
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?
Write some PHP code to check the executable is where you think it is,
with exec permissions, that the source file is where you think it is
with read permissions and that the destination is where you think it
is with permisions and run from a browser.

C.
Jun 2 '08 #3

P: n/a
xhe
Thanks for replying.
1. I wrote script to check the executable, and the file is executable,
readable and writable
2. I run it in cron task, and got the error is
/home/transla1/bin/ffmpeg: error while loading shared libraries:
libavdevice.so.52: cannot open shared object file: No such file or
directory
But the shared object exist. I added the path to include_path into the
php.ini, still wrong.
Now the thing is it can be executed in commandline, but not in script.
So I really got no idea how to solve it

Help will be highly appreciated.

Frank


On May 16, 9:18 am, "C. (http://symcbean.blogspot.com/)"
<colin.mckin...@gmail.comwrote:
On 16 May, 05:46, xhe <hexuf...@gmail.comwrote:
I am using ffmpeg to convert video, this is a sample script:
<snip>
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.

999 times out of 1000 this is due to permissions problems - either
your webserver uid can't exec ffmpeg or it can't write the output.
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.

It highly possible that your shared host webserver is running chroot -
the binary will have a completeky different path if the webserver can
see it at all (more likely it, and its required libs, will be outside
the jail).
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?

Write some PHP code to check the executable is where you think it is,
with exec permissions, that the source file is where you think it is
with read permissions and that the destination is where you think it
is with permisions and run from a browser.

C.
Jun 2 '08 #4

P: n/a
xhe wrote:
On May 16, 9:18 am, "C. (http://symcbean.blogspot.com/)"
<colin.mckin...@gmail.comwrote:
>On 16 May, 05:46, xhe <hexuf...@gmail.comwrote:
>>I am using ffmpeg to convert video, this is a sample script:
<snip>
>>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.
999 times out of 1000 this is due to permissions problems - either
your webserver uid can't exec ffmpeg or it can't write the output.
>>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.
It highly possible that your shared host webserver is running chroot -
the binary will have a completeky different path if the webserver can
see it at all (more likely it, and its required libs, will be outside
the jail).
>>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?
Write some PHP code to check the executable is where you think it is,
with exec permissions, that the source file is where you think it is
with read permissions and that the destination is where you think it
is with permisions and run from a browser.
Thanks for replying.
1. I wrote script to check the executable, and the file is executable,
readable and writable
Could you tell us exactly how you checked this? And for which user?
2. I run it in cron task, and got the error is
/home/transla1/bin/ffmpeg: error while loading shared libraries:
libavdevice.so.52: cannot open shared object file: No such file or
directory
But the shared object exist. I added the path to include_path into the
php.ini, still wrong.
php has nothing to do with what happens in executables on system calls.
Adding it to a php.ini path will do nothing, you'll have to tell ffmpeg.

Now the thing is it can be executed in commandline, but not in script.
So I really got no idea how to solve it
Can you run it at the server, logging in by ssh, from the command line?
If so, it's probably still a rights issue of the webserver vs. the ssh
user (vs. the cron user). When in doubt, ask the hoster. If not, and the
only command line it works on is at your home, you might ask the ffmpeg
people how they'd solve the error you got back from ffmpeg by cron job.
--
Rik Wasmus
....spamrun finished
Jun 2 '08 #5

P: n/a
xhe
Thanks again for replying.

I found this is the hosting provider issue. I set the environment
variables in .bash_profiles, but those setting can not be recognized
by the web server. and all the self-installed shared object has been
strictly filtered out because

when I use
system('set'),
all those environment setting is not included at all.

So my question now become are there anyway to include
the .bash_profile setting into the web server setting by php?

Thanks

On May 16, 11:24 am, Rik Wasmus <luiheidsgoe...@hotmail.comwrote:
xhe wrote:
On May 16, 9:18 am, "C. (http://symcbean.blogspot.com/)"


<colin.mckin...@gmail.comwrote:
On 16 May, 05:46, xhe <hexuf...@gmail.comwrote:
>I am using ffmpeg to convert video, this is a sample script:
<snip>
>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.
999 times out of 1000 this is due to permissions problems - either
your webserver uid can't exec ffmpeg or it can't write the output.
>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.
It highly possible that your shared host webserver is running chroot -
the binary will have a completeky different path if the webserver can
see it at all (more likely it, and its required libs, will be outside
the jail).
>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?
Write some PHP code to check the executable is where you think it is,
with exec permissions, that the source file is where you think it is
with read permissions and that the destination is where you think it
is with permisions and run from a browser.
Thanks for replying.
1. I wrote script to check the executable, and the file is executable,
readable and writable

Could you tell us exactly how you checked this? And for which user?
2. I run it in cron task, and got the error is
/home/transla1/bin/ffmpeg: error while loading shared libraries:
libavdevice.so.52: cannot open shared object file: No such file or
directory
But the shared object exist. I added the path to include_path into the
php.ini, still wrong.
php has nothing to do with what happens in executables on system calls.
Adding it to a php.ini path will do nothing, you'll have to tell ffmpeg.
Now the thing is it can be executed in commandline, but not in script.
So I really got no idea how to solve it

Can you run it at the server, logging in by ssh, from the command line?
If so, it's probably still a rights issue of the webserver vs. the ssh
user (vs. the cron user). When in doubt, ask the hoster. If not, and the
only command line it works on is at your home, you might ask the ffmpeg
people how they'd solve the error you got back from ffmpeg by cron job.
--
Rik Wasmus
...spamrun finished

Jun 2 '08 #6

P: n/a
On 16 May, 17:28, xhe <hexuf...@gmail.comwrote:
Thanks again for replying.

I found this is the hosting provider issue. I set the environment
variables in .bash_profiles, but those setting can not be recognized
by the web server. and all the self-installed shared object has been
strictly filtered out because

when I use
system('set'),
all those environment setting is not included at all.

So my question now become are there anyway to include
the .bash_profile setting into the web server setting by php?

Thanks
2. I run it in cron task, and got the error is
/home/transla1/bin/ffmpeg: error while loading shared libraries:
libavdevice.so.52: cannot open shared object file: No such file or
directory
Write a shell script to call ffmpeg. You could invoke
your .bash_profile directly but a better solution would be to printenv
and paste the results in the shell script.

(BTW: We're now way OT for PHP)

C.
Jun 2 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.