我正在尝试使用shell_exec或exec从PHP执行ffmpeg但它失败了。为什么会这样?命令/usr/bin/ffmpeg
在终端上运行,所以我尝试了
<?php
$cmd = "/usr/bin/ffmpeg";
exec($cmd." 2>&1", $out, $ret);
if ($ret){
echo "There was a problem!\n";
print_r($out);
}else{
echo "Everything went better than expected!\n";
}
?>
我继续
There was a problem! Array ( [0] => sh: /usr/bin/ffmpeg: not found )
非常感谢任何帮助。
可执行文件的权限是
-rwxr-xr-x 1 root root 106552 Jun 12 09:53 ffmpeg
将which /usr/local/bin/ffmpeg
运行到$ cmd会返回一个空数组。
答案 0 :(得分:5)
您的问题的答案可能比预期的要简单。您正在检查/usr/local/bin
和 /usr/bin
。有多种解决方案。
您可以运行$ whereis ffmpeg
并查看所获得的内容。根据结果,更改您的$cmd
变量。如果whereis
没有返回任何内容,那么您的系统就不知道它在哪里。您可以将其添加到$PATH
环境变量中,然后重试。
您可以尝试运行$ find /usr -name "ffmpeg"
或类似的东西。通过确保安装此程序,它将帮助您更快地解决此问题。
如果存在某种限制,拒绝apache访问/使用ffmpeg的能力,您可以随时将其存储在文档根目录中的bin文件夹中。 (比如 / path / to / doc / root / bin / ffmpeg )之前我已经这样做了所以我知道它有效。
如果您发现 ffmpeg 实际位于/usr/local/bin
,那么您应该尝试将$cmd
更改为:
$cmd = '/usr/local/bin/ffmpeg';
答案 1 :(得分:-1)
有问题!
Array (
[0] => FFmpeg version 0.6.5, Copyright (c) 2000-2010 the FFmpeg developers
[1] => built on Jan 29 2012 17:52:15 with gcc 4.4.5 20110214 (Red Hat 4.4.5-6)
[2] => configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64
--mandir=/usr/share/man --incdir=/usr/include --disable-avisynth
--extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC'
--enable-avfilter --enable-avfilter-lavf --enable-libdc1394 --enable-libdirac
--enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libgsm
--enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb
--enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora
--enable-libx264 --enable-gpl --enable-nonfree --enable-postproc --enable-pthreads
--enable-shared --enable-swscale --enable-vdpau --enable-version3 --enable-x11grab
[3] => libavutil 50.15. 1 / 50.15. 1
[4] => libavcodec 52.72. 2 / 52.72. 2
[5] => libavformat 52.64. 2 / 52.64. 2
[6] => libavdevice 52. 2. 0 / 52. 2. 0
[7] => libavfilter 1.19. 0 / 1.19. 0
[8] => libswscale 0.11. 0 / 0.11. 0
[9] => libpostproc 51. 2. 0 / 51. 2. 0
[10] => Use -h to get full help or, even better, run 'man ffmpeg'
[11] => Hyper fast Audio and Video encoder
[12] => usage: ffmpeg [options] [[infile options] -i infile]...
{[outfile options] outfile}...
[13] =>
)