2 ###APPNAME: mplayer-make-screenshot
4 ###APPDATE: 2008-05-11 02:53:08
6 ###APPDESC: mplayer-make-screenshot
7 ###APPUSAGE: filename [number of screenshots]
8 ###APPEXAMPLE: mplayer-make-screenshot [--hand] movie.avi 100
12 #ENV variable MUST be defined somewhere,
13 #FOR perl to search modules from,
15 use lib
$ENV{XR_PERL_MODULE_DIR
};
17 use MyPlace
::Script
::Usage qw
/help_required help_even_empty/;
18 exit 0 if(help_even_empty
($0,@ARGV));
21 if($hand eq "--hand") {
30 die "File not exist: $fn" unless(-r
$fn);
35 print STDERR
"$line\n";
39 #my @player_opt=("-slave","-vf","screenshot","-framedrop","-vo","jpeg:quality=100:smooth=100");
40 my @player_opt= $hand ?
("-vf","screenshot","-framedrop") : ("-slave","-vf","screenshot","-framedrop") ;
45 exit 0 unless(system("which png2jpg 1>/dev/null")==0);
46 my @pngs=glob("*.png");
48 system("png2jpg",@pngs);
49 system("rm","-v",@pngs);
57 system("mplayer",@player_opt,$fn);
61 $num = 50 unless($num>0);
63 $step = 100.00 / $num;
65 my $shot_cmd = "screenshot";
66 my $seek_cmd = "seek ";
67 open FO
,"|-","mplayer",@player_opt,$fn;
68 select ((select(FO
), $| = 1)[0]);
69 select ((select(STDERR
), $| = 1)[0]);
71 print FO dup_line
("pause");
72 print FO dup_line
($seek_cmd . "4 0");
73 print FO dup_line
($shot_cmd);
74 until($total>=99.88) {
76 $total=99.88 if($total>99.88);
78 print FO dup_line
($seek_cmd . "$total% 1") or last;
80 print FO dup_line
($shot_cmd);
82 print FO dup_line
("quit");
86 on_exit
unless($pipe_broken);