0

这是我想在所有情况下都可以使用的脚本:它仅在 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"/> 
4

1 回答 1

0

我认为您错过了执行如下所示的“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);
于 2013-11-14T09:29:46.483 回答