gpt4 book ai didi

php - ffmpeg 不能从 php 工作

转载 作者:行者123 更新时间:2023-12-04 23:04:50 25 4
gpt4 key购买 nike

我从 http://ffmpeg.org/releases/ffmpeg-2.5.3.tar.bz2 安装了版本
并且还尝试了 yum 版本,但它对于 youtube-dl 来说还不够新。

我试过export PATH=$PATH:/usr/local/bin/ffmpeg和 PHP/Apache 仍然找不到 FFmpeg。

Apache 用户在 CentOS 6.5 上运行 PHP 脚本。
从 php 命令行以 root 身份调用我的 youtube-dl.php(使用 FFmpeg)
从 php apache 用户调用我的 youtube-dl.php 有效(不适用于 FFmpeg)

我正在尝试做的事情:shell exec youtube-dl(youtube dl 在其二进制代码中调用 FFmpeg,现在可以对其进行修改以添加完整路径)。这有效,但 FFmpeg 部分
我的 youtube-dl.php 文件

$output = shell_exec('youtube-dl -o "/home/test/%(title)s.%(ext)s" '.$url.'      -f bestvideo+bestaudio 2>&1');
echo "<pre>$output</pre>";

# which ffmpeg
/usr/local/bin/ffmpeg

该站点其他页面上的某个人说 local/bin 用于自定义版本,但我直接从 FFmpeg 下载了它并进行了标准的 ./configure make install。

完毕:
 chmod 755 to /usr/local/bin/ffmpeg

直接将 FFmpeg 作为测试命令运行(有时有效,但在我升级/重新启动/updatedb/etc 时不起作用)
$output = shell_exec('ffmpeg 2>&1');
echo "<pre>$output</pre>";

结果:
<pre>sh: ffmpeg: command not found</pre>

我阅读了所有这些类似的问题,但它们没有帮助:

FFMPEG PHP does not seem to work
FFmpeg not working
Recording audio with FFMPEG works in terminal but not through exec() of PHP
ffmpeg-php permission denied on localhost
C++ program from PHP not working properly
FFMPEG works from command line but not PHP
Calling a shellscript from php - not working correctly
PHP Internal Server Error 500 when using ffmpeg to convert files
PHP code not proceeding to the line after exec ffmpeg
ffmpeg not working from php script but works from command line
PHP exec() Not Working With ffmpeg
ffmpeg not work with PHP exec()
ffmpeg php exec not working

最佳答案

解决方案对我有用。
我按照这里的教程安装ffmpeg:http://www.wikihow.com/Install-FFmpeg-on-Windows

设置 PATH 然后我从命令提示符检查 ffmpeg –version 它是否正常工作。

然后我尝试使用 youtube-dl(youtube 链接)-f bestvideo+bestaudio 下载 1080p 视频,但我收到了相同的消息:“警告:您已请求多种格式,但未安装 ffmpeg 或 avconv。格式不会合并。”当然是安装了。

然后我以管理员身份运行打开命令提示符,尝试了同样的方法,终于成功了。

关于php - ffmpeg 不能从 php 工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28488224/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com