ffmpeg - 在 exec() php 函数上使用 ffmpeg 进行音频转换

标签 ffmpeg exec

任何人都解释了为什么 exec(),shell_exec(), system() 在执行 ffmpeg 命令时不能返回任何返回值。

IE:
exec("我是谁", $output = array());
//这里执行成功,$output设置了一个数组值
$output= shell_exec("我是谁");
//这里执行成功,$output设置了一个数组值
system("我是谁", $output = array());
//这里执行成功,$output设置了一个数组值


exec('ffmpeg -i "$sourcepath/Test.mp3" -vn -acodec libvorbis -ab 128k -y $desnpath/TestTest.ogg"', $output = array());
//here execution is success but $output is not set an array value 
$output= shell_exec('ffmpeg -i "$sourcepath/Test.mp3" -vn -acodec libvorbis -ab 128k -y $desnpath/TestTest.ogg"');
//here execution is success but $output is not set an array value
system('ffmpeg -i "$sourcepath/Test.mp3" -vn -acodec libvorbis -ab 128k -y $desnpath/TestTest.ogg"', $output = array());
//here execution is success but $output is not set an array value

我不知道为什么..!?

请任何人帮助我。

最佳答案

这是因为 ffmpeg 不会向标准输出输出任何内容。它的输出被打印到 stderr。
如果您使用的是非 Windows 系统,则可以执行 exec('ffmpeg -i "$sourcepath/Test.mp3" -vn -acodec libvorbis -ab 128k -y $desnpath/TestTest.ogg 2>&1"', $output = array());或者你可以使用 proc_open()

关于ffmpeg - 在 exec() php 函数上使用 ffmpeg 进行音频转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20491796/

相关文章:

go - 无法从 Golang 运行 bash `read` 命令

php - 在 PHP 中执行 exec() 或 system() 并且不等待输出

unix - 如何使用tcl文件中的sed

go - golang中的FFmpeg I-P帧命令

flash - 自定义 HomeKit(使用 HomeBridge 插件或构建自定义应用程序?)

javascript - 使用AngularJS的视频编辑器

audio - 在 ffmpeg 构建中启用 "vorbis_parser.h"

ffmpeg - 如何流式传输文件夹中的所有视频?

linux - 使用绝对路径覆盖 exec 系统调用

Go:运行外部 Python 脚本