1991-10-30 07:52:48 -04:00
|
|
|
from gl import *
|
|
|
|
from GL import *
|
|
|
|
from DEVICE import *
|
|
|
|
import time
|
|
|
|
import sys
|
1991-11-06 12:13:02 -04:00
|
|
|
import getopt
|
1991-10-30 07:52:48 -04:00
|
|
|
|
|
|
|
class Struct(): pass
|
|
|
|
epoch = Struct()
|
|
|
|
EndOfFile = 'End of file'
|
|
|
|
bye = 'bye'
|
|
|
|
|
1991-11-04 10:30:51 -04:00
|
|
|
def openvideo(filename):
|
|
|
|
f = open(filename, 'r')
|
|
|
|
line = f.readline()
|
|
|
|
if not line: raise EndOfFile
|
1992-02-11 10:50:22 -04:00
|
|
|
if line[:4] == 'CMIF': line = f.readline()
|
1991-11-04 10:30:51 -04:00
|
|
|
x = eval(line[:-1])
|
1992-02-11 10:50:22 -04:00
|
|
|
if len(x) == 3: w, h, pf = x
|
1991-11-04 10:30:51 -04:00
|
|
|
else: w, h = x; pf = 2
|
|
|
|
return f, w, h, pf
|
|
|
|
|
|
|
|
def loadframe(f, w, h, pf):
|
|
|
|
line = f.readline()
|
1992-02-11 10:50:22 -04:00
|
|
|
if line == '':
|
1991-10-30 07:52:48 -04:00
|
|
|
raise EndOfFile
|
1991-11-04 10:30:51 -04:00
|
|
|
x = eval(line[:-1])
|
1992-02-11 10:50:22 -04:00
|
|
|
if type(x) == type(0) or type(x) == type(0.0):
|
1991-11-04 10:30:51 -04:00
|
|
|
tijd = x
|
1992-02-11 10:50:22 -04:00
|
|
|
if pf == 0:
|
1991-11-04 10:30:51 -04:00
|
|
|
size = w*h*4
|
|
|
|
else:
|
|
|
|
size = (w/pf) * (h/pf)
|
|
|
|
else:
|
|
|
|
tijd, size = x
|
|
|
|
f.seek(size, 1)
|
1991-10-30 07:52:48 -04:00
|
|
|
return tijd
|
1991-11-04 10:30:51 -04:00
|
|
|
|
1991-10-30 07:52:48 -04:00
|
|
|
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()
|
1991-11-04 10:30:51 -04:00
|
|
|
|
1991-10-30 07:52:48 -04:00
|
|
|
def main():
|
1991-11-06 12:13:02 -04:00
|
|
|
delta = 0
|
|
|
|
opts, names = getopt.getopt(sys.argv[1:], 'd')
|
|
|
|
for opt, arg in opts:
|
1992-02-11 10:50:22 -04:00
|
|
|
if opt == '-d': delta = 1
|
|
|
|
if names == []:
|
1991-10-30 07:52:48 -04:00
|
|
|
names = ['film.video']
|
|
|
|
for name in names:
|
1991-11-06 12:13:02 -04:00
|
|
|
try:
|
|
|
|
f, w, h, pf = openvideo(name)
|
|
|
|
except:
|
|
|
|
sys.stderr.write(name + ': cannot open\n')
|
|
|
|
continue
|
1991-11-04 10:30:51 -04:00
|
|
|
print name, ':', w, 'x', h, '; pf =', pf
|
1991-10-30 07:52:48 -04:00
|
|
|
num = 0
|
|
|
|
try:
|
1991-11-06 12:13:02 -04:00
|
|
|
otijd = 0
|
1991-10-30 07:52:48 -04:00
|
|
|
while 1:
|
|
|
|
try:
|
1991-11-04 10:30:51 -04:00
|
|
|
tijd = loadframe(f, w, h, pf)
|
1991-11-06 12:13:02 -04:00
|
|
|
if delta: print '\t', tijd-otijd,
|
|
|
|
else: print '\t', tijd,
|
|
|
|
otijd = tijd
|
1991-10-30 07:52:48 -04:00
|
|
|
num = num + 1
|
1992-02-11 10:50:22 -04:00
|
|
|
if num % 8 == 0:
|
1991-10-30 07:52:48 -04:00
|
|
|
print
|
|
|
|
except EndOfFile:
|
|
|
|
raise bye
|
|
|
|
except bye:
|
|
|
|
pass
|
|
|
|
if num % 8 <> 0:
|
|
|
|
print
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
main()
|