The problem here is the word random . I successfully got the duration of the video, and then try to get one frame with such a random duration. Easy to modify for more frames:
$cmd = "ffmpeg -i {$src} 2>&1 |grep Duration"; $output = array (); exec($cmd, $output); if(count($output)) { $duration = explode(':', trim(str_replace('Duration:', NULL, current(explode(',', current($output)))))); list($hour, $min, $sec) = $duration; $sec = sprintf("%02d:%02d:%02d", rand(0, $hour), rand(0, $min), rand(0, $sec)); } else { $sec = "00:00:12"; //12sec it ok :) } $cmd = "ffmpeg -ss {$sec} -i {$src} -s {$w}x{$h} -f image2 -vframes 1 {$destination}"; $output = array (); exec($cmd, $output);
Mahomedalid
source share