【问题标题】:Ffmpeg installation And Converting VIdeo's:Ffmpeg 安装和转换视频的:
【发布时间】:2011-08-24 05:49:03
【问题描述】:

我对安装 ffmpeg-php 进行视频转换的指令感到困惑...有一些 guide us 可以下载并将文件放在特定文件夹中然后转换文件,但有些是通过 another way 指示的,您必须在其中下载ffmpeg.exe 并将其放置在本地,然后从 php 调用它来转换文件.....

那么哪一个是最好的以及如何安装它....?????

现在我下载 ffmpeg 并执行此脚本但无法正常工作,并授予权限...

$ffmpeg = "ffmpeg/ffmpeg.exe";
$desvfile = $_POST['file'];
$curr_dir = dirname(__FILE__);
$flvfile = $curr_dir."/converted/new1.flv";

if(file_exists($ffmpeg)){
    $cmd = "ffmpeg/ffmpeg.exe -i ".$desvfile." -ar 22050 -ab 32 -f flv -s 320×240 ".$flvfile; 
    exec($cmd, $output); 
    echo "executed command: [".$cmd."] with result: ".print_r($output, true)."<br>\n";
    echo "Successfully video Converted, to video.flv";
}
else{
    echo "There is some problem during converting!";
}

有什么方法可以测试 => exec(ffmpeg) 功能....?????

更新!

if(file_exists($desvfile)){
    echo "Destination file Exist. <br />";
    $cmd = "$ffmpeg -i '$desvfile' -ar 22050 -ab 32 -f flv -s 320×240 '$flvfile'"; 
    exec(escapeshellcmd($cmd), $output); 
    echo "executed command: => [".$cmd."] <br />with result: => ".print_r($output, true)."<br>\n";
    echo "Successfully video Converted, to video_converted.flv";
 }
else{
    echo "There is some problem during converting!";exit;
}

这给了我输出,,,但不执行要转换的视频....

输出:

// Destination file Exist.

// executed command: => [/var/www/html/test_site/converter/ffmpeg/ffmpeg.exe -i '/var/www/html/test_site/converter/uploads/Gazzump.com - YouTube - Anders And.avi' -ar 22050 -ab 32 -f flv -s 320×240 '/var/www/html/test_site/converter/converted/new1.flv']

// with result: => Array ( )

// Successfully video Converted, to video_converted.flv

【问题讨论】:

  • 天啊,我想知道为什么。不,不是真的,看起来您正在尝试在 Linux 中运行 Windows 可执行文件。这当然行不通(是的,Wine 存在,但是当您在 Linux 上获得本机支持时,谁会如此疯狂地在 Wine 中运行可执行文件)。所以:只需为你的 Linux 发行版安装 ffmpeg 包,它就可以工作了。
  • @wimvds,是的,我也知道操作系统问题有些问题,但我无法识别并且不知道如何解决它。你愿意指导我在 ubunto 上运行吗...这个脚本...
  • 在 Ubuntu 上,发出 sudo apt-get install ffmpeg(在 cli 上),应该安装 ffmpeg(前提是您启用了 Universe 和 Multiverse 存储库)。然后你应该能够只使用exec('ffmpeg -i ... '); 来转码文件。有关更多信息(即安装标准构建中缺少的额外编解码器),请参阅Ubuntu Wiki - ffmpeg 页面。
  • @wimvds,我按照您的步骤操作但仍然无法正常工作,而 ffmpeg 是从 cli 安装的...
  • 那么ffmpeg不在webuser的路径中,所以要么将该路径添加到webuser的PATH var中,要么在调用exec时指定完整路径。要定位 ffmpeg,只需从 cli 执行 which ffmpeg

标签: php file-upload ffmpeg video-processing


【解决方案1】:

我一直发现使用exec() 调用FFMPEG 更容易。 FFMPEG 的 exe 版本比 PHP 扩展更容易找到。此方法没有安装过程...只需将 EXE 放在服务器上的某个位置,PHP 正在执行的任何帐户都可以访问该位置。

真的没有“最好的方法”。访问 FFMPEG 的两种方法都会产生相同的输出。

【讨论】:

  • 1:下载 FFMPEG 的二进制文件 (ffmpeg.zeranoe.com/builds)。 2:将ffmpeg.exe复制到某个文件夹。 3:在您的 PHP 脚本中,使用 exec("C:\somefolder\ffmpeg.exe someparameters"); 之类的名称调用它
  • 是的,正如我所期待的那样,这很容易.....但是当我想将我的网站上传到服务器时该怎么办......???
  • 你在你的服务器上做同样的事情。如果这是共享主机,那么您需要让您的 ISP 为您做这件事。您也许可以将 ffmpeg.exe 上传到您的网络根目录中的文件夹并从那里执行它,但通常安全限制不允许这样做。
  • 非常感谢,我正在尝试这种方法,但现在没有成功,但我相信我可以做到......明天我会通知你......
猜你喜欢
  • 1970-01-01
  • 2010-12-26
  • 1970-01-01
  • 2010-11-09
  • 2015-11-27
  • 2017-04-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多