Making a YouTube video of X program

Start by compiling vncrec. Rehearse the sequence you want to video.

Start vncserver and a regular vncviewer:

    vncserver :1 -geometry 800x600 &
    vncviewer -passwd ~/.vncpasswd :1 &
Make future X programs display to the vnc session. set the background to black. Start a simple window manager if necessary.
    export DISPLAY=:1
    xsetroot -solid black
    icewm &
Prepare the commandline for the program you want to record.

In another terminal on the regular X desktop, start the vnc recording session:

    ./vncrec -passwd ~/.vnc/passwd -record session.vnc :1
This records at 10FPS; you can set the environment variable VNCREC_MOVIE_FRAMERATE to the (integer) FPS desired to get a different rate.

Kick off the program by hitting enter. Do all your actions. Then ctrl-c vncrec. Use vncrec -play session.vnc to review the session. When you're satisfied, it's time to encode the movie into one that youtube will accept.

First, write each frame recorded by vncrec to a file:

    vncrec -passwd ~/.vnc/passwd -record test.vnc :1
this writes a series of xpm files which must be converted to png. I found that imagemagic convert was very slow for this, and that xpmtoppm | pnmtopng was much faster:
    for i in *.xpm; do
        xpmtoppm $i | pnmtopng -compression 1 > `basename $i .xpm`.png;
        echo $i;

Next, if there's a toolbar or titlebar you want to trim off, load up a sample image in a program like gimp and find the x, y, w, and h of the crop region. You'll use it when encoding the video.

At this step, you should also be able to remove any frames that you didn't want, a primitive form of editing.

I encoded with this commandline:

    mencoder "mf://*.png" -vf crop=800:574:0:0,scale=640:-2 -mf fps=15  \
        -o session.avi -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=300:vhq
This crops the bottom 26 out of 600 lines from the image, where icewm places its task bar, and resizes it to 640 pixels wide, a resolution recommended by youtube. The fps setting sped up my video by 50%, since the record was at 10fps.

I wanted to record a program that used OpenGL, but the Ubuntu Dapper vncserver doesn't have glx support. To do this, I used a version of Mesa compiled as a client-side library, and set LD_LIBRARY_PATH to point at the directory where This resided.

Entry first conceived on 26 November 2007, 19:29 UTC, last modified on 15 January 2012, 3:46 UTC
Website Copyright © 2004-2024 Jeff Epler