简体   繁体   English

PHP FFmpeg在windowxp和实时网站上无法正常工作在ubuntu中

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

Here is my script i want to work in all case : Its working in only ubuntu but not in all case like windowsxp Please suggest me... 这是我想在所有情况下都可以使用的脚本:它只能在ubuntu中工作,而不是在所有情况下都像Windows XP一样工作。请建议我...

    // 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"/> 

I think you miss the "exec" / "shell_exec" for execution like below , try the same. 我认为您会像下面那样错过“ 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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM