blob: d20d93fa5fe68f01be833829ac8d10787bfeb885 [file] [log] [blame]
Guido van Rossum82534fd1992-08-18 17:01:02 +00001#! /usr/local/python
2
3# Print some info about a CMIF movie file
4
5
6# Usage:
7#
8# Vinfo [-d] [-q] [-s] [file] ...
9
10
11# Options:
12#
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# file ... : file(s) to inspect; default film.video
17
18
Guido van Rossum843d1531992-08-18 14:16:12 +000019import sys
Guido van Rossum82534fd1992-08-18 17:01:02 +000020sys.path.append('/ufs/guido/src/video')
Guido van Rossum843d1531992-08-18 14:16:12 +000021import VFile
Guido van Rossum82534fd1992-08-18 17:01:02 +000022import getopt
23
24
25# Global options
26
27short = 0
28quick = 0
Guido van Rossum7268c931992-08-18 21:11:18 +000029delta = 0
Guido van Rossum82534fd1992-08-18 17:01:02 +000030
31
32# Main program -- mostly command line parsing
Guido van Rossum843d1531992-08-18 14:16:12 +000033
34def main():
Guido van Rossum7268c931992-08-18 21:11:18 +000035 global short, quick, delta
Guido van Rossum82534fd1992-08-18 17:01:02 +000036 opts, args = getopt.getopt(sys.argv[1:], 'dqs')
37 for opt, arg in opts:
38 if opt == '-q':
39 quick = 1
40 elif opt == '-d':
Guido van Rossum7268c931992-08-18 21:11:18 +000041 delta = 1
Guido van Rossum82534fd1992-08-18 17:01:02 +000042 elif opt == '-s':
43 short = 1
44 if not args:
45 args = ['film.video']
46 for filename in args:
47 process(filename)
48
49
50# Process one file
Guido van Rossum843d1531992-08-18 14:16:12 +000051
52def process(filename):
Guido van Rossum7268c931992-08-18 21:11:18 +000053 try:
54 vin = VFile.VinFile().init(filename)
55 except IOError, msg:
56 sys.stderr.write(filename + ': I/O error: ' + `msg` + '\n')
57 return
58 except VFile.Error, msg:
59 sys.stderr.write(msg + '\n')
60 return
61 except EOFError:
62 sys.stderr.write(filename + ': EOF in video file\n')
63 return
Guido van Rossum843d1531992-08-18 14:16:12 +000064 print 'File: ', filename
65 print 'Version: ', vin.version
66 print 'Size: ', vin.width, 'x', vin.height
67 print 'Pack: ', vin.packfactor, '; chrom:', vin.chrompack
68 print 'Bits: ', vin.c0bits, vin.c1bits, vin.c2bits
69 print 'Format: ', vin.format
70 print 'Offset: ', vin.offset
Guido van Rossum82534fd1992-08-18 17:01:02 +000071 if quick:
72 vin.close()
73 return
74 if not short:
Guido van Rossum7268c931992-08-18 21:11:18 +000075 if delta:
76 print 'Frame time deltas:',
77 else:
78 print 'Frame times:',
Guido van Rossum843d1531992-08-18 14:16:12 +000079 n = 0
80 t = 0
Guido van Rossum82534fd1992-08-18 17:01:02 +000081 told = 0
Guido van Rossum843d1531992-08-18 14:16:12 +000082 while 1:
83 try:
84 t, data, cdata = vin.getnextframe()
85 except EOFError:
Guido van Rossum82534fd1992-08-18 17:01:02 +000086 if not short:
87 print
Guido van Rossum843d1531992-08-18 14:16:12 +000088 break
Guido van Rossum82534fd1992-08-18 17:01:02 +000089 if not short:
90 if n%8 == 0:
91 sys.stdout.write('\n')
92 if delta:
93 sys.stdout.write('\t' + `t - told`)
94 told = t
95 else:
96 sys.stdout.write('\t' + `t`)
Guido van Rossum843d1531992-08-18 14:16:12 +000097 n = n+1
98 print 'Total', n, 'frames in', t*0.001, 'sec.',
99 if t:
100 print '-- average', int(n*10000.0/t)*0.1, 'frames/sec',
101 print
Guido van Rossum82534fd1992-08-18 17:01:02 +0000102 vin.close()
103
104
105# Don't forget to call the main program
Guido van Rossum843d1531992-08-18 14:16:12 +0000106
107main()