PHP exec () does not execute FFmpeg [closed]

0

The following code works at the prompt but does not work in php, why?

$ffmpeg = 'C:/ffmpeg/bin/ffmpeg.exe';
$video = 'C:/absolute-path-para-o-video';
$output = 'C:/minha-pasta/thumbnail.jpg'; 
$cmd = '$ffmpeg -ss 3 -i $video -vf "select=gt(scene\,0.4)" -frames:v 5 -vsync vfr -vf fps=fps=1/600 $output &';

exec($cmd);

It works perfectly in Windows Prompt, however in PHP it does not run and it has this error in Apache

  

'$ ffmpeg' is not recognized as an internal or external command,       operable program or batch file.

    
asked by anonymous 30.11.2016 / 15:02

1 answer

3

This is a Windows error message saying that you could not run $ffmpeg .

I noticed that you put the full path to the executable in the first line, so I guess you just forgot to concatenate the variable with the rest of the command.

In fact, the variables $video and $output are also going as literals for the

It is also important to leave the variable $video inside double quotation marks, so as not to give an error if there are spaces in the file path.

$cmd = $ffmpeg. ' -ss 3 -i "' . $video . '" -vf "select=gt(scene\,0.4)" -frames:v 5 -vsync vfr -vf fps=fps=1/600 ' . $output . ' &';
    
30.11.2016 / 15:38