blob: 2aec8032ae784f26fd2729b7b04107ff1f00e872 [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
29diffs = 0
30
31
32# Main program -- mostly command line parsing
Guido van Rossum843d1531992-08-18 14:16:12 +000033
34def main():
Guido van Rossum82534fd1992-08-18 17:01:02 +000035 global short, quick, diffs
36 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':
41 diffs = 1
42 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):
53 vin = VFile.VinFile().init(filename)
54 print 'File: ', filename
55 print 'Version: ', vin.version
56 print 'Size: ', vin.width, 'x', vin.height
57 print 'Pack: ', vin.packfactor, '; chrom:', vin.chrompack
58 print 'Bits: ', vin.c0bits, vin.c1bits, vin.c2bits
59 print 'Format: ', vin.format
60 print 'Offset: ', vin.offset
Guido van Rossum82534fd1992-08-18 17:01:02 +000061 if quick:
62 vin.close()
63 return
64 if not short:
65 print 'Frame times:',
Guido van Rossum843d1531992-08-18 14:16:12 +000066 n = 0
67 t = 0
Guido van Rossum82534fd1992-08-18 17:01:02 +000068 told = 0
Guido van Rossum843d1531992-08-18 14:16:12 +000069 while 1:
70 try:
71 t, data, cdata = vin.getnextframe()
72 except EOFError:
Guido van Rossum82534fd1992-08-18 17:01:02 +000073 if not short:
74 print
Guido van Rossum843d1531992-08-18 14:16:12 +000075 break
Guido van Rossum82534fd1992-08-18 17:01:02 +000076 if not short:
77 if n%8 == 0:
78 sys.stdout.write('\n')
79 if delta:
80 sys.stdout.write('\t' + `t - told`)
81 told = t
82 else:
83 sys.stdout.write('\t' + `t`)
Guido van Rossum843d1531992-08-18 14:16:12 +000084 n = n+1
85 print 'Total', n, 'frames in', t*0.001, 'sec.',
86 if t:
87 print '-- average', int(n*10000.0/t)*0.1, 'frames/sec',
88 print
Guido van Rossum82534fd1992-08-18 17:01:02 +000089 vin.close()
90
91
92# Don't forget to call the main program
Guido van Rossum843d1531992-08-18 14:16:12 +000093
94main()