I have a vncrec output and I need to encode a film out of it.
Note: this blog entry is getting updated with the feedback I receive by mail. All the part about recording an X session is being maintained in the Debian wiki.
transcode won't work: tried everything, googled a lot: either it exits right away, or I use the dvd delay option and it shows an error from vncrec and does nothing.
vncrec can generate xpm files, one per frame. However, imagemagick won't grok them complaining they have an illegal header. And xpmtoppm will complain that there is a line inside the file which is too long. The only thing that can load them is gimp.
So, let's script gimp. I came up with this python script that kinda does the trick:
from gimpfu import * def process (file): img=pdb.file_xpm_load("/home/enrico/tmp/cazzeggio/"+file+".xpm", file+".xpm") pdb.file_png_save_defaults(img, img.active_layer, "/home/enrico/tmp/cazzeggio/"+file+".png", file+".png") # (update) added to dispose of the image to avoid gimp swap to grow pdb.gimp_image_delete(img) for i in range(1, 10000): process("img_%05d"%i)
Tested in the gimp python-fu console, it works, with the save and load progress bar popping up all the time grabbing the focus from whatever I was doing.
There is a run_mode that can be passed to those file_xpm_load and file_png_save_defaults, however python-fu is happy to let me know that I don't need to bother about it. I searched, searched searched and I found out that this really means that there's no findable way to tell Gimp functions to STFU with python-fu.
Now, how do I run that script AND be still able to use my computer?
gimp has a nice --batch commandline option, from which it seems to only understand scheme. It has a --batch-interpreter option, but I couldn't find out any possible value that could make --batch understand python.
So, it seems that the only way to run python is to either register a plugin, or type it in the python console. And no STFU.
So I tried Xnest, so that I could at least iconise the whole thing out of my way. But it seems that xnest is denying connection from all clients I try to run in it.
So I've run a VNC server. In the VNC server I run Gimp. Then I fire up the Python console inside that Gimp. Then I paste the script in the Python console. Then it starts working and I close the VNC client to get rid of the popups.
Finally, this script helps me delete the big XPM files after they've been converted to PNG:
1 2 3 4 5 6 7 8 9
#!/bin/sh for i in *.xpm do if [ -e `basename $i .xpm`.png ] then echo rm $i rm $i fi done
If there were easier ways to do what I did, please mail me and I'll document them: no matter how I searched, I couldn't find any.
Update: it seems that in the Gimp python script, the image doesn't get automatically garbage collected. As a result, the file ~/.gimp-2.2/gimpswap.whatever keeps inflating, so space is not really saved by converting the XPM files to PNG, unless I restart Gimp from time to time.
Update: I found a function to deallocate the image: maybe that avoids the growth of the Gimp swap.