Cannot execute FFMPEG in php script

Discussion in 'PHP' started by arifsusam, Apr 15, 2007.

  1. #1
    Hello,

    I am trying to convert uploaded video files of various formats, automatically to the flash format.

    I use ffmpeg and php's "exec" command as below:

    <?php
    exec("ffmpeg -i clip_25.wmv -ar 22050 -ab 32 -f flv -s 320×240 destfile.flv");
    echo "Test OK.";
    ?>

    The script works fine on my local computer (meaning i can see 'Test OK')

    but when i upload and run it on the server 'Test ok' doesn't show up on the client's browser.
    Always a blank page. No matter what i write after of before the conversion line.

    However, the strange thing is, the file is perfectly converted, even on the server side.
    Which proves that ffmpeg and it's codecs are working fine.

    As the display is always a blank page,
    The fact is that the error is shown nowhere and that makes the page impossible to debug.

    The server is running php 4.1.1.1 and IIS 6.0.

    Any suggessions?
     
    arifsusam, Apr 15, 2007 IP
  2. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #2
    Try this:

    
    <?php
    if(exec("ffmpeg -i clip_25.wmv -ar 22050 -ab 32 -f flv -s 320×240 destfile.flv")){
    echo "Test OK.";
    }
    ?>
    
    PHP:
    Is the page loading or it just stops?

    Peace,
     
    Barti1987, Apr 15, 2007 IP
  3. 123GoToAndPlay

    123GoToAndPlay Peon

    Messages:
    669
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    123GoToAndPlay, Apr 15, 2007 IP
  4. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #4
    that's not how exec() works.

    If you wish for the user to see the output from the ffmpeg process ( assuming that process is running, I would check with a cmd first ), then use

    passthru('your ffmpeg command');

    if you would like to analyze the data from exec() you need to pass more than the command as parameters, exec has a possible three paramters, you need to pass at least two to be able to examine data, like so

    exec('your command', $output );

    in $output is an array of data, each key is a line number of output, the last line of output can be reached by using something like

    echo $output[ count($output) - 1 ];

    additionally, if your executing a system command and know the return value you need for success you can pass a exec like so :

    exec('your command', $output, $return );

    return would contain the integer returned from the execution of the program, I do not know what ffmpeg should or even if it will return anything, you should do some messing about.

    lastly, if you're using php5 you should pass the arguments by reference to exec [ &$args ], some configurations of php4 will produce errors when doing this and so I did not include it in examples.
     
    krakjoe, Apr 16, 2007 IP