TASVideos

Tool-assisted game movies
When human skills are just not enough

Encoding Guide / Encoding

<< Encoding Guide

Table of contents [expand all] [collapse all]

Introduction

You now have everything in place to embark upon the most gruelling step of the entire encoding process - the encoding itself. This step is the core of the entire process and takes the largest amount of time.

You can generally run the video and audio encoding at roughly the same time; the audio encoding will almost certainly take a lot less time than the video encoding.

Video encoding

If you are encoding for a console intended to be displayed on a TV, you will need to determine the pixel aspect ratio (PAR)[1] of your target console before proceeding (for handhelds or arcade machines, you can just use 1:1 or not specify this at all). A table of these follows for most standard resolutions.
Resolution Ratio
256x224 7:6
256x240 5:4
320x224 14:15
512x240 5:8
320x240 1:1
x by y (4/3)*(y/x) (as an integer ratio)

Regardless of whether you are using an .avi or an .avs as your input, the following command line (with some minor tweaks as noted afterwards) will initiate the video encoding process:

x264 --sar <PAR as found above> --crf 20 --keyint <keyint> --ref 16 --no-fast-pskip --bframes 16 --b-adapt 2 --direct auto --me umh --merange 64 --subme 11 --trellis 2 --partitions all --input-range pc --range pc --no-dct-decimate --tcfile-in times.txt -o video.mp4 in.avi

Before dissecting this command line, please note the following:

Now, let's briefly look over the x264 command line options:

You are encouraged to experiment with tweaking these options; this is intended as a generic set of options to serve as a good starting point, and our encoders tend to develop their own set of options which serves their needs best. The Encoders' Corner is a good place to look for advice.

Audio encoding

This step assumes that the .wav from the previous step is called audio.wav.

Current encoder guidelines suggest using Ogg Vorbis or AAC as audio codecs depending on the target container format (Ogg Vorbis for MKV and AAC for MP4).

Use the following command line:
oggenc2 -q 1 audio.wav

-q 1 specifies the target quality factor, determining the bitrate of the final product relative to the complexity of the audio file (similar to --crf with x264). 1 has been semi-arbitrarily selected as a suggested target value known to give consistently acceptable results; this value may need to be raised for games with complex sound.

Use the following command line:
neroAacEnc -q 0.25 -if audio-fixed.wav -of audio.mp4

-q 0.25 specifies a target quality factor, determining the bitrate of the final product relative to the complexity of the audio file (similar to --crf with x264). 0.25 has been semi-arbitrarily selected as a suggested target value known to give consistently acceptable results; this value may need to be raised for games with complex sound.

After you have encoded the file, you can check the audio delay with MP4Box:

MP4Box -info audio.aac


Next page: Packaging
Previous page: Pre-encoding

[1]: x264 calls this a scale aspect ratio (SAR); hence --sar. It is exactly the same concept.

[2]: The '40' is the minimum frame rate of the resulting video; you can reduce this significantly if desired (values as low as 0.1 are in common use). The remaining values are present to prevent most non-duplicate frames from being detected as duplicate frames. But if a game still has issues with dropped frames (There is one reported case), it is suggested you increase the minimum frame to something a bit higher, or consider not using Deldup at all. In this case, it might be a good idea to use DeDup.



Combined RSS Feed
EncodingGuide/Encoding last edited by Guga on 2014-05-01 16:32:12
Page info and history | Latest diff | List referrers | View Source