0

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;
?>
j0k
  • 22,600
  • 28
  • 79
  • 90
Elby
  • 1,624
  • 3
  • 23
  • 42
  • Any more info? How does the code fail? Any error messages? – Vyktor Dec 03 '12 at 10:37
  • 1
    Have you checked to see if shell_exec works at all for you?, try something like `echo shell_exec('echo foo');` Depending on configuration, shell functions can be disabled. – EJTH Dec 03 '12 at 10:44
  • There is a blank missing before `2>&1`, resulting in a filename `intermediate1.mpg2`in the command. – Gerald Schneider Dec 03 '12 at 10:47

2 Answers2

3

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
Vyktor
  • 20,559
  • 6
  • 64
  • 96
0
$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.

Niclas Larsson
  • 1,317
  • 8
  • 13