0

I'm trying to run ffmpeg via shell_exec on windows. My function isn't working (it doesn't execute, doesn't output a file, and doesn't output any results from shell_exec)

function convertFile($audio, $image)
{
    $output = str_replace(".mp3", ".mp4", $audio);
    $shellOutput = shell_exec("ffmpeg  -loop 1 -r 2 -i \"$image\" -i \"$audio\" -shortest -c:v libx264 -preset medium -tune stillimage -crf 28 -c:a copy $output");
    echo $shellOutput;

}

Apologies if this is something obvious. Thanks for any help!

1 Answer 1

3

Make sure that the web server user can read and execute ffmpeg, and that the binary is in its PATH. You can troubleshoot this by specifying the path to ffmpeg directly, e.g. /usr/bin/ffmpeg.

You could also consider adding 2>&1 to your command in order to redirect stderr to stdout, since ffmpeg will output debug messages via stderr, and you wouldn't see them otherwise. Or, disable output entirely. See here for more: Using FFmpeg from PHP scripts

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .