PHP exec does not execute command

I used php exec to execute the FFmpeg command, but it doesn’t wake up when I open it in a browser. But when I run this php file script in the terminal, it works fine. And my php safe mode is off. please help me solve this. my php code

<?php
$output=exec("ffmpeg -f image2 -i /home/phedra/imgs/image/img%03d.png -r 12 -s 610x489 /home/phedra/imgs/video/out.avi", $out);
echo $out;
echo $output;
?>
+3
source share
4 answers

try specifying the full path where the ffmpeg application is located.

eg.

/usr/bin/ffmpeg

So your function might look like this:

$output=exec("/usr/bin/ffmpeg -f image2 -i /home/phedra/imgs/image/img%03d.png -r 12 -s 610x489 /home/phedra/imgs/video/out.avi", $out);

You should check where "ffmpeg" is.

+3
source

I had this problem, and it turned out that this was Apache permission in the public directory.

: Ubuntu 14 AWS

FFmpeg /var/www/* www-data.

sudo chown -R www-data:root /var/www

( www-data)

, , URL (Apache)

// test.php

$run = system("/opt/ffmpeg/bin/ffmpeg -i /var/www/html/input.mp4 -vf scale=640:480 /var/www/html/output.mp4 &");

if($run) {
    echo "success";
} else {
    echo "failed";
}

/opt/ffmpeg/bin/ffmpeg FFmpeg. , /usr/bin/ffmpeg - . , locate ffmpeg , .

.mp4 , output.mp4 .

: php test.php - : yourwebsite.com/test.php -

+1

: , COMMAS. :

$output=exec('"/usr/bin/ffmpeg" -f image2 -i /home/phedra/imgs/image/img%03d.png -r 12 -s 610x489 /home/phedra/imgs/video/out.avi', $out);
0

@Arfeen, , ffmpeg, "/usr/bin/ffmpeg" .

First find your ffmpeg with the command:

which ffmpeg

The result in my case:

/ Usr / local / bin / ffmpeg

Then go back to your php code and replace "ffmpeg" in the command with the ffmpeg path (in my case, it is / usr / local / bin / ffmpeg).

0
source

All Articles