douchun5969 2019-03-15 18:28
浏览 158

根据操作系统在php中动态定义ffmpeg二进制路径

I'm trying to define the ffmpeg binaries path dynamically in php depending on OS...

Here's my code:

// Check if OS is Windows
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$OS = 'win';
// 'This is a server using Windows!';
}

require ABSPATH . '/vendor/autoload.php';

if($OS == 'win')
{
    $ffmpegpath = ABSPATH . 'FFMpeg/bin/ffmpeg.exe';
    $ffprobepath = ABSPATH . 'FFMpeg/bin/ffprobe.exe';
}

$ffmpeg = FFMpeg\FFMpeg::create(array(
'ffmpeg.binaries' => $ffmpegpath,
'ffprobe.binaries' => $ffprobepath,
'timeout' => 3600, // The timeout for the underlying process
'ffmpeg.threads' => 12, // The number of threads that FFMpeg should use
));

For some reason it doesn't work.

If I hard code the same paths within the ffmpeg construct function it does work.

Any ideas?

Thanks.

  • 写回答

1条回答 默认 最新

  • duangan4406 2019-03-15 19:19
    关注

    Nevermind, I found the problem, it was a pesky little GLOBAL var bug in my code. Apologies for the question, I can't delete it. Thanks.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考