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

Skip to content

Commit 6f00a31

Browse files
committed
Introduced getopt.
Added -d option: print deltas instead of absolute times.
1 parent b3c493c commit 6f00a31

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

Demo/sgi/video/vinfo.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from DEVICE import *
44
import time
55
import sys
6+
import getopt
67

78
class Struct(): pass
89
epoch = Struct()
@@ -43,19 +44,28 @@ def saveframe(name, w, h, tijd, data):
4344
f.close()
4445

4546
def main():
46-
if len(sys.argv) > 1:
47-
names = sys.argv[1:]
48-
else:
47+
delta = 0
48+
opts, names = getopt.getopt(sys.argv[1:], 'd')
49+
for opt, arg in opts:
50+
if opt = '-d': delta = 1
51+
if names = []:
4952
names = ['film.video']
5053
for name in names:
51-
f, w, h, pf = openvideo(name)
54+
try:
55+
f, w, h, pf = openvideo(name)
56+
except:
57+
sys.stderr.write(name + ': cannot open\n')
58+
continue
5259
print name, ':', w, 'x', h, '; pf =', pf
5360
num = 0
5461
try:
62+
otijd = 0
5563
while 1:
5664
try:
5765
tijd = loadframe(f, w, h, pf)
58-
print '\t', tijd,
66+
if delta: print '\t', tijd-otijd,
67+
else: print '\t', tijd,
68+
otijd = tijd
5969
num = num + 1
6070
if num % 8 = 0:
6171
print

0 commit comments

Comments
 (0)