pygame-based video capture on Linux
I haven't had a ton of luck using things like recordmydesktop to get footage of games in Linux. So today I put together a rough draft of a module that allows you to "record" a video directly in your game. To get the video, it simply dumps the window to a file each frame. This can then be sequenced into a motion PNG or something afterward in mencoder. To get the audio... well... any ideas?The horrible hack I currently have for the audio is to write down the times that every sound is played, then use pygame.sndarray to reconstruct what the audio was during the game. I'm not even handling things like fadeout yet, and it's already a mess.
Still, it works okay. I think the results are better. Here's a video of my Ludum Dare game I made using it. The original AVI that I uploaded to YouTube looks even better, since the video is completely lossless. For comparison, here's a video of an old pyweek game I made using recordmydesktop.
Is this something anyone would be interested in? Any suggestions on how to do this better, particularly the audio part? Thanks!
(log in to comment)
Effectively the commandline would look a bit like
gst-launch tcpclientsrc ! audio/x-raw-int,<format details> ! wavenc ! filesink
With more effort you could even build a commandline that reads your screen grabs at the same time (on a network socket) and multiplexes the video and audio stream. You might also be able to read the sound from the soundcard rather than reconfiguring Pulseaudio - I'm not sure.
I need to pass a port number to tcpclientsrc, correct? Where do I get that from? I assume it's specified in the Pulseaudio config, but I don't see it.