video thumbnail contact sheet code done

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tatyana
    DavidNudesWorld hahahahaha
    • Dec 2008
    • 151

    #1

    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
  • avrevenue
    Confirmed User
    • Apr 2004
    • 1904

    #2
    nice script, thanks for sharing
    An alternative would be to use php-ffmpeg is available.
    AV Revenue High Quality Sites to Promote
    Telegram: avrevenue

    Comment

    • fitzmulti
      I Like Depth Of Field!
      • Jan 2003
      • 14861

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


      www.SexyGirlsCash.com


      CONTACT // FITZMULTI AT GMAIL.COM //
      {Please include a message so I know you are from GFY! I get too many spam "add requests"!}

      Comment

      Working...