<?php
$num_thumbs = 9;
$input_file = 'yourfile.mpg';
$output_file_prefix = 'yourfile';
$output_file_format = 'png';
$time_from_end = 0.5;
$input_duration = trim ( `ffprobe
-v error
-show_entries format
=duration
-of
default=noprint_wrappers
=1:nokey
=1 "{$input_file}"`
); $interval = (float) ( $input_duration / $num_thumbs );
for ( $i = 0; $i < $num_thumbs; $i++ ) {
if ( $i === ( $num_thumbs - 1 ) ) { $interval_time = $input_duration - $time_from_end; }
else { $interval_time = $interval * $i; }
$num = str_pad ( $i + 1, 2, '0', STR_PAD_LEFT
); $cmd = "ffmpeg -ss {$interval_time} -i \"{$input_file}\" -frames:v 1 \"{$output_file_prefix}.{$num}.{$output_file_format}\"";
echo "\n\n" . $cmd . "\n\n";
}
?>