tags:

views:

82

answers:

2

I have an exec function in php file that execs a bash script. It script calls fmpeg to transcode a video file.

How can I know when transcoding is finish??

$script = "/opt/lamp../name.sh"
exec("$script $videoIn $id")

I will try using next code but it doesn't workd.

if (exec("$script $videoIn $id"))
{
//print on screen that the video has been transcoded
}
A: 

Your php script waits for the exec'd command to be finished before going on.

exec does not return the command's return value.

string exec  (  string $command  [,  array &$output  [,  int &$return_var  ]] )

you have to provide a var where that value will be written.

Lo'oris
If I have a php code, next line after exec, when will be run? When exec() is finish?
skiria
A: 

The function exec() will return when the executed command is finished. My guess is that the command fails somehow (possibly because you're not using escapeshellcmd() and escapeshellarg()).

soulmerge
Where I have to use escapeshellcmd()?
skiria
ok solved. the video input file hasn't execution permisses. Thanks
skiria
@skiria: If my answer solved your problem, you should *accept* it (i.e. press the hollow tick left to it.) If you don't accept answers to your questions, less and less people will be ready to help you.
soulmerge