Example #1
0
def record(v, info, filename, mono, grey, greybits, monotreshold, fields):
    import thread
    format, x, y, number, rate = info
    fps = 59.64  # Fields per second
    # XXX (Strange: need fps of Indigo monitor, not of PAL or NTSC!)
    tpf = 1000.0 / fps  # Time per field in msec
    #
    # Go grab
    #
    gl.wintitle('(rec) ' + filename)
    try:
        ninfo, data, bitvec = v.CaptureBurst(info)
    except sv.error, arg:
        print 'CaptureBurst failed:', arg
        print 'info:', info
        gl.wintitle(filename)
        return
Example #2
0
def record(v, info, filename, audiofilename, \
                mono, grey, greybits, monotreshold, fields):
    import thread
    format, x, y, number, rate = info
    fps = 59.64  # Fields per second
    # XXX (Strange: need fps of Indigo monitor, not of PAL or NTSC!)
    tpf = 1000.0 / fps  # Time per field in msec
    #
    # Go grab
    #
    if audiofilename:
        gl.wintitle('(start audio) ' + filename)
        audiodone = thread.allocate_lock()
        audiodone.acquire_lock()
        audiostart = thread.allocate_lock()
        audiostart.acquire_lock()
        audiostop = []
        initaudio(audiofilename, audiostop, audiostart, audiodone)
        audiostart.acquire_lock()
    gl.wintitle('(rec) ' + filename)
    try:
        ninfo, data, bitvec = v.CaptureBurst(info)
    except sv.error, arg:
        print 'CaptureBurst failed:', arg
        print 'info:', info
        gl.wintitle(filename)
        return
Example #3
0
def record(v, info, filename, audiofilename, \
	               mono, grey, greybits, monotreshold, fields):
	import thread
	format, x, y, number, rate = info
	fps = 59.64 # Fields per second
	# XXX (Strange: need fps of Indigo monitor, not of PAL or NTSC!)
	tpf = 1000.0 / fps # Time per field in msec
	#
	# Go grab
	#
	if audiofilename:
		gl.wintitle('(start audio) ' + filename)
		audiodone = thread.allocate_lock()
		audiodone.acquire_lock()
		audiostart = thread.allocate_lock()
		audiostart.acquire_lock()
		audiostop = []
		initaudio(audiofilename, audiostop, audiostart, audiodone)
		audiostart.acquire_lock()
	gl.wintitle('(rec) ' + filename)
	try:
		ninfo, data, bitvec = v.CaptureBurst(info)
	except sv.error, arg:
		print 'CaptureBurst failed:', arg
		print 'info:', info
		gl.wintitle(filename)
		return
Example #4
0
#! /usr/bin/env python
# Play CMIF movie files

# Help function
def help():
	print 'Usage: Vplay [options] [file] ...'
	print
	print 'Options:'
	print '-M magnify : magnify the image by the given factor'
	print '-d         : write some debug stuff on stderr'
	print '-l         : loop, playing the movie over and over again'
	print '-m delta   : drop frames closer than delta seconds (default 0.)'
	print '-n         : don\'t wait after each file'
	print '-q         : quiet, no informative messages'
	print '-r delta   : regenerate input time base delta seconds apart'
	print '-s speed   : speed change factor (default 1.0)'
	print '-t         : use a 2nd thread for read-ahead'
	print '-x left    : window offset from left of screen'
	print '-y top     : window offset from top of screen'
	print '-w width   : window width'
	print '-h height  : window height'
	print '-b color   : background color (white,black or (r,g,b))'
	print 'file ...   : file(s) to play; default film.video'
	print
	print 'User interface:'
	print 'Press the left mouse button to stop or restart the movie.'
	print 'Press ESC or use the window manager Close or Quit command'
	print 'to close the window and play the next file (if any).'

