View Single Post
Old 10-10-2013, 01:57 AM  
tatyana
DavidNudesWorld hahahahaha
 
tatyana's Avatar
 
Industry Role:
Join Date: Dec 2008
Location: Scottsdale, AZ
Posts: 151
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);
__________________
David & Tatyana Owner & Producer
DavidNudesWorld.com for all our sites!!
NATS & CCBill Affiliate Program nats.DavidNudesCash.com
tatyana is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote