php - How ffmpeg is command executed in this code -
want know how ffmpeg command executed taking screenshot in code. not able figure out when screenshot created, function or line done.
$ffmpeg = '/usr/bin/ffmpeg'; $video = $sourceurl;// input video file $thumbid = uniqid(); $thumbid .= ".jpg"; // you'll save image $image = "uploads/$thumbid"; // default time image $second = 1; // duration , random place within $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)); } // 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 = "";
this line executes command stored in variable $cmd
:
$return = `$cmd`;
in php, backtick execution operator, , use identical calling shell_exec.
Comments
Post a Comment