# Imported modules
Example #5
0
	if quiet: vin.quiet = 1
	vin.initcolormap()

	if bgcolor:
		r, g, b = bgcolor
		vin.clearto(r,g,b)

	gl.qdevice(ESCKEY)
	gl.qdevice(WINSHUT)
	gl.qdevice(WINQUIT)
	gl.qdevice(LEFTMOUSE)

	stop = 0

	while not stop:
		gl.wintitle(filename)
		stop = (playonce(vin) or nowait)
		gl.wintitle('(done) ' + filename)
		if not looping:
			while not stop:
				dev, val = gl.qread()
				if dev == REDRAW:
					if bgcolor:
						r,g,b = bgcolor
						vin.clearto(r,g,b)
					else:
						vin.clear()
				if dev == LEFTMOUSE and val == 1:
					break # Continue outer loop
				if dev == ESCKEY and val == 1 or \
						dev in (WINSHUT, WINQUIT):
Example #6
0
def record(v, info, filename, audiofilename, mono, grey, greybits, \
   monotreshold, fields, preallocspace):
    import thread
    format, x, y, qsize, rate = info
    fps = 59.64  # Fields per second
    # XXX (Strange: need fps of Indigo monitor, not of PAL or NTSC!)
    tpf = 1000.0 / fps  # Time per field in msec
    if filename:
        vout = VFile.VoutFile(filename)
        if mono:
            format = 'mono'
        elif grey and greybits == 8:
            format = 'grey'
        elif grey:
            format = 'grey' + ` abs(greybits) `
        else:
            format = 'rgb8'
        vout.setformat(format)
        vout.setsize(x, y)
        if fields:
            vout.setpf((1, -2))
        vout.writeheader()
        if preallocspace:
            print 'Preallocating space...'
            vout.prealloc(preallocspace)
            print 'done.'
        MAXSIZE = 20  # XXX should be a user option
        import Queue
        queue = Queue.Queue(MAXSIZE)
        done = thread.allocate_lock()
        done.acquire_lock()
        convertor = None
        if grey:
            if greybits == 2:
                convertor = imageop.grey2grey2
            elif greybits == 4:
                convertor = imageop.grey2grey4
            elif greybits == -2:
                convertor = imageop.dither2grey2
        thread.start_new_thread(saveframes, \
           (vout, queue, done, mono, monotreshold, convertor))
        if audiofilename:
            audiodone = thread.allocate_lock()
            audiodone.acquire_lock()
            audiostop = []
            initaudio(audiofilename, audiostop, audiodone)
    gl.wintitle('(rec) ' + filename)
    lastid = 0
    t0 = time.time()
    count = 0
    ids = []
    v.InitContinuousCapture(info)
    while not gl.qtest():
        try:
            cd, id = v.GetCaptureData()
        except sv.error:
            #time.sleep(0.010) # XXX is this necessary?
            sgi.nap(1)  # XXX Try by Jack
            continue
        ids.append(id)

        id = id + 2 * rate
        ##		if id <> lastid + 2*rate:
        ##			print lastid, id
        lastid = id
        count = count + 1
        if fields:
            data1, data2 = cd.GetFields()
            cd.UnlockCaptureData()
            if filename:
                queue.put((data1, int(id * tpf)))
                queue.put((data2, int((id + 1) * tpf)))
        else:
            data = cd.InterleaveFields(1)
            cd.UnlockCaptureData()
            if filename:
                queue.put((data, int(id * tpf)))
    t1 = time.time()
    gl.wintitle('(busy) ' + filename)
    print lastid, 'fields in', round(t1 - t0, 3), 'sec',
    print '--', round(lastid / (t1 - t0), 1), 'fields/sec'
    print 'Captured', count * 2, 'fields,',
    print round(count * 2 / (t1 - t0), 1), 'f/s',
    if lastid:
        print '(',
        print round(count * 200.0 / lastid), '%, or',
        print round(count * rate * 200.0 / lastid), '% of wanted rate )',
    print
    if ids:
        print 'Ids:',
        t0 = ids[0]
        del ids[0]
        for t1 in ids:
            print t1 - t0,
            t0 = t1
        print
    if filename and audiofilename:
        audiostop.append(None)
        audiodone.acquire_lock()
    v.EndContinuousCapture()
    if filename:
        queue.put(None)  # Sentinel
        done.acquire_lock()
    gl.wintitle('(done) ' + filename)
