Linux 终端下使用 Python 看葫芦娃


简介 :

介绍一款终端下的媒体播放器(图片/视频)

https://github.com/WangYihang/tplayer


一个简单的小栗子 :

nc 120.24.215.80 50000
试试看会发生什么吧~

使用方法 :

Usage : 
        python tplayer.py [VIDEO_PATH|IMAGE_PATH]
Author : 
        WangYihang 

使用样例 :

python tplayer.py BruceLee.jpg
oottzzzzzkotkkkkkeeewsVVwVlsssewswwwVeVsseJweVJJJkeeeeJtootokk@CCCUxxzxzoozxJJJJJJJVVwwVVVwwwwwJJJJJJJJJeewwwwwwwweeeeeeeeeeJkJJttttttttttttttttttttttttt
ozzzzookkeJJeVVVVwwVsssVsaa$$$l$$$aalllllsssssVVlsweeewVlJk[#iUCU[qvTT?F?uy)]CokJkeJJJJJJewwwwwwwwwwwwwwVVwwwwwwwweeeeeeeeeeeJJJkkJkkkkkkkkkkkkkkkkkkkkkk
zzxzzztkJJJJwVwwwVsVVaaaaaaP$$aP$aaalaalssssslsssVeJeeJkJh#)I(\:     n     ;;}\Yy)i[htkJkeeweeewVsewwwwwwweeeewwwweeeeeeeeeeeJJJJkJJkkkkkkkkkkkkkkkkkkkkk
oootttttJJJeeeweVVVVsa$aaaa$$$aaaaaaaaaaaaassslVtoxI(%iC#r|<          =!ycYnT}*!L;1Ycn/\n@zkweVVVsweewVVVVVVVVVVVVwwwweeeeeeeJJJJJkkkJJJkkkkkkkkkkkkkkkkk
ototkkkkkkJeeeeeVVVVVsVaaaaaaaalaaaaalVaallVJo[%;                            : /Yv|}!uL|}}}nzswVVVVVVVVVVVVVwwwwwwwwwweeeeeeeJJJJJkkkJJJkkkkkkkkkkkkkkkJJ
ototkkkkJJeeeeewVVVVssVVVVaaaassVlasaVssasJq=                         {  r  <{\;*; *<=: ;!*=TnxJJswVVsalsVVswwwwwweeeeeeeeeeeeeweekkkJJJkkJJJkttkkktkJeww
oottkktJJJJeweeeeVVVVsVVsVVslalaaaa$Vallt1                               1  {  }?T*;!  <>                      <}/c[oeslslllllsVssssssVslssVaVVVVVVVVVVVVeeJeVVVVVeJw
eeJeeeeeVVVVwwVVwVVVVVslVlal$a$s)=;:     < };         q     r  =*  =!   *                            :}cqtVlaalllsVVVVssssllslVlsVVVVVVVVVVVVVVVVVVVVVwVs
eJwwwVVVweVVwwVVwVVsasaaaaaaaP@n{       r  ;   >= =} !   =          T   q            ; *; )%VJn|;;;       ::L{{<*  ;>*|*: ::                       >u[JlPPPPP$aaaalaaaaaaaaala$lsaaaaallalsls
VVsVsssasssssssaaalaasH ;<;=;yo\ %!(\C1T=r|(VMPN5dZbdbbAARRRARRAdKge7F]Ycnccc(%Ynu?!<;=:::                       q$EQQPP$$aaas$laaaaalls$$$lsslslssssssss
VVVVVlslslalsssssllaa#*=r ;*<;y*; =!}%{| {:UQKKODddDdbRRRRRRAAZRdbNDXd2GNNNOdO3fMaVJIT}*>;=                     > \7> :   {rMN55KNONNXdZRRRRRRRRbNdGNKfQZOKM2g2llka4UH%qqpcuL ;<<                FKQEQQEEQEP$aaaaaaaaaaaalaa$aaaaaaalaaaaa
$sssssssaaaaaaaaa$Q$apum\I!]!=  *c}   > :!rPGGKKXDOOOXNDO5GjfQohJtkssks3MQaJJ4@ynL*                             |fgQQQQEPPPEPPaa$PP$aaaaa$aaallllllllllll
aslalaaaa$$$aa$$aPQPa4m!rrI}*;:nMgM3GOj532$VIFr*:   =                                                )g2ggQQEPPPPPPPPPPPPPPP$$$$$a$aalaallaall
$aaa$$aa$a$EEEEEEEEQQl(r{r\!><;LTr      /rsojjqq !rcYF{;:                               ;;;;;                   $E22gggQEEPPPPPEPPPPPQP$$$$$$aaaa$$$$aaaa
EP$PEEEEEEPEEEEEEEEgQa#T!F1FL*vu}>      ceC   m/FIymnvmvn?|;:                         = >**!*             ;xgggggQQQEQEPPPPPPPPPPP$P$$$$$$$$PPP$PPa$
E$PPPPPPEEEEEEEEEEEQQa@F\7/u>|Fc=*      Fn} 4yzx4UJolPzy7?FFuYr}<; =         :!!           ;;;;>;;:           :\3fMgggggQQEEQEPPPPPPPQEPPEEP$EEPPPPEEEPPP
2PPPPPEEEEEEPPPPPEEQQekm\/I]}!nu;;=     TL Qwtzzh4o4?<=         :>::   <*     }*              =;;;   <:r ;     HKfj2MgggQEEEQEEEPPPgQgEEQQEP$$$$PPEPPPPPP
gEPPPEEEEEQEPPEQQQQEQgPHFYycnn{( <:      : awJkoh(F===:           :;  !yWOu    ;               =:===   Y :     %j2fMMgggQEEEQEQEPPPPPEQQ2MME$PEPEEPEEQEPP
gEPEPEEEEEEEEQQgQggggMfg7u{TuF=|| ==    :I JeJz]%c};=;;;;=;:==: :=;*!:          >{\ch* gb&WZXf4hHm   >>==;;;;===;<;  *}*           e3ffM2gQQQQQQQQQQQQQQQQQQQEEP$QQQggQQQQQQ
ggQQQEQQQQQgQQQQQg2MMffjMCp(ccL|4>;     = ; rxlw@UC#)mu1!r\/\Fv@H {ASRW&dOMsxhy?Y   {T\\\\{!;=><<>;;:          :J2fff2gggggQQQQQQQQQQQQQQQQQQEQQQgggggggQ
ggQgQgQQQQggggggg2MfMjj33PYuy\u{LY=    =PV*{ :7c#qyqmY??TL|L=:z0ZdddRZZdN5glsp**{]a/*:           }%(%         }g2fjjMM22ggggQQQQQQQQQQQQQQQQQQQgggggQEEE
MQQgggggggggggg2MMMfffjGG3Mycyr{vu7|!: L@ZRZAs=  >!<>>=1Zy  k9&SEKOXbRARRDOQPkke#/r)EPM$4nrTLL{T17v)Hp     < ==pGfMMffMMMMggggQQQgQQQQQQQQQQQQQQQgggggQEE
fgg2g2gggggg222MMMMffjjGGGG2puI#hu1?}::::>hW6A0Wa[QdddXdRSNMso#YmyIIyr[t$PQQEQa#u7/?uy))=   !* :*lj3ffffMMM2g2ggggQQQQQQQQQQQQQQEQgggggggQQ
f2g2g222gggggg2gg22MffjjjjjGPmqrMhT\m|::!MOdXdDDdZSS&00ASSbdQHqEZddNMekx]I/L!|}{!1F!r]ihozxUqY///Fuy(H:: r!T!m(333jffjMMM2g2ggggQQQQQQQQQEEQQQEQQggggQQQQ
f22g22g2MM2222222fMMfffjjjj3Ks]WbNEuFz:=<\4C]i)qnF??/7nv)I!=:%yvo4KG3jffffMMM2gggggQQQQEEQQQQQQQQEQQQggggggQQ
f2M2222MM22222222fMffjfjjjjGG3MJZNSSSX===*jGKO5OKGGjfjfQsJzh3AAARsL<**!< :     =:=;*=>=:==>>*|{\(cc\T1T1?c)#h%*u[aKOKG3jMMMfffM2222gggggQgggEQQQQQQQQQQgggggQQQQ
2ggg2MMfffMMMMMMMfMj3jjjjjj33jME(bRdXDG/*!gXONN3GOjjMPs$2NDZRRRbddbdddbOK5ODXG)=<<>>>***!!u/rTrT?/YyIU)?tKKGG3G3jMfMfffMMMMM2ggggQgggggggggggggQQQQggQQgg
fg222MMMMMfMMMffj3333GGGG33GGGG3x\qDZXRZDC2DXXNNNN5Kfg2GOXDdZdXN5NZDSdXwaE3Em\T{1u}<<>><**}1{Lr1?YIcq]yrKGGGG3jjfMfMffffMMMMM2ggggggggggggggggggQQQQQQQgg
fg2MfMjjjjjfffffjGGGGKKKKGGGGGKGjp!: mh]mYbdXXNOOOKKKKKONDONOEwkVfRCIyF1Lr1!;;;;;;>;<=;>**!T7Lr?1nmmpCqcOKKG33jjfMfMffffMMMMMM2fggQQQggggQQQQgPEPPgQQQQQQ
3Mffffjjjjjjffffjf3GGGKKKKKKKKKGjPH*;;= : PDddODKNKKKKKKK5Kjzq1\puL<}==Fvyn}rT//r;     :;<*rF{T\/cqI)U1]N3G3jjjjjjjfffffMMMMfMMM2gggggggEEQQQPPaa$EQQQQQQ
M2ffffffffffffMfjj333GKKKKKKKKKKKGK#!>;: ::bZDNONOG5GGGGjMgkq};IjgZddbNSddbX5MlzUHvT!!|****LFrT17YyIix|wKGG3jjjjjjjjffffMMM2MMgMgggggggggQQQEQ$aaEgQQQQQQ
MgMMMfffffjjjfj33GGKKKKKKGKKGKKKKKK5f/;=;==yXbNXKKKG3jGGjQas$NddDXXNGfaJ#F\T{<*><|FYyn{!{LrT/uumI[|>kG33jjjjjfMjfjMMMMMMMM22MMMgggggggQEEEEQ$$$$QQQQQQQ
GGK5K5555OOO5OOONOOOONNOKKKKKKKKKK5555G4>:: }oQ2QfggggEslae$PEgGKf3ffMaoC(C#(H[(%%pImc1L}||}r?Fun%): ngG33jjjjffjfMMMMMMMMMMMMMMMgggggggQQQEEQ$sVlQQQQQQQ
5K5555NNNNNO55OOONNNNONO5KGGKKKKKKKKK555j!; L?f@VPPPP$EE$l$sPQPgQ3K5XdbRdddXObNNfkJ#)Y\1T{}r??uYmpm:=zfG33jjjjjjfMffMffMMMffMMMMMggggggggQQEM5OKGM2QQQQQE
5555KKKOKK55555555K5O55OO5KKKKGKKKKGGGK55NXpFLNO]%kVVEgg2QEPgMgjjKKXdRZRZbbbON2PkzU#mcT}TL}r\F/YuFn*vGKjjjjjjjjjfffMMfM22222MMMMMM2MgggQQEPf5XXXOGMQ$EPEQ
GK5KKKK3GGGGKKKK5KK555K5555K5KKKGKKKKKKKKOO){cjX5G77%ztaggQQQQMfjj35XNdddXXNGMaekC(c1*!}{}r1?TrT?\n#K5KKjfjjjjjjMffMMMM22222MMMMMMM22gggggQGONXX5MM$aPPQQ
Q3j3GGjjjjjjGjjj3jfjjKKKK55555KKKGGGG3KKKjKOkszNNNOQL}1)(]hokPQgMgEMMfjfjffE$Vh#(/T*><<<*!|!<|}}}{1TFHO55KKKK5G3KGG3fjjfffMMfM222222222MgQg23GGKKGQalEllgQQ
lE$aaasVwwVwVs$aaVJkxzotJkkJtketkJJktkttkkkzoxHOKNNNNf@FL|!***|\c(%)ymYnmY71{<;;;;;<<*<>;>****!}{L1YNNNff$%?TT/mJOK33jffffffffMMfM22222f2fjGfffMeoteawggQ
PPP$lVssJekxx4zzx4xzooootJJekJktkkktozzzzzzzzz4sKNNNOKQ%m?{{r!<<<<<<<<<<<<<<<<<<<<><;;>;<*****!|}}{1>           : CKG3jjfffffffffMMMMMMg2j3GfMMQJoJaaaggQ
jf2MEQQQEawt4@@4xxxxxoooooootottkkozzx4zzoxz4ox4XONOOOGghI7r}}LL|!!!!!!||!!||!**<<<<><*******!!!|}}}r              <<*********!||}|!}                :/KG3jjfffjM2222gggfK5OK3jMMPQa$gQEg
jgQasekx4@@@@@@@zx44xzoktootJJJJJeJJJktoo@@44xzz4G3K55NGG3GjjGGlYr{{|!!**<>;;;<;;><<<>!**|!*!!!**!!<<                 ==;;;><***!!!||}}|!!|!!|!!*=                 =::;Qg$$$Pgggg2f5ONNOOKgEPa$23G3Q$
CUhhhhhhh@@@@@h4zzzzzkkJJJeeJJJJtoo4x4xxz4xxzzkeVQ5OXOOONNXXXDXdddbXM\\r}!!*<*:                           =hh4hUVgQf3QQa@%ympkksk4C
Hi][CCCCh@@@@444xzzokkJJkkkokJJJeJtx4xxxoooCm;;; :>XXDDDDDXXNN3MfgE$ez4CyYr}!|!||||}}{{{{}L{}}!*<>>=:   :   :                     !x4zEGOK5OKQE@CzVQfjMls
)i[C@444xz44444@@xkV$$PEEPseJJkeeJooxxtokh}  =     pOXNNXXNNNNKK5j$Vtz)cTT{{}}}}}}}!}{L{{{L{}**<<>;=    :::::                        43OXNN55fasJJlgfjMas
piChxzxxtotzoJseJes$QgfKK5fskkkekxxz4ssh>=;:   :    KNONNNXXKKGGKfM$l4%mFTL{{{{}{{{}rLLL{L{}}*<<>;;;    ::==:      }Y\\\T*       :/?rrL<>=!IVEfgM2Q2fj2aV
(tssekoztotzVlaaawJVeQMKO5jatkkkktxksJ{ ;           33OOOO55NNOK5jfQQlhHymvn/rr{LL{r?1TTr{L{|*<*<>==:  :====:=  :?{TFF\\1{;     1/???TTT}}|!!|}{1u%Q5jfMM
CPEQEVwkto@htesVJJott$fO55Mstkea$$jC}< T>:          lQ3jGj3GKK5O5OK3j2zz@C[qyvFrTr11\?TrTL{}|**<><=:    ====;= 1?//!c%\/rL!    <}{}<               *;< >|rrrLLTT1TTrrrLLLLrLr{}!||
HiHqyyp(UVfO5jletkeI1{{r1??               r; =:     dO5jj22gfONDXNKG3MMMswt4CzxV$3NOfJU[I\r{LLrrr{!;;<*!}}                 ={>!}}{LrL{|}}{{TT1}{LrLrL{||}
sgjMfjjG5XNfkcTL}!|!!}/7                   *r1<:    dbNNONGfMfKXXNKj2EaltoC@C4z2KXbdOjozxez/T?\\?T}<;>>         <        | 1}|{LT1/\?\??TTTT1|LTrL{|}
MOamcYun/==<{!|||}!}1                       r ;\  !FCNDDdbbbbbdddDdOf2ex4kV$3dASAAAZdbSASSAAAASZbyycYmnm;          q1  r?1\7/TTL =LT1\/\??TTrT??\\7|LL}}}
Jvvmu\\cc; {TrLLL{}/                     ;!}u ;T7  17MDXZbDDbbbbbbddNOfjGOdZAAASSSSRRAAASSSSSAASSARbAjzY{;/Y7;=>  pY  }//77/?}}{}   |nr7TT1???1\7FFFL?TrT
cccv1}{\c= }?1{LrTLF                   \qYYvn L}Ycv7mL{XdXXDbbRRRRRZbNONNbRAAAAAAAAAASSSAASRRWAANVozt5Gn7i;7*!!|}}ryI%pF1{>y*{Fn I\!|}T1777//Tr}TT\/?;         /YYcYuYu7Y
7/\\Fu11y< !1\?\uuTY            qu\?7mvIycncm  !1\\/Y/?\;         :Ip\1/nmvpmcFmY; cm1  YYu>)SRSbHLY7VdbZZbbbZRRAAAAAZ(Y}Rg\1bASWSSSSASWS&17Fucmr !cIrr1L{r\/uu\\TTT\///7FcccT}/uFYYF}   SRRbRZbbYTr7mPRZZbRAAAr1 |???uImn?*}=    \7uIp\}TuFFmyYFF/n\|{c  cFFYY;5RRRRRRbZZZImu\uF/yTrXRSANFnO&SAAARRRRAAAA&Rp77TTuF{ \y7u/*;{T\/7F\1TT?\1\\/FnccYT*7F///\\?TT1Fc
|{* *\??Y{ *1?\YIIY*  =:   \FFpmTLFuFYcvm?1YyYc>* /n7FF7}4RRRARAAAbZAW{;>;\/7\aAAcYeS&AAARZbdbRRASSW&\FF7FyY= uvunT }T\\7/\?TrT1/\?7/7FuYcu>?//71?//1T\Fc
{/|  T1?u} ;??\YynL   !{}  !7cqur1YuYYYvc1r7mcu{  YYuF77\|ZWSSSA0sT>|:V6Ag7Fqv/?77Fa&WSARRRRASSSSASA6/uFFuu7  }cv1|>rFuF/7/\/TT\\?7777YYYYu/ \7F//F//T?uF
wRAASASSARRRRZbbOv#&W5(cvc$bW0a\|r{/kD9&&&mYnYYyc\ vYI\r{L/uu///7//TTr?/FFcYcccnYmF /1?7F\\1\uF
{}*T  L1u{{>}r?Yu   {T/FuFuFmyn\Tr/uYuFmmrLFnc   c77u !|> TZSASASS&RZAGQUIeW0SSSSWWlycI)OWASSb&90dE1|!}rF)Y  Yyn1T}1/777FF7/7/TT??F7uu7YuYYcu1    >TT/uuuYnmyyY7TT/FuccImr}\Yn <1uF1FuYuu?=M0SSAAAAAAARRAAAASWSSSSSSSSSSSASSSA0SDJpq/71!Yc1 I!Y?}{17uYFFuu//\?11?\?Y?///FFFFFT7 FFF71\/Y7
{*={;{  r{{;|!FT  {T/unuYnccvyu711?Funncc/}r/n:!}FY7uu//FF FFbAAAAAAAAAbRRRRWWSSSSSSSSSSSWWSWWW96 !   =!!:=}F} *r?7unnncmyycuF\T1/FYcymurL?F!T=77F/?\/77} nn7USAARbbDXXXdRASS&&WSSSSSWWWWWWSt;|T;YYYFYm{ vF1T{r?/7uuu777//\////?\\\?\1/\?//7T\? /?1T\/\
:!{< *   !;  r\|!}1FunnYYccvvvuu\\7//mmIvcTL17|1 FF7?1\777/:S&&YFuyXRXDDDDbASWW&&&WSSSSSWSWWH<mr1TrT?\FuFFF777F7/\\\\\1/1?/?11\?1r|r; r{1T{}
   L*    >:  ?\}}?FFunnYYvvmmvmuF7/\/7FmmcTL?\!F Tr{L//777\>aSSSSWC\YnjRbbZAWWWWWWSWSWSSS0c    |*{*    m\}r/cmcYYcvvvvvmmYYF7////ccc?TT7|F 1uu?//FF77>[SWWWWAAWa/}}?IDAS0SSSSSWASX|yWyuA0&WWRuuFFI1 \n=?1rL1\7FFu7\\\\\//?111111TTTrrrLT1T}}T>   = 
 =>   <>*    c\T/nmmmmcvmvvmvmmnmnuuFFYncc/rr?{Y *\1T//F/\/!ySSSSWSSSbd0Hcyuu1iD09Dx>{d&ZVm#0&&WWSKuFu7cr Fc;71LT\\FF7F/\\\\?\\111?Tr1Trr1?LLrTTL{}L     
=            cY7mcvmccmmmmmmmvmcYY/1rrrLrF\Tr1Fm =F7\77/\?u}\A&&A&NbeI}{TLLT:>>}\i;>4R6GycS&&&WWWSquu7u7: mp{/r}T??/77/?/\/F/?/111111TT1??111T17?{|rL    
!<           cccycYF/?\\/\1YmyqIIqcnnyvm1

python tplayer.py GourdBrothers.mp4
  ====:====;::{11\\////F//uF7?\/777FuFr<***><>;!*;<****!*!<*}LTr*>;<{rT{!|!!*}LT11rL{}*}}|!*Lr\F/?TL}|!r1rTrr11?r}*!!!!!L?T{{!!!!*!!<|rrr{LL|>}T1?T|!*<><**1\
 :**======;= }?\\\7//7/7//T!*T\//F1}<><*!<*>>><<<<>:T\\??r<;;=:?1r|<<**<***!<<<<>{T}!*<*}/uuuuY\1TrrL***>**{/YYuTL1r1T}|}}?T1T1
  :: !>;;>>>>>>;T/T|<>;;>>;;=;*|*!*|!***<<<{||!*!|}r\FuYYY/?1???T>><{L1Tr|{{}}}}}{{{{}|}/uuuuYYuYu\1?\1{}}}{{{1\1L{rrrTrrrrT1?\11TrL{r{{|*!}L}|!*<<<*<<<**<<<;;;;<****!***!!**<*******>!}!*}}*;*}};><*<*<>**|}}*|*!*|<|}!;=;><<<***|}!!}}||}}{rrr1F7FuFuncnYyY\T}{}|!|{L}}}|||r{{T1TL{TYnYunccY\//FFFuYu/TL{L{LT1?11\\???/uu/?TT1?r{{{|;=;><>>>;==>>;    >{|}!!  *{LrrL1uFuF/?{!{{rLLrr{r?1r!{}{r1r1 }*  rr\ncuYnncu\171r{{{rL1TTr1T11\111TTTT\\/uF7\?\}{{{}}!!||}!!*!!{}}FuYYYv!    (mnccncn\T11\\/
=<|}}}|}}}!***<>>;>*    <*<  :   >* *}|> ;L{{{{{r?r{|}{Lrrr?!  rrLTTTrTT11\Y;|: F??T\YYFT1TTTr{L{{rr11rr1?TrT?1T?111/uF7uYu\\T{}{{}}LTL!||!!!r1T{} *mYmI1 {|: cmccnYYY7Ync/\
:<}}{||}}!**<<<;>;;<  =:  := *}r=    :;: {{{{}{L{{{LLrrTTrrr11 : TuF7??/\\Y    7/?111TTTTLrrrrTrrr11TT1TrT/uu7?1\7umvvvvc\\1{}!}}}{?}}}|!{LT/F:   =Fncmv =*<<  HncYYYnYYu1T1
=<}}|!*!*!*!!>;;;::<   !!<>= {        :}}||}||{{rrTTTrrrrrT1T1n! * */??1ru=} H?1?1Tr1?1rTTrTrrT?\1rT11TTY1   =   (cymvvmuF/L}T11111{{}!}\  ;*|<= r/nqF  >;   =mcYYYYYYnF\T?1
 >!!|*}}|*<>;<>:=}*>>!   };   }*{r=  =T}!!!{{rrrrrTrLLTTTTrrTuYc)?;| |/?F1qm!    /T1TT11T1?TTT111T?1Y{<;  }||*>  [vvyvmcnrrT/F71r{}{}}rT17 }{<> r/Yc  =  c%uuYuuYF/rr1?11?1?
 >!|!}!*>>>>;=<}|>>;=;{      T>   =::   L{rLL{LrTrLLrrTTrL\? ci)pq%1<<<}!;>>>;!Tu<       ><=><*>  ={{{{r}rrLrrrTr|}7n%  ;!*}{!<>=>;;      \1T111TTTT111rrrTu   :    m:! ncmvvvmmmmcccccn\r{LL{11111T11LT\7 ; }TvL   |\|Lr}}}{rrrTTTT11
:>*!!***<*<<**<<<=  !!<<>;;;=< >rL{LL{{{LrTr{}|**/T1cq  }p#))#)%IcYF//?1T11TrrTTTT\Y     F?T1YI)Y  !> vqcvmmmmmmnncn1rLr1T1?1TrTTT?T1  ::  :><=::   :      !T{{{{{{{rr{}||!!<*T7F/7FFuu/q; =;  /rrT1rTT111TTTTrT1T}  ;}=  r;>L|<*r!< yycncnmY!{L{}}T??1T?T111?F |{< !    *| :L}}{LrrTTrrTTrr1/LT7
 =*||||||!!!*}!!{L1c!          =uFF7Fu\}   :Trr{{}|!!*}Lr?7FF7F7uur      \7>  }rT1TTTTTTTTr1\11nr *{T;;*||*!>   pnnnnFr|}}}L1/F\TuYu1\/\?{   FF{T= ;|;  }{{{Lr1T1T11rT1?TT1\
 >}{{|||}|}*1< =:  TT!   > *T?1/\//\F! !}!*  {{}|}|}rrr{L\?L|T??\1\7TT1/r  |T*  !rrTTrr\?\?T111rr1?     ;{*  FuFYur}!}}{!}1/FuuYYYn\//?1?7\\1uF< =}!}*  *{r/u?       =?rr1T\
:<}LL}}}||!!T*  {};  }}1}  L\\//\\7Y:;>=!>=  {}LrLLrTr}|}{*LTr{!|{TT!   ;<*}}< L{{{rLLT11TrTTTTr{LL{/= *{*> rLL{}{L{}}||!?7FuYnnnu\\1TrT?L  ? =;!|;       =><<*!!: ?T{\c
=>}Lr||}}}}|!}{7> >*=  ;  /?uuFFu7}  ;! *}|; {\1TrT{}{rrrL}       *L**=  <{< |/||}{}11T1rTrTrLrrL}}{1 ;TL!| }{{{}}{}LL}}\FFFFnncu11?1T1\Y > c!=/\m <*|;            >*= TLrum
;|{rL||{{{}}|!!{!n <**: :}{1 !<<<=  *|! <**= =F\Trr{LrTr}}\=  <>    |77 :  \{ ;{!}L}LrTTTrrrLLL{|}/u=!|>:** \\?Lrr}Lr1< !< ;> |<*7*;  ;*!   T{{{L{{/=!|= 1Lr/Yn
>*}}{!|{{}!{> *!!!!*{ ;<  = <>**!*= *LrrT1TT!|!|!!}| !L<    :<{L}!=  1LrrTT\TTTTTL}r{?L !}<  |LT1rL?uYu?F=!}<;<>   m !!*  TLL{rr1\:}|> *|}|*}{{!!}> {{Tr{T   <{|!<<>{ <**=!**<<}|*<  \rT1L!!!!!!}|}Y   }TL{{rrrrrT1?T1TTLLL1/= *L*  7{;T{  /}{T11r}TT?u>> 1rrr7u7?r\  *|||!}}{!|{}!|!!}r?= ;;; <* **>:  1rrr{}}}LTrLrLrT????TLLL{7u LLL!  L1}=}}> 1L111TrrL1?F     {rTLr{L1{    {11*    =<: !?{  =*!L}>: Tr}!7uuY
= <|}|> |= ;L;*!; Y LF <||<: :\rL!<*rLLT1TTc!*}< L|}}{}{Lr{{{{L\/11TrrrTr/* ;1r!! L|r! =;=! 7\1rTT\F7<=rL!<= 1LL{{L}rTT{/? *?  / <|! ;{|/!*}{|= ;}||*{F7uY
>!}L{}T   =!*!!}1  <*;<}; =   r:!!!  Y}  ;}|>=  \}LT1T{}TTTTL?;!}: r|}{rLL{{{{{{TT1TTTrLrTT7: >>*<  {}T7  <{<<<       <*|||}}L r{}rL{L{T7}  =  rT\= >*> L|r?;    }}!!{}1uF\1
{rL|!!r      |}{: <= T *<;=  *r;***   =;  !}!!  TT?T{L{{LLLrr?:r! !{}L{{{}}{{Lr{7/\TTrrTT{LTu!    <{{}?7c; ;}T{!|!!}{{L{!|}||  {}TTTrLrL *{* {TLr r}}}; /\??\{{r{{{rr{|}T{}T
{{*!**|= ;!}!>=     {{ ;}<  }|*;!*  |*;=;;>;<   :{{{LrLLrTr/Y!  1Lr?<  :{!! uF\1TL{{LLr{|!|}}}rT
<>*****}|  !}!*=   }*}<   ;**L:!||; < r\< *}!}: |!!!!!!\7/TT{ *; ={}}}}|!!||{{{{rTT1rL{T1?Trrr{}{{TT{}r?rrTTLLL11\\T17r1\1TL{}}{LLLLL}{r1 {rTLr\= |L}!|  u11rL}{}Lr!}}}}}}LL
=;**<<<<*{! =<****;  !*!*!!<*r*}L* >1  r{=}{}!; }!}r/\\//7r1 *  <}}}}}}}|}}|||T/\/7TrrT//\r{{L}{{L}{{TTLTLTL{{}}}}r/\{{{rTrr{{{{L{||{{TLrTL{L{{L\ }}L{!; 1rT{}}}{L{**{!!|}|{
=;*<<<<<<*!L: =<**!<  ***<<<<{>**  L= ;=:;!{|!; >}??\?\//r=!rL T||}}}}}}{|}|}\////71r1/7/\1{{{{L{}{{rrrTr1TL{}||}}FFL{{}{{{{Lr{{{{r{{Lrrr{{L{L{{17>{{}!: 1r{|}|}{{!<<{=!*>*} <|||{|!= |?1?\\r}!|}}||}|}}}{}||}{r}|?/\\//?Tr?\/7r{{{{TL{{}{1///7TLL{}}}}?7/\{{{L{{{{{LrL{rLrL{}{{{{LL{|}LT/{   ;{}}||LLL}*!!!!!|??\
=;*<>=<<<<|{!**!|*{} <>;;>>;;!|**<<<<}!  *!|}< >T1L}|}{!||||!*}}}{{}|!!|**!?\\\1TLL}L\1r{}}}{}LLLLrr?////1L{{{}|}?7/\{{{{}{Tr{L}}r{Lr{}}}}}{}{{}}}}}|L{{L}!}}}{}}!!}!**T??1?
==>>><><}}{}<<*!***<>><<*<;;<*<<<<*<*!!{*     <;;;rTL{L|!!|}}}}}}}}{LTT1T11?1//\TL{}}}!}?///r|{}}{r{}}{{LL{{}|}}}Tr{}{|!!}{{}}}}}<**!*<*!***<<**}rT111T}*!|!!****!|rL}!!*>;>*!!*!***!|}||LL{}}}}LTT1TT111?\\1}||||!{?7\L}}{{|}L{}{{*|{}|}}|}T1||r}!!}}L{Lr}|!!*!|!!****}LTT1\\1r}
>!|{LL}!<=>;<<<<>;;;;><<*<<<***<>{rr1TT1{*<**!*!**<><*<*!*<:<;;;>;><>;;;;>><<<*<<<>>>;>!!|*<==**><*<*rTT1L|{?T1TT{|!!|}{rLrrTT1L|!!}T111?T}*<|{r11TTTL!*!|!*!TT1??11{**}TrLr1{>}rr*|LTr|!<><}TTTTTTTTL!|!
!!!<*;=;=;=;;==;>=;;;>;;=;>><<;*|<>!{rTTrTTTT*<****<*<>;;*!*<;=:;|><<<|>>*LL{}**;*LTrTTTrrLLL{{
**||>====;=;;;;;;<*>;;;;;;>>><{LLL{LLrrrTrL{|***>><<><<<***<<<*<*<;>*<|rrTTT1T11}**>;;>><*!<>;>}LTrLrrrrrrrLL{
**|;:: ;||*=;**!!||*=====><*{rLLrLLLrrrrrLL{{LL*<>>;><><<*<<;><<*!>><<<**!!>>;>
><|;;<><<*<>>*<<<<<<<**>><{TrrrTrT}<{LrrT1!*<****<**<><<<***<><**|*<}rTTrT|<>>!{{rrLTrrrTTrL{LLLrLLrrr{LLrLrLL}>!
<<}}}}}}}}}}}}}{{|=;;;|{{{{{{LLLL{LLL{LL{{{{{{rr>><**<>>><<<**<*<<;>****>>{Trrrr{}}{{r{LTrrrrrrrrrL{rLLLrrTLLLLLLLL{}L1
<>><<>>*}rL|!}LL{LLLrrrrrLLL{LrrL{}**|{{rrr{{{L{LLTLrrrL*<<>>>>;>*<<<<<*<;;}{{rrLrr{{LLTrrrrTTrrLLLL{{L{LLL{LL{{{LL{{{{LT
<**!!!!||||!}}}};::<}}}}}}}}{{{{{{}}{{}{}}}{{}};;;>>|{{}}}{r{{{}{LLLL{{LLLLL{{T{{{{Lrrrrrrr{LLLL{{LrLrLLLL!;>>;;>>>>>><<<><>|{LLLLLLLLrrrLLLLrLLLLLLLL{{{{{L{{{L{{{{{{{L{{LT
;<*!!!!|||!|||}|;:<}}|}}}}}}{{}{}}}}}}}}}}}}}}!=;<|{{}{}{{{{{{{{{LrLLLLLT{LL{{{{{rL{{{rLLrLrLL{{rL{{r{{{{L{**!!!;;;>>>><<;;>;;;*}}{{{{{{{LL{{{{L{{{{{{LL{{{{{{{{{{}}}{{}}}}}}}}}{{}r
;>*!!!!!!!!!!!!!!||!|}}}}}||}|}||}}}}}}}}}}}}}}}}}}}}}{{{{{L{{{{{{}{{{{LL{{{L{{{{{{L{{{{{{{{{{L{{{{{{{L{{{{}}}!==;>=;;|}}}}{{{{{{}}{{{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}}}}}{{{{r
=;<***!!!!!*!!!!!!!*||!!}}||}}||||}}}}}}}}}}}}}}}}}}{{}{{{}{{{{{{{}{{{{{{{{{{L{{{L{{{{{{{{{{{{{{{{{{{{{{{{{}}}}**;;=;|{{{{{{{{{r{{{{{{{{{{{}}}}{}{}{}}}}}}}}}}}}}}}}}}}}}L{r
;;><*!!******!!!!!!!!!!!!!!|||}!|!|||}}}}||}}}}}}}}}}{}|}}}}}}}}}{{{}{{{{{{{{{{{{{{{{{{{{{{{{{{{{{}{{{{{{{}}}}}{!>=<}}}{{{{{{{{}}{{{{{LLLL{{{{{{{{{{{{{}|||}}}}}}}}}}}}}|}{L

原理分析 :

1. 首先对所有可打印的ASCII字符进行取模
2. 根据占据的像素以及整个字符占用的空间计算出像素占比
3. 排序得到图像灰度和ASCII的映射关系
4. 对单个图像来说 , 首先将图像转为灰度图 , 然后对图像大小进行调整 , 然后逐个字符进行映射即可
5. 对视频来说 , 首先将视频逐帧分解 , 得到每一帧的图像 , 利用处理单个图像的方法进行处理 , 最后根据帧率进行播放即可
6. 播放视频的时候需要在帧与帧的间隔对屏幕进行清空处理

你可能感兴趣的:(Linux 终端下使用 Python 看葫芦娃)