Dienstag, 11. Dezember 2012

[Bash] Play Flash-video with mplayer

Just a little script I made to play flash-videos from Firefox using mplayer.
Some flash-player put the video at
/proc/$pid/fd/$filedescriptor
That one can be played with using e.g. mplayer or vlc.
The script tries to find the right $pid and $fd and plays it.



Here it is:
http://paste.kde.org/623894/ )
#!/bin/sh
pid=`pgrep -f flashplayer.so`
echo "$pid"
for p in $pid
do
    echo "ls -l1 /proc/$p/fd/ | grep deleted"
    deles=`ls -l1 /proc/$p/fd/ | grep deleted`
    echo "deles: $deles"
    wcDeles=`echo $deles | wc -w`
    wlDeles=`ls -l1 /proc/$p/fd/ | grep -c deleted`
    echo "WC: $wcDeles"
    echo "WL: $wlDeles"

    wPerLine=`expr $wcDeles / $wlDeles`
    echo $wPerLine
    offset=3
    i=1
    dval=""
    for d in $deles
    do
        dval=$d
        for numLine in `seq 1 $wlDeles`
        do
            pos=`expr $wPerLine \* $numLine - $offset`
            #echo "expr $wPerLine \* $numLine - $offset"
            #echo "P: $pos"
            if [ $i -eq $pos ]
            then
                #echo "V: $dval"
                echo "playing /proc/$pid/fd/$dval"
                mplayer /proc/$pid/fd/$dval
            fi
        done
        i=`expr $i + 1`
    done
done

Keine Kommentare:

Kommentar veröffentlichen

[Review/Critic] UDock X - 13,3" LapDock

The UDock X - 13.3" LapDock is a combination of touch display, keyboard, touch-pad and battery. It can be used as an extension of vari...