AnimeMusicVideos.org > Guide Index
Compressing to H.264 using Zarx264gui
The H.264 standard is the best video compression technology available today, and it has a free implementation through the great x264 codec. However, compressing to H.264 properly has typically been a fairly complex proceedure, so in order to encourage more people to use it, I wrote a program called Zarx264gui which makes the entire process extremely simple.
Zarx264gui is designed with AMVs in mind, and is available in the AMVApp, but you can always find the most up to date version here. Zarx264gui requires you to have the Microsoft .NET framework installed. If you have Windows Vista or better then you already have .NET, but if you are running Windows XP then you may need to download it seperately. The easiest way to determine if you have it installed is to try running Zarx264gui. If the program opens, then you have it installed already. However, if you get a cryptic error message, then you will need to download and install the .NET Framework. You can get it here.
When you start up Zarx264gui, you should see a window that looks like this:
The first thing you need to do is load your input video. Zarx264gui only accepts AviSynth scripts. However if you try to load a normal AVI file, Zarx264Gui will automatically generate an avisynth script for you. If your AviSynth script contains audio, it will automatically be loaded as well. If you exported your audio from your editing program as a wav file, you can load it in the second box. You also have the option of loading an MP3 or AAC audio file. In this case, the MP3 or AAC audio will simply be copied instead of re-encoded. Lastly, you want to specify where to save your output MP4 file to.
Now, Zarx264gui is set up so that all you really need to do is press the encode button, and you will get a great encode without having to really mess with anything. Of course, there are a few settings available that we can tweak, and it's a good idea to learn about them, so let's take a look at what they can do:
The mode setting lets you select one of four different encoding modes--Constant Quality, Bitrate (1 pass), Bitrate (2 pass), and Bitrate (2 pass fast). Constant Quality is the recommended setting here. What is the difference between these three modes? Well, let's see.
Quantizer/Bitrate: This setting is basically a trade-off between visual quality and filesize. If you are using bitrate mode, then you simply set the bitrate that you want to encode your video at. Higher bitrates increase the size of your output file, and you can see the estimated filesize as you modify the bitrate value. If you are using constant quality mode, then this is where you select the quantizer to use. Valid values are from 0-51, with lower values giving better quality, but larger filesizes. A quantizer of 18 is generally considered the lowest that you should select, as it's unlikely that you will see much visual improvement by going any lower. For those of you familiar with Xvid, a quantizer of 18 here is equivalent to Xvid's quantizer 2. The default quantizer value is 22, which gives a rather decent tradeoff between quality and size.
Audio Bitrate: This sets how much bitrate will be given to the audio. If you loaded an MP3 or AAC audio file, then this setting will not be available. Higher bitrates result in better audio quality. The default of 128 is recommended. Audio is encoded into the AAC format, which is more efficient than MP3.
Preset: The options here basically give you a quality verses speed tradeoff. For most encodes, I recommend that you stick with the normal preset. Its reasonably fast and will give you great quality. If you want to squeeze every last bit of quality out of your encode, then go for insane. This will slightly inprove quality, but encodes MUCH slower. I use the Fast or Preview modes when I just need a quick encode to watch, or to send a test clip to a friend. I wouldn't recommend either of these modes for your distribution copy though.
Normalize: Checking this box will normalize the audio. This option is not available if you loaded MP3 or AAC audio.
The settings here are mostly recommended for people who know what they are doing. If you don't understand a setting, then you probably shouldn't mess with it.
Deblocking: These two settings can help to reduce the appearance of blocks in your encode. It is recommended to leave this at the default value. Some people have suggested that values as high as 3 and 3 might be good for anime, though. In general higher values make the video more smoothed and blurry, while lower values make it sharper, but more tendency to block.
Variance AQ: This is the strength of the adaptive quantization, which will compress some parts of the frame more heavily than others. In general this tends to help quality, but sometimes it might look better with a smaller value, or turned off altogether.
Psy-RDO: The RD and trellis options here are additional adaptive quantization settings which I don't recommend using on anime. RD can be helpful in some situations, but the trellis is almost always bad for anime. These options can help preserve noise and grain, so if you video contains a lot of noise then you may want to play with them some. They may also be helpful on live action or CG video.
Sample Aspect Ratio
The sample aspect ratio is different from a pixel aspect ratio or a display aspect ratio. The sample aspect ratio defines a ratio by which your video will be stretched on playback. Because it can be slightly difficult to calculate, you can select a target display aspect ratio from the drop down box, and the appropriate sample aspect ratio will be automatically filled in.
I strongly recommend that you use this feature if your source was 16:9 anamorphic footage. Instead of having to resize your video to a large 16:9 resolution like 848x480, you can instead keep it at the DVD resolution of 720x480, and it will be stretched to the proper aspect ratio on playback. This will result in smaller filesizes, and will allow your video to be played on slightly weaker PCs, to boot.
Threads: This option is for multithreaded PCs. It is recommended to set this value to 1.5 times the number of CPU cores you have. Of course, you could just leave it at 0 and it will automatically detect the correct value.
Interlaced: Check this option if you have interlaced video. When encoding your video for internet distribution, you should NOT have interlaced video, so you should probably never need this option.
Keep Intermediate Files: Behind the scenes, Zarx264gui creates a number of different files during encoding. It first compresses the audio to an m4a (aac) file, then it compresses the video to a .264 file, before finally combining them together into an mp4 container. At the end, these intermediate files are deleted, but if you would like to keep them around for some reason, just check this box.
Only Use Keyframes: x264 could potentially make a good editing codec as an alternative to lagarith, if your editing application lets you load MP4 files natively. In such a case, you would want to make sure that all of the frames are keyframes. I've never actually tried editing like this, so it might not work well. For the most part though, you should never need this option.
For advanced users, this allows you to view the commandline settings that are used to encode your video, and you can also select to save a batch file, so you can modify the settings manually.
Zarxrax - May 2009