现在作为-6ren">
gpt4 book ai didi

php - FFMPEG 视频转换完成后发送电子邮件 (php)

转载 作者:行者123 更新时间:2023-12-04 22:56:35 27 4
gpt4 key购买 nike

我有一个使用 ffmpeg 转换 avi 的基本 php 脚本:

<?php
if (exec("/usr/bin/ffmpeg -i testvideo.avi -sameq -ar 22050 convertvideo.mp4 2> logfile.log")){
echo "Success";
}else{
echo "Error";
}
?>

现在作为对此的扩展,我想使用 php 检查文件是否仍在转换,如果不应该发送电子邮件,谁能告诉我如何实现这一目标?

此外,尽管使用了上面的代码并且文件被成功转换,但我总是得到的输出是“错误”,任何人都可以帮助解决这个问题吗?

谢谢

最佳答案

以下应该有效:

exec("/usr/bin/ffmpeg -i testvideo.avi -sameq -ar 22050 convertvideo.mp4 2> logfile.log", $ret, $val);

if ($val != 0) {
// Video conversion fail for some reason
$msg = "Error converting video: $ret" . "\n";
echo ($msg);

// send the email
mail("no@body.com", "Error convering video", $msg);
}

如果您想为 ffmpeg 进程设置超时,请考虑使用 proc_open方式( see example)。

关于php - FFMPEG 视频转换完成后发送电子邮件 (php),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10987114/

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