[MPlayer-users] Parsing mplayer output

Yan Seiner yan at seiner.com
Fri Jan 22 03:51:18 CET 2010


RC wrote:
> On Tue, 19 Jan 2010 08:25:51 -0800 (PST)
> "Yan Seiner" <yan at seiner.com> wrote:
>
>   
>> No combination of
>>
>> mencoder ... 2>&1 | tr '\r' '\n' | grep -v '^Pos'
>> or
>> mencoder ... 2>&1 | sed -e s/\r/\n\r/g | grep -v '^Pos'
>>
>> seems to do the trick.
>>     
>
> The former works perfectly here.  
>   


It apparently had to do with buffering...

Here's what I ended up doing:

( echo "Pass 1" && $PASS1 && echo "Pass 2" && $PASS2 && echo "Pass 3" && 
$PASS3 && echo "SUCCESS!") 2>&1 \
    | tee $MENCODERLOG \
    | tr '\r' '\n' \
    | awk 'BEGIN {b=99} /^Pos/ {i=match($0,'/[0-9]%/'); 
a=substr($0,i,1);if (a!=b) {b=a; print $0}};! /^Pos/ {print $0}; fflush()' \
    | zenity --text-info --title "Ripping $TTILE"

It only prints the status line at every new % and it prints every other 
message.  I need to eliminate blank lines; that's next.


-- 

   o__
   ,>/'_         o__
   (_)\(_)       ,>/'_          o__
A day may come  (_)\(_)         ,>/'_      o__
when the courage of men fails, (_)\(_)     ,>/'_ 
when we forsake our friends and break all (_)\(_)
bonds of fellowship, but it is not this day.
It is not this day!
This day we ride!



More information about the MPlayer-users mailing list