PHP FFmpeg 在 windowxp 中不起作用,而在实时网站上,在 ubuntu 中工作的代码相同


PHP FFmpeg not working in windowxp and on live website same code working in ubuntu

这是我的脚本,我想在所有情况下工作:它只在ubuntu中工作,但并非在所有情况下都像windowsxp一样工作请建议我...

    // where ffmpeg is located, such as /usr/sbin/ffmpeg
    $ffmpeg = 'ffmpeg';
    // the input video file
    $video  = "upload/uploads/movies/animations/dhoom-2.mp4";
    // where you'll save the image
    $image  = "upload/uploads/movies/animations/images/dhoom-2.jpg";
    // default time to get the image
    $second = 1;
    // get the duration and a random place within that
    $cmd = "$ffmpeg -i $video 2>&1";
    if (preg_match('/Duration: (('d+):('d+):('d+))/s', `$cmd`, $time)) 
    {
        $total = ($time[2] * 3600) + ($time[3] * 60) + $time[4];
        $second = rand(1, ($total - 1));
    }
    // get the screenshot
    $cmd = "$ffmpeg -i $video -deinterlace -an -ss 04 -t 00:00:01 -r 1 -y -vcodec mjpeg -f mjpeg $image 2>&1";
    $return = `$cmd`;
        echo "<script>alert('done!');</script>";
    ?>
    <img src="upload/uploads/movies/animations/images/dhoom-2.jpg" alt=";-)" class="wp-smiley"/> 

我想你错过了像下面这样执行的"exec"/"shell_exec",尝试相同的操作。

$cmd = "$ffmpeg -i $video -deinterlace -an -ss 04 -t 00:00:01 -r 1 -y -vcodec mjpeg -f mjpeg $image 2>&1";
return exec($cmd);