Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 27cb991

Browse files
committed
Made it work for more cases.
1 parent b51afcc commit 27cb991

1 file changed

Lines changed: 28 additions & 13 deletions

File tree

Demo/sgi/video/vinfo.py

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/ufs/guido/bin/sgi/python3.3
21
from gl import *
32
from GL import *
43
from DEVICE import *
@@ -10,36 +9,52 @@ class Struct(): pass
109
EndOfFile = 'End of file'
1110
bye = 'bye'
1211

13-
def openvideo(name):
14-
f = open(name, 'r')
15-
w, h = eval(f.readline()[:-1])
16-
return f, w, h
17-
def loadframe(f, w, h):
18-
tijd = f.readline()
19-
if tijd = '':
12+
def openvideo(filename):
13+
f = open(filename, 'r')
14+
line = f.readline()
15+
if not line: raise EndOfFile
16+
if line[:4] = 'CMIF': line = f.readline()
17+
x = eval(line[:-1])
18+
if len(x) = 3: w, h, pf = x
19+
else: w, h = x; pf = 2
20+
return f, w, h, pf
21+
22+
def loadframe(f, w, h, pf):
23+
line = f.readline()
24+
if line = '':
2025
raise EndOfFile
21-
tijd = eval(tijd[:-1])
22-
f.seek(w*h*4,1)
26+
x = eval(line[:-1])
27+
if type(x) = type(0) or type(x) = type(0.0):
28+
tijd = x
29+
if pf = 0:
30+
size = w*h*4
31+
else:
32+
size = (w/pf) * (h/pf)
33+
else:
34+
tijd, size = x
35+
f.seek(size, 1)
2336
return tijd
37+
2438
def saveframe(name, w, h, tijd, data):
2539
f = open(name, 'w')
2640
f.write(`w,h` + '\n')
2741
f.write(`tijd` + '\n')
2842
f.write(data)
2943
f.close()
44+
3045
def main():
3146
if len(sys.argv) > 1:
3247
names = sys.argv[1:]
3348
else:
3449
names = ['film.video']
3550
for name in names:
36-
f, w, h = openvideo(name)
37-
print name+': '+`w`+'x'+`h`
51+
f, w, h, pf = openvideo(name)
52+
print name, ':', w, 'x', h, '; pf =', pf
3853
num = 0
3954
try:
4055
while 1:
4156
try:
42-
tijd = loadframe(f, w, h)
57+
tijd = loadframe(f, w, h, pf)
4358
print '\t', tijd,
4459
num = num + 1
4560
if num % 8 = 0:

0 commit comments

Comments
 (0)