This howto provides some usual information on creating frag movies (or any other videos) with a powerful command line tool called mencoder. Mencoder is a part of mplayer and is used to deal with multimedia streams.


MPlayer is a movie player for Linux (runs on many other platforms and CPU architectures, see the documentation). It plays most MPEG/VOB, AVI, ASF/WMA/WMV, RM, QT/MOV/MP4, Ogg/OGM, MKV, VIVO, FLI, NuppelVideo, yuv4mpeg, FILM and RoQ files, supported by many native and binary codecs. You can watch Video CD, SVCD, DVD, 3ivx, DivX 3/4/5 and even WMV movies, too.


mencoder (MPlayer’s Movie Encoder) is a simple movie encoder, designed to encode MPlayer-playable movies (see above) to other MPlayer-playable formats. It encodes to MPEG-4 (DivX/Xvid), one of the libavcodec codecs and PCM/MP3/VBRMP3 audio in 1, 2 or 3 passes. Furthermore it has stream copying abilities, a powerful filter system (crop, expand, flip, postprocess, rotate, scale, noise, RGB/YUV conversion) and more.

Building a video from screenshots

If you are using quake on a UNIX based operating system and ezQuake 1.9 or older, then most probably you can capture screenshots at most (unlike windows, where you can capture and encode video on the fly) with mencoder it is quite easy to compile multiple screenshots into an encoded or raw video file. To compile all .jpg files in the current directory and use 30 files per second:

mencoder "mf://*.jpg" -mf fps=30 -o output.avi

To have the motion unchanged, the fps setting must match the one used during capturing. Changing this value may result in slower or faster playback later. The speed of the output video file can be also adjusted with the -speed parameter. If your capture resulted in getting tga files instead of jpg just replace mf://*.jpg with mf://*.tga.

Building a video from other video files

You can do the same with multiple video files, compiling them into one, and possibly encoding. Note though that if the video files vary in resolution, the output video’s resolution will be the largest from the input videos. The other files will be decorated with black borders around them.

To compile all .avi files in the current directory:

mencoder *.avi -o output.avi

Note that you might have to add -nosound to the command line due to various problems.


There are many codecs available to use with mencoder. Each one has it’s own specific encoding options. Short description of the most popular codecs follows. To see what video and audio codecs are available to you, issue the following command:

mencoder -ovc help -oac help

You will be shown a list of possible codecs for audio and video. Selecting a codec is done by -ovc <vidcodec> and -oac <audiocodec> in the command line, where ovc stands for output video codec and oac is output audio codec. The most important encoding settings are bitrate, pass, speed and aspect.

xvid codec

To encode a video file with the xvid codec (recommended for Frag Of The Week), the -ovc parameter has to be set to xvid and -xvidencopts should follow to enable custom encoding options. Possible encoding options are:

pass=<1|2> - specify the pass in two pass mode
bitrate=<x> - specify the bitrate of the file being encoded (the more, the better quality and bigger file size)


mencoder input.avi -o output.avi -ovc xvid -xvidencopts bitrate=3000

For best results use the two pass mode. Some tasks, such as encoding a live feed in real time, TV-capture or a security camera allow for single pass mode only. In any other case it is recommended to use two pass mode. It is often necessary to resize the final movie clip to the desired resolution and use gamma settings other than the default.
Example of encoding with 2-pass mode, resizing to 320×240 and altering the gamma level to 1.5:

mencoder "mf://*.tga" -mf fps=25 -o /dev/null -ovc xvid -xvidencopts pass=1:bitrate=3000 -vf scale=320:240,eq2=1.5
mencoder "mf://*.tga" -mf fps=25 -o output.avi -ovc xvid -xvidencopts pass=2:bitrate=3000 -vf scale=320:240,eq2=1.5

The bitrate setting in the first pass is not really needed and mencoder can ignore it.
Mencoder uses the data gathered from the first pass via the divx2pass.log file (so stay in the same dir).

x264 codec

This codec can give very good quality while the file size remains low. It is rapidly gaining popularity among groups releasing movies. The use is very similar to xvid. -ovc has to be set to x264 and the parameter -x264encopts allows for further customization. The nr encoding parameter stands for noise reduction, which might be useful for bad quality videos. Example:

mencoder input.avi -o output.avi -ovc x264 -x264encopts bitrate=3000 pass=1 nr=2000

MPEG codec

The MPEG muxer can generate 5 types of streams, each of which has reasonable default parameters that the user can override. Generally, when generating MPEG files, it is advisable to disable mencoder’s frame-skip code (see -noskip and -mc). Example:

mencoder input.avi -o output.avi -ovc lavc -mpegopts format=mpeg2:tsaf:vbitrate=8000 -nosound

lavc filter

This filter is supposed to give best quality and relatively small files, according to MPlayer’s manual.The following example shows one way of encoding a file with lavc. Example:

mencoder "mf://*.jpg" -mf fps=30 -o output.avi -ovc lavc -lavcopts vcodec=mpeg4

Another example:

mencoder input.avi -o output.avi -oac copy -ovc lavc -lavcopts vcodec=mpeg4:mbd=1:vbitrate=2800

Using audio

At the current stage of ezQuake’s development, there is no possibility to record quake sounds in Linux during capturing. It is still possible to use an audio file as soundtrack. Furthermore, it is possible to encode the audio track (-oac). The -noaudio parameter can be used to remove audio from a video file or not to use audio when compiling one. However, an audio stream can be included thanks to the -audiofile parameter. In this next example, mencoder adds an audio track from a .wav file and encodes it to mp3.

mencoder input.avi -o output.avi -ovc copy -oac mp3lame -audiofile soundtrack.wav

It is also possible to add an audio stream which is already encoded:

mencoder input.avi -o output.avi -ovc copy -oac copy -audiofile soundtrack.mp3

It is a good idea to prepare the audio track beforehand. There is a great tool with GUI to do that under Linux, called Audacity. The program is very easy to use thanks to an intuitive interface. It allows mixing, cutting and rearranging of audio files and can export the results to mp3.

Leave a Reply