On 4/16/2012 8:37 AM, superpollo wrote:
alex23 ha scritto:
On Apr 16, 7:34 pm, superpollo <superpo...@tznvy.pbz> wrote:
is there a way to convert the graphical output of a pygame application
to a mpeg file or better an animated gif? i mean, not using an external
capture program...
There is, but it's probably not going to be as performant as using
something external:
http://stackoverflow.com/questions/6087484/how-to-capture-pygame-screen
but where in the code should i put the line:
pygame.image.save(window, "screenshot.jpeg")
?
Somewhere in the loop that draws frames, perhaps just before or after
flipping to the screen. Of course, number the frames.
framenum = 0 # somewhere, just once
# in loop
pygame.image.save(window, 'frame%05d' % framenum)
framenum += 1
5 digits for frames is just an example.
>>> 'frame%05d.jpg' % 21
'frame00021.jpg'
>>> 'frame{:0>5d}.jpg'.format(21)
'frame00021.jpg'
You might consider saving .bmp bitmaps, as mpeg compresses across frames
as well as within frames. If you have sprites moving over a static
background, only the changes need to be encoded.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list