Example #7
0
        sys.exit(2)
    file = sys.argv[1]
    try:
        fp = open(file, 'r')
        data = fp.read()
        fp.close()
    except IOError, msg:
        print file, ':', msg
        sys.exit(1)

    W, H = 600, 600
    gl.foreground()
    gl.prefsize(W, H)
    wid = gl.winopen('glwww')
    gl.color(GL.WHITE)
    gl.clear()
    gl.ortho2(0, W, H, 0)
    gl.color(GL.BLACK)
    T.TSTART()
    fmt = GLFormatter().init(5, 0, W - 5)
    p = html.FormattingParser().init(fmt, GLStylesheet)
    p.feed(data)
    p.close()
    T.TSTOP()
    gl.wintitle(p.title)
    import time
    time.sleep(5)


main()
Example #8
0
#! /usr/bin/env python
# Play CMIF movie files
# Help function

def help():
    print 'Usage: Vplay [options] [file] ...'
    print
    print 'Options:'
    print '-M magnify : magnify the image by the given factor'
    print '-d         : write some debug stuff on stderr'
    print '-l         : loop, playing the movie over and over again'
    print '-m delta   : drop frames closer than delta seconds (default 0.)'
    print '-n         : don\'t wait after each file'
    print '-q         : quiet, no informative messages'
    print '-r delta   : regenerate input time base delta seconds apart'
    print '-s speed   : speed change factor (default 1.0)'
    print '-t         : use a 2nd thread for read-ahead'
    print '-x left    : window offset from left of screen'
    print '-y top     : window offset from top of screen'
    print '-w width   : window width'
    print '-h height  : window height'
    print '-b color   : background color (white,black or (r,g,b))'
    print 'file ...   : file(s) to play; default film.video'
    print
    print 'User interface:'
    print 'Press the left mouse button to stop or restart the movie.'
    print 'Press ESC or use the window manager Close or Quit command'
    print 'to close the window and play the next file (if any).'

# Imported modules
Example #9
0
def record(v, info, filename, audiofilename, mono, grey, greybits, \
	  monotreshold, fields, preallocspace):
	import thread
	format, x, y, qsize, rate = info
	fps = 59.64 # Fields per second
	# XXX (Strange: need fps of Indigo monitor, not of PAL or NTSC!)
	tpf = 1000.0 / fps # Time per field in msec
	if filename:
		vout = VFile.VoutFile(filename)
		if mono:
			format = 'mono'
		elif grey and greybits == 8:
			format = 'grey'
		elif grey:
			format = 'grey'+`abs(greybits)`
		else:
			format = 'rgb8'
		vout.setformat(format)
		vout.setsize(x, y)
		if fields:
			vout.setpf((1, -2))
		vout.writeheader()
		if preallocspace:
			print 'Preallocating space...'
			vout.prealloc(preallocspace)
			print 'done.'
		MAXSIZE = 20 # XXX should be a user option
		import Queue
		queue = Queue.Queue(MAXSIZE)
		done = thread.allocate_lock()
		done.acquire_lock()
		convertor = None
		if grey:
			if greybits == 2:
				convertor = imageop.grey2grey2
			elif greybits == 4:
				convertor = imageop.grey2grey4
			elif greybits == -2:
				convertor = imageop.dither2grey2
		thread.start_new_thread(saveframes, \
			  (vout, queue, done, mono, monotreshold, convertor))
		if audiofilename:
			audiodone = thread.allocate_lock()
			audiodone.acquire_lock()
			audiostop = []
			initaudio(audiofilename, audiostop, audiodone)
	gl.wintitle('(rec) ' + filename)
	lastid = 0
	t0 = time.time()
	count = 0
	ids = []
	v.InitContinuousCapture(info)
	while not gl.qtest():
		try:
			cd, id = v.GetCaptureData()
		except sv.error:
			#time.sleep(0.010) # XXX is this necessary?
			sgi.nap(1)	# XXX Try by Jack
			continue
		ids.append(id)
		
		id = id + 2*rate
