解决PHP's exec() not executing command for FFmpeg
I have installed ffmpeg on my server and it works fine via my terminal. I'm able to successfully convert a file to webm format, so I'm sure the installation is fine. I'm also sure that I only have one installation of ffmpeg installed on my machine.
A problem arises when I try to convert files through PHP via PHP's exec(). When I run the same commands, I ran in the terminal, nothing happens. I looked around stackoverflow and other parts of the net for some help. I tried this to see the output:
exec($cmd, $out, $rv); echo "output is:\n".implode("\n", $out)."\n exit code:$rv\n";
The output is: "output is: exit code:127"
The command I'm using is in this format:
ffmpeg -i "sample.mov" -vcodec libvpx -r 30 -b "644k" -acodec libvorbis -ab 128000 -ar "44100" -ac 2 -s "352x198" "sample.webm"
I've tried replacing "ffmpeg" with the full path to FFmpeg but that did not work.
Why isn't the script running the command correctly and converting the files?
Thank you!php ffmpeg command exec
this question edited Aug 30 '11 at 6:34 Frankie 16.7k 7 52 94 asked Aug 30 '11 at 6:17 tundoopani 82 1 18 2 It's "¿Por qué?" (two words) ;-P – Álvaro González Aug 30 '11 at 6:21 Search for
ffmpeg status 127 error. Does your command run ok without php? – xdazz Aug 30 '11 at 6:22 facepalm. Thanks, I forgot :p – tundoopani Aug 30 '11 at 6:27 The command works perfectly in my terminal. – tundoopani Aug 30 '11 at 6:28 Possible duplicate of stackoverflow.com/questions/4828083/ffmpeg-php-error-code-12??7 – Bailey Parker Aug 30 '11 at 6:29 | show more comments
I have similar problem with ant target executions from php. I can't get whole output from ant command only first few rows and ant target was not executed. In other words is partial executed.
With bellow command I've managed to run it but output of the command is append to log_file.log.
$commandString = 'you_command_here >> log_file.log 2>&1 &'; $command = exec($commandString);
Hope this will work for you.
this answer edited Sep 16 '11 at 6:17 answered Aug 30 '11 at 6:42 glg 452 3 15
Error code 127 means the executable (ffmpeg) couldn't be found. Try specifying the whole path (you can that out find in your terminal with
which ffmpeg) or compare the value of the
PATH environment variable in your php script and terminal.
this answer answered Aug 30 '11 at 6:22 phihag 148k 36 285 331 1 "I've tried replacing "ffmpeg" with the full path to FFmpeg but that did not work." – tundoopani Aug 30 '11 at 6:25
- 1FFMPEG 和 FFMPEG-PHP 的安装
- 2ffmpeg php win32扩展的初步调试 php_ffmpeg.dll下载
- 5ffmpeg ffmpeg-php 安装及出错解决办法()