10 EndOfFile
= 'End of file'
13 def openvideo(filename
):
14 f
= open(filename
, 'r')
16 if not line
: raise EndOfFile
17 if line
[:4] == 'CMIF': line
= f
.readline()
19 if len(x
) == 3: w
, h
, pf
= x
20 else: w
, h
= x
; pf
= 2
23 def loadframe(f
, w
, h
, pf
):
28 if type(x
) == type(0) or type(x
) == type(0.0):
33 size
= (w
/pf
) * (h
/pf
)
43 opts
, names
= getopt
.getopt(sys
.argv
[1:], 'ds')
44 except getopt
.error
, msg
:
45 sys
.stderr
.write(msg
+ '\n')
46 sys
.stderr
.write('usage: vinfo [-d] [-s] [file] ...\n')
49 if opt
== '-d': delta
= 1 # print delta between frames
50 elif opt
== '-s': short
= 1 # short: don't print times
52 names
= ['film.video']
55 f
, w
, h
, pf
= openvideo(name
)
57 sys
.stderr
.write(name
+ ': cannot open\n')
62 size
= (w
/pf
) * (h
/pf
)
63 print name
, ':', w
, 'x', h
, '; pf =', pf
, ', size =', size
,
67 print '(' + `
(w
/pf
)`
+ 'x' + `
(h
/pf
)`
+ ')',
68 if (w
/pf
)%4 <> 0: print '!!!',
75 tijd
= loadframe(f
, w
, h
, pf
)
76 if delta
: print '\t' + `tijd
-otijd`
,
77 else: print '\t' + `tijd`
,