learnix edited this page Jul 27, 2011 · 7 revisions

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


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

Using FFMPEG to encode glc's captured stream

glc-play test.glc -o - -a 1 | ffmpeg -i - -sameq -y audio.mp4
glc-play test.glc -o - -y 1 | ffmpeg -i - -sameq -y video.mp4

Now you can either use a video editing software of your choice to combine them when you go to edit your video or use ffmpeg to merge them together. Personally i used openshot video and imported both files together.

Alternatively: ffmpeg -i audio.mp4 -i video.mp4 -sameq test2.mp4