mirror of
https://github.com/python/cpython.git
synced 2025-07-31 07:04:42 +00:00
Added -p packfactor and -l (looping) options.
This commit is contained in:
parent
7d435fee60
commit
5dafd916f2
1 changed files with 31 additions and 6 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import getopt
|
||||||
from gl import *
|
from gl import *
|
||||||
from GL import *
|
from GL import *
|
||||||
from DEVICE import *
|
from DEVICE import *
|
||||||
|
@ -72,20 +73,35 @@ def playsound(af, spkr):
|
||||||
spkr.writesamps(data)
|
spkr.writesamps(data)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
foreground()
|
looping = 0
|
||||||
if len(sys.argv) > 1:
|
packfactor = 0
|
||||||
filename = sys.argv[1]
|
opts, args = getopt.getopt(sys.argv[1:], 'p:l')
|
||||||
|
for opt, arg in opts:
|
||||||
|
if opt = '-p':
|
||||||
|
packfactor = int(eval(arg))
|
||||||
|
elif opt = '-l':
|
||||||
|
looping = 1
|
||||||
|
if args:
|
||||||
|
filename = args[0]
|
||||||
else:
|
else:
|
||||||
filename = 'film.video'
|
filename = 'film.video'
|
||||||
f, w, h, pf = openvideo(filename)
|
f, w, h, pf = openvideo(filename)
|
||||||
if len(sys.argv) > 2:
|
if 0 < packfactor <> pf:
|
||||||
audiofilename = sys.argv[2]
|
w = w/pf*packfactor
|
||||||
|
h = h/pf*packfactor
|
||||||
|
pf = packfactor
|
||||||
|
if args[1:]:
|
||||||
|
audiofilename = args[1]
|
||||||
af = open(audiofilename, 'r')
|
af = open(audiofilename, 'r')
|
||||||
spkr = openspkr()
|
spkr = openspkr()
|
||||||
|
afskip = 0
|
||||||
if len(sys.argv) > 3:
|
if len(sys.argv) > 3:
|
||||||
af.seek(eval(sys.argv[3]))
|
afskip = eval(sys.argv[3])
|
||||||
|
if afskip > 0:
|
||||||
|
af.seek(afskip)
|
||||||
else:
|
else:
|
||||||
af, spkr = None, None
|
af, spkr = None, None
|
||||||
|
foreground()
|
||||||
prefsize(w,h)
|
prefsize(w,h)
|
||||||
win = winopen(filename)
|
win = winopen(filename)
|
||||||
RGBmode()
|
RGBmode()
|
||||||
|
@ -98,6 +114,8 @@ def main():
|
||||||
epoch.epoch = time.millitimer()
|
epoch.epoch = time.millitimer()
|
||||||
nframe = 0
|
nframe = 0
|
||||||
tijd = 1
|
tijd = 1
|
||||||
|
if looping:
|
||||||
|
looping = f.tell()
|
||||||
try:
|
try:
|
||||||
while 1:
|
while 1:
|
||||||
if running:
|
if running:
|
||||||
|
@ -114,6 +132,13 @@ def main():
|
||||||
print 'Played', nframe, 'frames at',
|
print 'Played', nframe, 'frames at',
|
||||||
print 0.1 * int(nframe * 10000.0 / (t-epoch.epoch)),
|
print 0.1 * int(nframe * 10000.0 / (t-epoch.epoch)),
|
||||||
print 'frames/sec'
|
print 'frames/sec'
|
||||||
|
if looping:
|
||||||
|
f.seek(looping)
|
||||||
|
epoch.epoch = time.millitimer()
|
||||||
|
nframe = 0
|
||||||
|
running = 1
|
||||||
|
if af <> None:
|
||||||
|
af.seek(afskip)
|
||||||
if af <> None:
|
if af <> None:
|
||||||
playsound(af,spkr)
|
playsound(af,spkr)
|
||||||
if not running or qtest():
|
if not running or qtest():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue