How to export and encode captured stream

glc-play is able to export audio streams in  WAV format and video streams in  YUV4MPEG format or frames as separate  BMP or  PNG files for transcoding into commonly playable video format.

Please note that while glc is able to handle multiple dynamic audio and video streams, common video containers and formats usually don't. Each stream must be extracted separately. If stream configuration changes (eg. window was resized when it was captured) glc-play generates a new export file for each configuration (%d is usually substituted with export file counter in file name).

To extract information about captured streams (eg. how many video and audio streams it has), execute

glc-play [stream file] -i LEVEL

where LEVEL is a verbosity level (try numbers between 1 and 6). For example with verbosity level 1, glc-play prints out something like

[   0.00s] video stream 1
[   0.00s] audio stream 1
[  54.87s] end of stream
video stream 1
  frames      = 2469
  fps         = 45.00
  bytes       = 1.13 GiB
  bps         = 21.09 MiB
audio stream 1
  packets     = 2570
  pps         = 46.84
  bytes       = 9.22 MiB
  bps         = 171.98 KiB

Video stream (YUV4MPEG)

To export video stream number NUM, execute

glc-play [stream file] -y NUM -o video.y4m

If you have resized the window while capturing, you need to add %d to file name to recover the whole stream.

Video stream (PNG)

glc-play [stream file] -p NUM -o pic-%010d.png

Audio stream (WAV)

glc-play [stream file] -a NUM -o audio.wav

Encoding

Video encoding is a complex business and if you just want a nice .mp4, use glc/scripts/encode.sh included in the source distribution package.

./encode.sh [stream file] -o mynicefragvid.mp4

It is possible export audio and video to pipe and tell encoding applications to read from pipe. It is often much faster and we are going to use it in our examples.

Part 1: transcode audio to MP3

glc-play [stream file] -o - -a NUM | lame -hV2 - audio.mp3

Part 2: read mencoder's manual

mplayer/mencoder is a huge beast and if you are going to work with videos on linux, you should definitely know mencoder.

man mencoder

Part 3: use mencoder to encode video in H.264 and mix it with audio

glc-play [stream file] -o - -y NUM | mencoder -demuxer y4m - -nosound -ovc x264 -x264encopts qp=18:pass=1 -of avi -o video.avi
glc-play [stream file] -o - -y NUM | mencoder -demuxer y4m - -audiofile audio.mp3 -oac copy -ovc x264 -x264encopts qp=18:pass=2 -of avi -o video.avi

Alternative encoding: quick and dirty

This method uses mencoder and assumes that you want to encode only the first audio and video track. It produces a low-quality video, for improving the quality you can try using a higher bitrate.

glc-play [stream file] -a 1 -o audio.wav
glc-play [stream file] -y 1 -o - | mencoder -demuxer y4m - -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=3000 -audiofile audio.wav -oac mp3lame -o video.avi