##		if id <> lastid + 2*rate:
##			print lastid, id
		lastid = id
		count = count+1
		if fields:
			data1, data2 = cd.GetFields()
			cd.UnlockCaptureData()
			if filename:
				queue.put((data1, int(id*tpf)))
				queue.put((data2, int((id+1)*tpf)))
		else:
			data = cd.InterleaveFields(1)
			cd.UnlockCaptureData()
			if filename:
				queue.put((data, int(id*tpf)))
	t1 = time.time()
	gl.wintitle('(busy) ' + filename)
	print lastid, 'fields in', round(t1-t0, 3), 'sec',
	print '--', round(lastid/(t1-t0), 1), 'fields/sec'
	print 'Captured',count*2, 'fields,',
	print round(count*2/(t1-t0), 1), 'f/s',
	if lastid:
		print '(',
		print round(count*200.0/lastid), '%, or',
		print round(count*rate*200.0/lastid), '% of wanted rate )',
	print
	if ids:
		print 'Ids:',
		t0 = ids[0]
		del ids[0]
		for t1 in ids:
			print t1-t0,
			t0 = t1
		print
	if filename and audiofilename:
		audiostop.append(None)
		audiodone.acquire_lock()
	v.EndContinuousCapture()
	if filename:
		queue.put(None) # Sentinel
		done.acquire_lock()
	gl.wintitle('(done) ' + filename)
Example #10
0
	def settitle(self, title):
		self._title = title
		gl.wintitle(title)
Example #11
0
		print 'usage: www file'
		sys.exit(2)
	file = sys.argv[1]
	try:
		fp = open(file, 'r')
		data = fp.read()
		fp.close()
	except IOError, msg:
		print file, ':', msg
		sys.exit(1)

	W, H = 600, 600
	gl.foreground()
	gl.prefsize(W, H)
	wid = gl.winopen('glwww')
	gl.color(GL.WHITE)
	gl.clear()
	gl.ortho2(0, W, H, 0)
	gl.color(GL.BLACK)
	T.TSTART()
	fmt = GLFormatter().init(5, 0, W-5)
	p = html.FormattingParser().init(fmt, GLStylesheet)
	p.feed(data)
	p.close()
	T.TSTOP()
	gl.wintitle(p.title)
	import time
	time.sleep(5)

