3 # Print some info about a CMIF movie file
8 # Vinfo [-d] [-q] [-s] [-t] [file] ...
13 # -d : print deltas between frames instead of frame times
14 # -q : quick: don't read the frames
15 # -s : don't print times (but do count frames and print the total)
16 # -t : terse (one line/file, implies -s)
17 # file ... : file(s) to inspect; default film.video
21 sys
.path
.append('/ufs/guido/src/video')
36 # Main program -- mostly command line parsing
39 global short
, quick
, delta
, terse
, maxwidth
41 opts
, args
= getopt
.getopt(sys
.argv
[1:], 'dqst')
42 except getopt
.error
, msg
:
43 sys
.stdout
= sys
.stderr
45 print 'usage: Vinfo [-d] [-q] [-s] [-t] [file] ...'
59 maxwidth
= max(maxwidth
, len(filename
))
69 def process(filename
):
71 vin
= VFile
.RandomVinFile(filename
)
73 sys
.stderr
.write(filename
+ ': I/O error: ' + `msg`
+ '\n')
75 except VFile
.Error
, msg
:
76 sys
.stderr
.write(msg
+ '\n')
79 sys
.stderr
.write(filename
+ ': EOF in video file\n')
83 print string
.ljust(filename
, maxwidth
),
84 kbytes
= (VFile
.getfilesize(filename
) + 1023) / 1024
85 print string
.rjust(`kbytes`
, 5) + 'K',
86 print ' ', string
.ljust(`vin
.version`
, 5),
87 print string
.ljust(vin
.format
, 8),
88 print string
.rjust(`vin
.width`
, 4),
89 print string
.rjust(`vin
.height`
, 4),
90 if type(vin
.packfactor
) == type(()):
91 xpf
, ypf
= vin
.packfactor
92 s
= string
.rjust(`xpf`
, 2) + ',' + \
93 string
.rjust(`ypf`
, 2)
95 s
= string
.rjust(`vin
.packfactor`
, 2)
96 if type(vin
.packfactor
) == type(0) and \
97 vin
.format
not in ('rgb', 'jpeg') and \
98 (vin
.width
/vin
.packfactor
) % 4 <> 0:
116 print '[Using cached index]'
119 print '[Constructing index on the fly]'
123 print 'Frame time deltas:',
125 print 'Frame times:',
133 t
, ds
, cs
= vin
.getnextframeheader()
134 vin
.skipnextframedata(ds
, cs
)
137 datasize
= datasize
+ ds
138 if cs
: datasize
= datasize
+ cs
141 sys
.stdout
.write('\n')
143 sys
.stdout
.write('\t' + `t
- told`
)
146 sys
.stdout
.write('\t' + `t`
)
152 print string
.rjust(`n`
, 6),
153 if t
: print string
.rjust(`
int(n
*10000.0/t
)*0.1`
, 5),
156 print 'Total', n
, 'frames in', t
*0.001, 'sec.',
157 if t
: print '-- average', int(n
*10000.0/t
)*0.1, 'frames/sec',
159 print 'Total data', 0.1 * int(datasize
/ 102.4), 'Kbytes',
162 print 0.1 * int(datasize
/ 0.1024 / t
), 'Kbytes/sec',
169 # Don't forget to call the main program
173 except KeyboardInterrupt: