Question

I want to convert a flv file to mpg using avconv it is run successively using terminal. My problem is run command using php script. I write a code but i did not got result. My code as follows

<?php
$cmd="avconv -i http://localhost/test3/a.flv http://localhost/test3/intermediate1.mpg";
$results = shell_exec($cmd.'2>&1');
?>  

I tried also following code but no luck

<?php
$cmd="avconv -i /home/elby/workspace/test3/a.flv /home/elby/workspace/test3/intermediate1.mpg";
$results = shell_exec($cmd.'2>&1');
echo $results;
?>
Was it helpful?

Solution

First of all, the first execute example is non-sense, according to manual of avconv it takes 2 parameters:

avconv [global options] [[infile options][-i infile]]... {[outfile options] outfile}...

And you cannot just tell program to save file to http protocol like that.

The second invocation... There are several possible issues with that:

  • Are you running script from web or from CLI? Webserver may (and probably will) use different user which won't have an access to folders
  • PHP scripts have timeout (default 30 seconds) and video converting takes a lot more
  • PHP may have shell_exec disabled
  • PHP may have safe_mode turned on
  • PHP may have a problem with PATH environment variable, try using absolute path
  • With disabled error_reporting you may already have error logged but not displayed

OTHER TIPS

$cmd="avconv -i /home/elby/workspace/test3/a.flv /home/elby/workspace/test3/intermediate1.mpg";
$results = shell_exec($cmd.' 2>&1');
echo $results;

Use absolute path to avconv.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top