| Category: | Miscellaneous |
| Author/Contact Info | |
| Description: | Autocrop for MPlayer |
#!/usr/bin/perl -w
######################################################################
+#
#
# MPlayercrop - MPlayer autocrop script
# By Martin (bumby) Stenberg <bumby@evilninja.org>
#
use strict;
use File::Basename;
my $SAME_FRAMES=30; # You may have to tweak this
usage($0) unless @ARGV;
my $argv="";
foreach my $arg (@ARGV){
$arg=~s/ /\\ /g;
$argv.=" $arg";
}
my $s="";
my $old="";
my $i=0;
my $pid = fork();
die "Couldn't fork: $!\n" unless defined $pid;
if($pid == 0){
open(FILE,"mplayer -vf cropdetect $argv|")
or die "Could not start mplayer";
print "\nGathering crop detections. Please wait...\n";
while(<FILE>){
$s=$_;
if(/\(-vf crop=(\d+:\d+:\d+:\d+)\)/){
$s=$1;
if("$s" eq "$old"){
$i++;
}else{
$i=0;
}
}
if($i == $SAME_FRAMES){
system("reset");
exec("mplayer -vf crop=$s $argv");
exit 0;
}
$old=$s;
}
exit 0;
}
sub usage{
my $file = basename(shift);
print "Usage: $file [mplayer options] file\n";
exit 1;
}
|
|
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: mplayercrop
by mrborisguy (Hermit) on Jul 29, 2005 at 23:40 UTC | |
by bumby (Beadle) on Aug 01, 2005 at 07:28 UTC | |
|
Re: mplayercrop
by Anonymous Monk on Sep 13, 2007 at 22:35 UTC |