#!/usr/bin/perl

#
#         movies in dir screenshots creation
#       --------------------------------------
#
#
#          (c) 2006 sh@isecure.cz
#

use strict;

use POSIX qw(floor);

use constant MPLAYER    => "/usr/bin/mplayer";     # path to mplayer
use constant IMAGES     => 7;                      # number of images to create

my $file;
my $length;
my $step;
my $pic;

open(MOVIES, "ls | grep -v '.pl' | grep -v '.txt' | grep -v '.jpg' | grep -v '.php' |");

while(<MOVIES>) {
    $file = $_;
    chomp($file);

    if( -e $file.'.1.jpg' ) {
        # if screenshots exists do next
        next;
    }

    print $file . " ";

    open(MDATA ,MPLAYER." -identify -nosound -vo null $file -ss 666:00 2>&1 > /dev/null | grep ID_LENGTH | tee $file.txt |");
    $length = <MDATA>;
    close(MDATA);

    #print $length."\n";
    #ID_LENGTH=136.00

    if($length =~ /^ID_LENGTH=(\d*).\d/) {
        $length = $1;
        print floor($length / 60)."m ".($length % 60)."s \n\n";
    } else {
        next;
    }

    $step = floor($length / IMAGES);

    system(MPLAYER." -vo jpeg -frames 1000 -ao null $file -sstep $step -nosound 2>&1 > /dev/null ");

    for(my $i=0; $i < IMAGES; $i++) {
        $pic = sprintf("%08d.jpg",($i+1));
        if( -e $pic ) {
            system("mv $pic $file.".sprintf("%02d.jpg",($i+1)));
        }

    }

}

close(MOVIES);

Vlož koment...

Jsou povoleny tyto XHTML tagy: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>





© sh, bw and hosting donated by lidos.cz