1
이 코드에서 스크린 샷을 찍는 ffmpeg 명령이 어떻게 실행되는지 알고 싶습니다. 나는 스크린 샷이 언제 만들어 지는지, 어떤 기능에 의해서 또는 어떤 라인에 의해 그것이 수행되는지를 파악할 수 없다.이 코드에서 ffmpeg가 실행되는 방법
PHP에서$return = `$cmd`;
가 백틱는 execution operator이며, 그 사용 shell_exec 호출 동일 :
$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 = "";
@Dan 편집에 대한 감사는 적절한 맞춤법을 쓰고 싶습니다. – XMen