.. _video:

.. index::
   pair: Encoding; Videos

Encoding Videos
===============

To create a video, make and xaf file first (the easiest way to do this is to
use the **record** function in the file menu). Then you need to render the
animation. XaoS can output sequences of ordinary PNG images, that can later be
used by a video encoder.

Generating image sequences for video
------------------------------------

To generate an image sequence, choose **Render Animation** from the **Misc**
menu. You can also use the following command on the command line:

xaos -render [filename] -size 352x240 -antialiasing -renderframerate 24
-basename [basename]

**File to render** ([filename]) is the name of the xaf file, **Basename**
([basename]) is the name used as the base filename for rendered images. This
should also include the path where you want to save the images. XaoS adds a
four digit sequence number and .png extension to this name automatically.

You might also want to change the resolution. Make sure that the resolution you
choose is supported by the video codec you wish to use.

The framerate can also be altered. Make sure you choose a framerate that is
supported by the video codec you wish to use.

**Antialiasing** (-antialiasing) is used to produce anti-aliased images. It
takes a much longer time and much more memory to calculate them, but resulting
images are better for video compression and they result in a much smaller video
file. (the same is true of **JPEG images**)

On the other hand, the other XaoS rendering option **Always Recalculate**
(-alwaysrecalc) (which disables XaoS's zooming optimizations) is **not
recommended**. If that's used, the sequence of animation then contains quite a
lot of extra information, which increases size of video file, but because of
the codec's lossy compression it is hard to see any difference, so it's not
worth it.

Rendered files
--------------

Once you start it, XaoS will generate thousands of frames. They take quite a
long time to calculate and save, and consume plenty of disk space. (e.g. to
render part 1 of the tutorial you need about 60MB and half an hour of time).

All images are named [basename]framenum.png. For example intro0001.png is the
first frame of the animation intro. If consecutive frames are the same, XaoS
doesn't save them, so some frames may be missing. If your encoder can't handle
that, you will need to write a simple script which will fill in the gaps by
means of mv or symbolic linking.

A list of all filenames is saved into the file [basename].par, where each line
is the name of one frame. The names repeat here if necessary, so you can use
this file to supply filenames to the encoder.

Encoding videos
---------------

Once XaoS has generated the png files for each frame of the animation, you can
use a third-party video encoder to convert the sequence of images into a video
file. We currently recommend the following encoders, which support a wide
variety of video codecs and file formats:

ffmpeg

* `ffmpeg home page`_
* `ffmpeg instructions`_

.. _`ffmpeg home page`:
	http://ffmpeg.mplayerhq.hu/ 

.. _`ffmpeg Instructions`:
	 http://ffmpeg.mplayerhq.hu/faq.html#SEC12

mencoder (part of mplayer)

* `mplayer homepage`_
* `mencoder instructions`_

.. _`mplayer homepage`:
	http://www.mplayerhq.hu/ 

.. _`mencoder instructions`:
	http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-enc-images.html

These are both command line tools. If you prefer a graphical tool, you may
prefer `Quicktime Pro`_ from Apple. However, this software costs approximately 
US $30. Although QuickTime may be easier to use, the two free
encoders above are just as capable once you learn how to use them.

.. _`Quicktime Pro`:
	http://www.apple.com/quicktime/pro/
