4

我在 PHP 的 shell_exec() 中运行 ffmpeg 命令来转换列表中的多个视频。是否有办法检测在转换视频时是否发生错误(或至少验证它完全完成了转换)?

如果发生错误,我不想停止转换其他视频,只是能够记录错误。

<?php
    shell_exec('ffmpeg -i downloads/flv/file1.flv -vcodec libvpx -acodec libvorbis downloads/webm/file1.webm');

    if(error) {
     //run a command here to report the error (ie. MySQL or email)
    }
?>
4

2 回答 2

12

使用另一个系统调用函数捕获退出代码,例如exec

exec('ffmpeg ...', $output, $return);

if ($return != 0) {
    // an error occurred
}

任何体面的实用程序都会在出错时以 0 以外的代码退出。

于 2011-10-28T00:16:35.800 回答
-2
$return=shell_exec('ffmpeg ...');

if ($return) { //look at what it returns do what you will with the data

}
于 2011-10-28T00:19:17.817 回答