2011-02-09 6 views
1

このコードでスクリーンショットをとるためにffmpegコマンドがどのように実行されるかを知りたい。私は、スクリーンショットが作成されたとき、関数によって、またはそれが実行された行によって何かを把握することができません。このコードでffmpegを実行する方法

$ffmpeg = '/usr/bin/ffmpeg'; 
     $video = $sourceUrl;// the input video file 
     $thumbId = uniqid(); 
     $thumbId .= ".jpg"; 
     // where you'll save the image 
     $image = "uploads/$thumbId"; 
     // 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 $second -t 00:00:01 -r 1 -y -s 120x90 -vcodec mjpeg -f mjpeg $image 2>&1"; 
     $return = `$cmd`; 
     $thumbLink = ""; 
+0

@Dan編集のおかげで、適切な綴りを書いてください。ありがとう。 – XMen

答えて

3

この行は、あなたが変数$cmdに格納されたコマンドを実行:PHPで

$return = `$cmd`; 

を、バッククォートはexecution operatorであり、その使用はshell_execを呼び出すことと同じです。

+0

何かを学んだ:) – DhruvPathak

関連する問題