diff options
author | Guido van Rossum <guido@python.org> | 1991-11-04 14:30:51 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1991-11-04 14:30:51 (GMT) |
commit | 27cb9916dbf04e94161d520c2b3569f9edbb081b (patch) | |
tree | 8f874da95f9c6def93a69da95e2c348f60e35ef4 /Demo/sgi | |
parent | b51afcc5c499e90a7a94cd1a67a27af9ae28be1b (diff) | |
download | cpython-27cb9916dbf04e94161d520c2b3569f9edbb081b.zip cpython-27cb9916dbf04e94161d520c2b3569f9edbb081b.tar.gz cpython-27cb9916dbf04e94161d520c2b3569f9edbb081b.tar.bz2 |
Made it work for more cases.
Diffstat (limited to 'Demo/sgi')
-rwxr-xr-x | Demo/sgi/video/vinfo.py | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/Demo/sgi/video/vinfo.py b/Demo/sgi/video/vinfo.py index 98b29fa..196a0da 100755 --- a/Demo/sgi/video/vinfo.py +++ b/Demo/sgi/video/vinfo.py @@ -1,4 +1,3 @@ -#!/ufs/guido/bin/sgi/python3.3 from gl import * from GL import * from DEVICE import * @@ -10,36 +9,52 @@ epoch = Struct() EndOfFile = 'End of file' bye = 'bye' -def openvideo(name): - f = open(name, 'r') - w, h = eval(f.readline()[:-1]) - return f, w, h -def loadframe(f, w, h): - tijd = f.readline() - if tijd = '': +def openvideo(filename): + f = open(filename, 'r') + line = f.readline() + if not line: raise EndOfFile + if line[:4] = 'CMIF': line = f.readline() + x = eval(line[:-1]) + if len(x) = 3: w, h, pf = x + else: w, h = x; pf = 2 + return f, w, h, pf + +def loadframe(f, w, h, pf): + line = f.readline() + if line = '': raise EndOfFile - tijd = eval(tijd[:-1]) - f.seek(w*h*4,1) + x = eval(line[:-1]) + if type(x) = type(0) or type(x) = type(0.0): + tijd = x + if pf = 0: + size = w*h*4 + else: + size = (w/pf) * (h/pf) + else: + tijd, size = x + f.seek(size, 1) return tijd + def saveframe(name, w, h, tijd, data): f = open(name, 'w') f.write(`w,h` + '\n') f.write(`tijd` + '\n') f.write(data) f.close() + def main(): if len(sys.argv) > 1: names = sys.argv[1:] else: names = ['film.video'] for name in names: - f, w, h = openvideo(name) - print name+': '+`w`+'x'+`h` + f, w, h, pf = openvideo(name) + print name, ':', w, 'x', h, '; pf =', pf num = 0 try: while 1: try: - tijd = loadframe(f, w, h) + tijd = loadframe(f, w, h, pf) print '\t', tijd, num = num + 1 if num % 8 = 0: |