[MPlayer-users] -quiet option for mencoder?

Matija Grabnar matija.grabnar at arnes.si
Sun Jan 5 08:22:03 CET 2003


> well, i know i can capture mencoder's output into a perl string and
> then extract the bitrates outta the end of that string, but the
> problem is that string is going to HUGE!
Yes, if you capture the whole string at once, it _is_ going to be huge.

But you need not do that. 
I have a script which captures that information like this:
sub execute {
    my ($exec,$sub)=@_;
    my $on=1;
    print "$exec\n";
    open(PROG,"$exec 2>&1 |");
    while (sysread(PROG,$buf,64)) {
        print $buf if $on || $verbose;
        $str.=$buf;
        $lines=$lines.$buf;
        &$sub($lines) if defined($sub);
        $on=1 if (!$on && index($lines,"\n")>-1);
        $on=0 if $lines=~/^Pos:/m;
        $lines=~s/.*[\r\n]//;
    }
    close(PROG);
}
execute("mencoder \"$inp\" $passthrough -ovc frameno -oac copy -o frameno.avi",sub {while ($lines=~/Recommended video bitrate for (\d+)MB CD:\s*(\d+)/g) {$rec{$1}=$2;}});

That gives me recommended sizes in the %rec hash.

Hope this helps...



More information about the MPlayer-users mailing list