GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   video thumbnail contact sheet code done (https://gfy.com/showthread.php?t=1123224)

tatyana 10-10-2013 01:57 AM

video thumbnail contact sheet code done
 
Hi all! Im just working right now on some new site automation work, and finished a simple php script for making a video contact sheet on the server. You can specify num of shots, size, and source video. Couldnt find this anywhere else, so here is mine in case someone out there needs it! (BTW, it figures out the length of your vid and smartly decides where to screenshot the vid, you need ffmpeg and imagemagick on your server)


// make screenshot thumbnail graphics
$video = $source_folder.$sourcefile.'.mp4';
$second = 140; //specify the time to start the screen shot at (can easily be randomly generated)
$num_thumbs = 12;
$output_size = '200x113';
$thumbsheet = $destination_folder.$sourcefile.'_contactsheet.png ';

// get the duration and a random place within that
$retval = system('ffmpeg -i '.$video.' 2>&1 | grep "Duration"',$retval);
if (preg_match('/Duration: ((\d+):(\d+):(\d+))/s', $retval, $time)) {
$total = ($time[2] * 3600) + ($time[3] * 60) + $time[4];
//$second = rand(1, ($total - 1)); //rand second chooser
}

$second_increments = ($total-$second) / $num_thumbs; // example every 305 seconds

$this_second = $second;

for ($i = 1; $i <= $num_thumbs; $i++) {

$image = $destination_folder.$sourcefile.'_ss'.$i.'.jpg'; //define the output file
//finally assemble the command and execute it
$command = "ffmpeg -ss $this_second -i $video -an -vframes 1 -s ".$output_size." $image";
//echo $command;
exec($command);

$this_second = $this_second + $second_increments;

}

//make simple graphic
$command = "montage -verbose -background transparent -define jpeg:size=".$output_size." -geometry ".$output_size."+2+2 ".$destination_folder.$sourcefile."_ss{1..".$num_t humbs."}.jpg ".$thumbsheet;
exec($command);

avrevenue 10-10-2013 06:52 PM

nice script, thanks for sharing
An alternative would be to use php-ffmpeg is available.

fitzmulti 10-10-2013 06:56 PM

Very nice...and nice OF you! ;-)


All times are GMT -7. The time now is 02:35 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123