phpubuntuterminalavcodec

Run CLI commands using PHP script


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;
?>

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: