PHP的exec()不执行FFmpeg的命令 [英] PHP's exec() not executing command for FFmpeg
问题描述
我在我的服务器上安装了ffmpeg,它通过我的终端工作正常。我能够成功地将文件转换为webm格式,所以我确定安装是正常的。我也确定我只有一个安装的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.
当我尝试通过PHP通过PHP的exec()转换文件时出现问题。当我运行相同的命令,我在终端,没有任何反应。我围着stackoverflow和网络的其他部分寻求帮助。我试过这个看看输出:
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";
输出为:output is:exit code:127
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"
我尝试用FFmpeg的完整路径替换ffmpeg,但是没有工作。
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?
谢谢!
推荐答案
我有类似的问题,从蚂蚁目标执行从PHP。我不能得到整个输出从ant命令只有前几行和蚂蚁目标没有执行。换句话说是部分执行。
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.
使用bellow命令我设法运行它,但命令的输出附加到log_file.log。
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);
希望这会为你工作。
这篇关于PHP的exec()不执行FFmpeg的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!