We all know that glc has a little gamma problem - recorded videos are usually too dark. I was researching a bit and knitted this script which takes care of the whole encoding process. The result is a h.264 file in 720p.

First of all we need to make sure that we have everything. This script needs the following stuff to be in your system:
- lame (libmp3lame)
- ffmpeg including libraries
- libx264 (free h.264 encoder)
- mplayer package

Opensuse users can get pretty current packages from the Packman repository.

Then we need to start flightgear through glc and to make sure, audio is recorded, glc needs a few extra parameters

glc-capture -i -j -b back --compressed=200 --uncompressed=100 --unscaled=100 -o "/tmp/fgfs_$(date "+%Y-%m-%d_%H%H%S").glc" ${COMMAND}

${COMMAND} is your commandline for starting fgfs. This line will start glc and tell it to create a new recording file with the date and time in the filename in /tmp. -b back tells glc to capture the back buffer (I let some OpenGL guru explain this if somebody really needs to know) and -i tells glc to paint a little red square in the top left screen corner when it records. The square itself is NOT recorded, of course. -j is some option which gets the audio actually recorded. Also, we increase the buffers, so the recording in 720p works without stuttering.

Then you do your recording and when you are finished you use this script - I call it glc2h264.sh



    echo "Extracting audio..."
    glc-play "${GLCFILE}" -a 1 -o "${GLCFILE}.wav"
    echo "Creating named pipe and starting encoding..."
    rm -f stream.yuv
    mkfifo stream.yuv
    glc-play "${GLCFILE}" -o - -y 1 | \
    mplayer -nojoystick -demuxer y4m -vo yuv4mpeg:file=stream.yuv -vf eq2=1.4 -ao null -nosound \
      -noframedrop -quiet - & \
    ffmpeg -f yuv4mpegpipe -i stream.yuv -i "${GLCFILE}.wav" -acodec libmp3lame -ab 128k -ac 2 -s 1280x720 \
      -sameq -vcodec libx264 -threads 0 "${GLCFILE}.avi"
    echo "Removing temporary files"
    rm "${GLCFILE}.wav"
    rm -f stream.yuv