#!/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; }

In reply to mplayercrop by bumby

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.