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.
ResolutionRatio
256x2247:6
256x2405:4
320x22414:15
512x2405:8
320x2401: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 Encoderguidelines 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.

EncodingGuide/Legacy/Encoding last edited by adelikat on 8/7/2022 8:13 PM
Page History Latest diff List referrers View Source