sh: /usr/bin/ffmpeg: not found



我正在尝试使用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返回一个空数组。

您问题的答案可能比预期的要简单。您正在检查/usr/local/bin /usr/bin。有多种解决方案。

  1. 您可以运行$ whereis ffmpeg并查看所获得的内容。根据结果,更改您的$cmd变量。如果whereis不返回,那么您的系统将不知道它在哪里。您可以将其添加到$PATH环境变量中,然后重试。

  2. 您可以尝试运行$ find /usr -name "ffmpeg"或类似的东西。通过确保安装此程序,它将帮助您更快地解决此问题。

  3. 如果有某种限制拒绝Apache访问/使用FFMPEG的能力,则可以随时将其存储在文档根部内的bin文件夹中。(类似/path/to/doc/doc/root/bin/ffmpeg )我以前已经这样做了,所以我知道它有效。


如果您发现 ffmpeg 实际上位于/usr/local/bin中,那么您应该尝试将$cmd更改为:

$cmd = '/usr/local/bin/ffmpeg';

有问题!

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] =>
)

最新更新