4 |
from gzz.gfx.gl import GL |
from gzz.gfx.gl import GL |
5 |
import os |
import os |
6 |
|
|
7 |
def saveframe(filename, win): |
def saveframe(filename, win, x=0, y=0, w=None, h=None): |
|
x,y = 0,0 |
|
8 |
s = win.getSize() |
s = win.getSize() |
9 |
pix = win.readPixels(0, 0, s.width, s.height) |
if w==None: w = s.width |
10 |
saveimage.save(filename, pix, s.width, s.height) |
if h==None: h = s.height |
11 |
|
pix = win.readPixels(x, y, w, h) |
12 |
|
saveimage.save(filename, pix, w, h) |
13 |
|
|
14 |
def savesequence(win, filebase, vs1, vs2, n): |
def savesequence(win, filebase, vs1, vs2, n, **args): |
15 |
for frame in range(0, n+1): |
for frame in range(0, n+1): |
16 |
fract = frame / (n+0.0) |
fract = frame / (n+0.0) |
17 |
win.renderAnim(vs1, vs2, fract, 0, 1) |
win.renderAnim(vs1, vs2, fract, 0, 1) |
18 |
saveframe(filebase + "%03d"%frame + ".jpg", win) |
saveframe(filebase + "%03d"%frame + ".jpg", win, **args) |
19 |
|
|
20 |
def encodefilm(globpat, outfilm): |
def encodefilm(globpat, outfilm): |
21 |
mencoder = "/BIG/MPlayer-0.90pre8/mencoder" |
mencoder = "/BIG/MPlayer-0.90pre8/mencoder" |
22 |
os.system("%(mencoder)s %(globpat)s -lavcopts vcodec=mpeg4 -mf on:fps=25 -ovc lavc -o %(outfilm)s" |
cmd = "%(mencoder)s %(globpat)s -lavcopts vcodec=mpeg4 -mf on:fps=25 -ovc lavc -o %(outfilm)s" % locals() |
23 |
% locals()) |
print cmd |
24 |
|
os.system(cmd) |
25 |
|
|