1992-08-18 14:01:02 -03:00
|
|
|
#! /usr/local/python
|
|
|
|
|
|
|
|
# Print some info about a CMIF movie file
|
|
|
|
|
|
|
|
|
|
|
|
# Usage:
|
|
|
|
#
|
|
|
|
# Vinfo [-d] [-q] [-s] [file] ...
|
|
|
|
|
|
|
|
|
|
|
|
# Options:
|
|
|
|
#
|
|
|
|
# -d : print deltas between frames instead of frame times
|
|
|
|
# -q : quick: don't read the frames
|
|
|
|
# -s : don't print times (but do count frames and print the total)
|
|
|
|
# file ... : file(s) to inspect; default film.video
|
|
|
|
|
|
|
|
|
1992-08-18 11:16:12 -03:00
|
|
|
import sys
|
1992-08-18 14:01:02 -03:00
|
|
|
sys.path.append('/ufs/guido/src/video')
|
1992-08-18 11:16:12 -03:00
|
|
|
import VFile
|
1992-08-18 14:01:02 -03:00
|
|
|
import getopt
|
|
|
|
|
|
|
|
|
|
|
|
# Global options
|
|
|
|
|
|
|
|
short = 0
|
|
|
|
quick = 0
|
1992-08-18 18:11:18 -03:00
|
|
|
delta = 0
|
1992-08-18 14:01:02 -03:00
|
|
|
|
|
|
|
|
|
|
|
# Main program -- mostly command line parsing
|
1992-08-18 11:16:12 -03:00
|
|
|
|
|
|
|
def main():
|
1992-08-18 18:11:18 -03:00
|
|
|
global short, quick, delta
|
1992-08-18 14:01:02 -03:00
|
|
|
opts, args = getopt.getopt(sys.argv[1:], 'dqs')
|
|
|
|
for opt, arg in opts:
|
|
|
|
if opt == '-q':
|
|
|
|
quick = 1
|
|
|
|
elif opt == '-d':
|
1992-08-18 18:11:18 -03:00
|
|
|
delta = 1
|
1992-08-18 14:01:02 -03:00
|
|
|
elif opt == '-s':
|
|
|
|
short = 1
|
|
|
|
if not args:
|
|
|
|
args = ['film.video']
|
1992-08-20 08:49:58 -03:00
|
|
|
sts = 0
|
1992-08-18 14:01:02 -03:00
|
|
|
for filename in args:
|
1992-08-20 08:49:58 -03:00
|
|
|
if process(filename):
|
|
|
|
sts = 1
|
|
|
|
sys.exit(sts)
|
1992-08-18 14:01:02 -03:00
|
|
|
|
|
|
|
|
|
|
|
# Process one file
|
1992-08-18 11:16:12 -03:00
|
|
|
|
|
|
|
def process(filename):
|
1992-08-18 18:11:18 -03:00
|
|
|
try:
|
|
|
|
vin = VFile.VinFile().init(filename)
|
|
|
|
except IOError, msg:
|
|
|
|
sys.stderr.write(filename + ': I/O error: ' + `msg` + '\n')
|
1992-08-20 08:49:58 -03:00
|
|
|
return 1
|
1992-08-18 18:11:18 -03:00
|
|
|
except VFile.Error, msg:
|
|
|
|
sys.stderr.write(msg + '\n')
|
1992-08-20 08:49:58 -03:00
|
|
|
return 1
|
1992-08-18 18:11:18 -03:00
|
|
|
except EOFError:
|
|
|
|
sys.stderr.write(filename + ': EOF in video file\n')
|
1992-08-20 08:49:58 -03:00
|
|
|
return 1
|
|
|
|
|
1992-09-07 06:35:23 -03:00
|
|
|
vin.printinfo()
|
1992-08-20 08:49:58 -03:00
|
|
|
|
1992-08-18 14:01:02 -03:00
|
|
|
if quick:
|
|
|
|
vin.close()
|
|
|
|
return
|
1992-08-20 08:49:58 -03:00
|
|
|
|
1992-08-18 14:01:02 -03:00
|
|
|
if not short:
|
1992-08-18 18:11:18 -03:00
|
|
|
if delta:
|
|
|
|
print 'Frame time deltas:',
|
|
|
|
else:
|
|
|
|
print 'Frame times:',
|
1992-08-20 08:49:58 -03:00
|
|
|
|
1992-08-18 11:16:12 -03:00
|
|
|
n = 0
|
|
|
|
t = 0
|
1992-08-18 14:01:02 -03:00
|
|
|
told = 0
|
1992-08-20 08:49:58 -03:00
|
|
|
datasize = 0
|
1992-08-18 11:16:12 -03:00
|
|
|
while 1:
|
|
|
|
try:
|
|
|
|
t, data, cdata = vin.getnextframe()
|
|
|
|
except EOFError:
|
|
|
|
break
|
1992-08-20 08:49:58 -03:00
|
|
|
datasize = datasize + len(data)
|
|
|
|
if cdata: datasize = datasize + len(cdata)
|
1992-08-18 14:01:02 -03:00
|
|
|
if not short:
|
|
|
|
if n%8 == 0:
|
|
|
|
sys.stdout.write('\n')
|
|
|
|
if delta:
|
|
|
|
sys.stdout.write('\t' + `t - told`)
|
|
|
|
told = t
|
|
|
|
else:
|
|
|
|
sys.stdout.write('\t' + `t`)
|
1992-08-18 11:16:12 -03:00
|
|
|
n = n+1
|
1992-08-20 08:49:58 -03:00
|
|
|
|
|
|
|
if not short: print
|
|
|
|
|
1992-08-18 11:16:12 -03:00
|
|
|
print 'Total', n, 'frames in', t*0.001, 'sec.',
|
1992-08-20 08:49:58 -03:00
|
|
|
if t: print '-- average', int(n*10000.0/t)*0.1, 'frames/sec',
|
|
|
|
print
|
|
|
|
print 'Total data', 0.1 * int(datasize / 102.4), 'Kbytes',
|
1992-08-18 11:16:12 -03:00
|
|
|
if t:
|
1992-08-20 08:49:58 -03:00
|
|
|
print '-- average',
|
|
|
|
print 0.1 * int(datasize / 0.1024 / t), 'Kbytes/sec',
|
1992-08-18 11:16:12 -03:00
|
|
|
print
|
1992-08-20 08:49:58 -03:00
|
|
|
|
1992-08-18 14:01:02 -03:00
|
|
|
vin.close()
|
|
|
|
|
|
|
|
|
|
|
|
# Don't forget to call the main program
|
1992-08-18 11:16:12 -03:00
|
|
|
|
1992-09-01 11:45:57 -03:00
|
|
|
try:
|
|
|
|
main()
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
print '[Interrupt]'
|