【问题标题】:sting up ffmpeg to work in XAMPP让 ffmpeg 在 XAMPP 中工作
【发布时间】:2012-06-01 09:19:43
【问题描述】:

我正在尝试弄清楚如何在带有 XAMPP 的 Windows 64 上安装和使用 ffmpeg。

我有 flow this tutorial 并安装了 ffmpeg-php 库,我可以在 phpinfo() 中看到扩展。

现在我将我的 ffmpeg.exe 放在站点根文件夹中并运行这个 php 脚本:

extension_loaded('ffmpeg') or die('Error in loading ffmpeg');

function convertTo( $input, $output ) 
{
echo $cmd = "ffmpeg -i $input $output";
$outputData = array();
exec( $cmd , $outputData);
echo "<br/>";
print_r($outputData);
}

convertTo( "input.mp4", "output.flv" );

我得到这个输出:

ffmpeg -i input.mp4 output.flv
Array ( )

但没有编码文件。 我的 php 安全模式已关闭,电影文件也在根文件夹中。

工作场所信息:

  • win7 64位
  • XAMPP 1.7.2
  • Apache 2.2
  • php 5.3.5

我们将不胜感激。

【问题讨论】:

  • 启用error.log和错误报告。如果使用 cmdline 工具,为什么要安装 PHP 扩展?
  • 错误报告已打开,error_get_last() 没有输出,可能是目录有问题?所有文件都在同一个站点根文件夹中。

标签: php ffmpeg xampp ffmpeg-php


【解决方案1】:

对于windows,使用ffmpeg.exe并修改代码

function convertTo( $input, $output ) 
{
echo $cmd = "c:\\ffmpeg\\ffmpeg -i $input $output";
$outputData = array();
exec( $cmd , $outputData);
}

convertTo( "d:\www\input.mp4", "d:\www\output.flv" );

$outputdata 不返回任何东西,所以不要期望输出。

【讨论】:

  • 我需要在服务器上使用这个脚本,所以我只能使用根目录。我所有的文件都在 C:\xampp\htdocs\ffmpeg-test -ffmpeg.exe -input.mp4 -script.php
  • 对于上述脚本 ffmepeg.exe 可能在不同的位置,源和目标可能在不同的位置。根据需要更改脚本中的路径。
  • 我根据答案移动了文件,但仍然注意到发生了。我从here 下载了 exe 并选择了 64-bit Builds (Static)
  • 感谢大家,我已经玩过这些目录并让它从根文件中工作。
猜你喜欢
  • 2015-03-27
  • 2011-04-26
  • 1970-01-01
  • 2012-05-08
  • 2014-07-30
  • 2013-11-30
  • 2012-10-11
  • 2021-10-01
  • 2011-10-31
相关资源
最近更新 更多