main()
Example #12
0
def main():
	QSIZE = 16
	TIME = 5
	audio = 0

	opts, args = getopt.getopt(sys.argv[1:], 'aq:t:')
	for opt, arg in opts:
		if opt == '-a':
			audio = 1
		elif opt == '-q':
			QSIZE = string.atoi(arg)
		elif opt == '-t':
			TIME = string.atoi(arg)

	if args:
		filename = args[0]
	else:
		filename = 'film.video'

	if audio:
		if args[1:]:
			audiofilename = args[1]
		else:
			audiofilename = 'film.aiff'

	gl.foreground()

	x, y = SV.PAL_XMAX / 4, SV.PAL_YMAX / 4
	print x, 'x', y

	gl.minsize(40, 30)
	gl.stepunit(8, 6)
	gl.maxsize(SV.PAL_XMAX, SV.PAL_YMAX)
	gl.keepaspect(SV.PAL_XMAX, SV.PAL_YMAX)
	win = gl.winopen(filename)
	x, y = gl.getsize()
	print x, 'x', y

	v = sv.OpenVideo()
	v.BindGLWindow(win, SV.IN_REPLACE)
	v.SetSize(x, y)
	v.BindGLWindow(win, SV.IN_REPLACE)

	v.SetCaptureFormat(SV.RGB_FRAMES)
	v.SetCaptureMode(SV.BLOCKING_CAPTURE)
	v.SetQueueSize(QSIZE)
	v.InitCapture()
	if v.GetQueueSize() != QSIZE:
		QSIZE = v.GetQueueSize()
		print 'Warning: QSIZE reduced to', QSIZE

	gl.qdevice(DEVICE.LEFTMOUSE)
	gl.qdevice(DEVICE.WINQUIT)
	gl.qdevice(DEVICE.WINSHUT)
	gl.qdevice(DEVICE.ESCKEY)

	print 'Click left mouse to start recording', TIME, 'seconds'
	ofile = None
	afile = None
	# Mouse down opens the file & freezes window
	# Mouse up starts recording frames

	while 1:
		dev, val = gl.qread()
		if dev == DEVICE.LEFTMOUSE:
			# Start recording
			if val == 1:
				# Mouse down -- preparations
				if ofile == None:
					ofile = VFile.VoutFile().init(filename)
					ofile.format = 'rgb8'
					ofile.width = x
					ofile.height = y
					ofile.writeheader()
					# XXX other format bits?
				# The window can't be resized from now
				gl.prefsize(x, y)
				gl.winconstraints()
				gl.wintitle('* ' + filename)
				if audio:
					afile = initaudio(audiofilename)
				continue
			# Mouse up -- start actual recording
			global recording, stop_recording
			if audio:
				stop_recording = 0
				recording.release()
			t0 = time.millitimer()
			v.StartCapture()
			while 1:
				t = time.millitimer() - t0
				if t >= TIME*1000:
					break
				if v.GetCaptured() > 2:
					doframe(v, ofile, x, y, t)
			v.StopCapture()
			stop_recording = 1
			while v.GetCaptured() > 0:
				doframe(v, ofile, x, y, t)
				t = time.millitimer() - t0
			gl.wintitle(filename)
		elif dev == DEVICE.REDRAW:
			# Window resize (or move)
			x, y = gl.getsize()
			print x, 'x', y
			v.SetSize(x, y)
			v.BindGLWindow(win, SV.IN_REPLACE)
		elif dev in (DEVICE.ESCKEY, DEVICE.WINQUIT, DEVICE.WINSHUT):
			# Quit
			if ofile:
				ofile.close()
			if afile:
				afile.destroy()
			posix._exit(0)
			# EndCapture dumps core...
			v.EndCapture()
			v.CloseVideo()
			gl.winclose(win)
Example #13
0
 def settitle(self, title):
     self._title = title
     gl.wintitle(title)
Example #14
0
#! /usr/bin/env python
Example #15
0
	def settitle(self):
		gl.winset(self.window)
		x, y = gl.getsize()
		title = 'Vb ' + self.vfile + ' (%dx%d)' % (x, y)
		gl.wintitle(title)
Example #16
0
     audiodone = thread.allocate_lock()
     audiodone.acquire_lock()
     audiostart = thread.allocate_lock()
     audiostart.acquire_lock()
     audiostop = []
     initaudio(audiofilename, audiostop, audiostart, audiodone)
     audiostart.acquire_lock()
 gl.wintitle('(rec) ' + filename)
 try:
     ninfo, data, bitvec = v.CaptureBurst(info)
 except sv.error, arg:
     print 'CaptureBurst failed:', arg
     print 'info:', info
     gl.wintitle(filename)
     return
 gl.wintitle('(save) ' + filename)
 #
 # Check results
 #
 if info <> ninfo:
     print 'Sorry, format changed.'
     print 'Wanted:', info
     print 'Got   :', ninfo
     gl.wintitle(filename)
     return
 # print bitvec
 if x * y * number <> len(data):
     print 'Funny data length: wanted',x,'*',y,'*', number,'=',\
        x*y*number,'got',len(data)
     gl.wintitle(filename)
     return
Example #17
0
#! /usr/bin/env python
Example #18
0
File: Vb.py Project: carol8421/gosh
	def settitle(self):
		gl.winset(self.window)
		x, y = gl.getsize()
		title = 'Vb ' + self.vfile + ' (%dx%d)' % (x, y)
		gl.wintitle(title)
Example #19
0
#! /usr/bin/env python
Example #20
0
#! /usr/bin/env python
Example #21
0
#! /usr/bin/env python