mirror of https://github.com/python/cpython
Made it work for more cases.
This commit is contained in:
parent
b51afcc5c4
commit
27cb9916db
|
@ -1,4 +1,3 @@
|
||||||
#!/ufs/guido/bin/sgi/python3.3
|
|
||||||
from gl import *
|
from gl import *
|
||||||
from GL import *
|
from GL import *
|
||||||
from DEVICE import *
|
from DEVICE import *
|
||||||
|
@ -10,36 +9,52 @@ epoch = Struct()
|
||||||
EndOfFile = 'End of file'
|
EndOfFile = 'End of file'
|
||||||
bye = 'bye'
|
bye = 'bye'
|
||||||
|
|
||||||
def openvideo(name):
|
def openvideo(filename):
|
||||||
f = open(name, 'r')
|
f = open(filename, 'r')
|
||||||
w, h = eval(f.readline()[:-1])
|
line = f.readline()
|
||||||
return f, w, h
|
if not line: raise EndOfFile
|
||||||
def loadframe(f, w, h):
|
if line[:4] = 'CMIF': line = f.readline()
|
||||||
tijd = f.readline()
|
x = eval(line[:-1])
|
||||||
if tijd = '':
|
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
|
raise EndOfFile
|
||||||
tijd = eval(tijd[:-1])
|
x = eval(line[:-1])
|
||||||
f.seek(w*h*4,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
|
return tijd
|
||||||
|
|
||||||
def saveframe(name, w, h, tijd, data):
|
def saveframe(name, w, h, tijd, data):
|
||||||
f = open(name, 'w')
|
f = open(name, 'w')
|
||||||
f.write(`w,h` + '\n')
|
f.write(`w,h` + '\n')
|
||||||
f.write(`tijd` + '\n')
|
f.write(`tijd` + '\n')
|
||||||
f.write(data)
|
f.write(data)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
names = sys.argv[1:]
|
names = sys.argv[1:]
|
||||||
else:
|
else:
|
||||||
names = ['film.video']
|
names = ['film.video']
|
||||||
for name in names:
|
for name in names:
|
||||||
f, w, h = openvideo(name)
|
f, w, h, pf = openvideo(name)
|
||||||
print name+': '+`w`+'x'+`h`
|
print name, ':', w, 'x', h, '; pf =', pf
|
||||||
num = 0
|
num = 0
|
||||||
try:
|
try:
|
||||||
while 1:
|
while 1:
|
||||||
try:
|
try:
|
||||||
tijd = loadframe(f, w, h)
|
tijd = loadframe(f, w, h, pf)
|
||||||
print '\t', tijd,
|
print '\t', tijd,
|
||||||
num = num + 1
|
num = num + 1
|
||||||
if num % 8 = 0:
|
if num % 8 = 0:
|
||||||
|
|
Loading…
Reference in New Issue