Ponymath - optimisation for x264

Ponymath is a script to aid in testing x264 encode settings. It changes a parameter, and draws nice graphs of the result. This alone is something anyone with even basic scripting ability could do, but Ponymath adds some features to aid in the process. Most usefully, it automates the caching of results to use in later tests, potentially saving a great deal of time. This means that, for example, if a graph is first plotted of merange from 16 to 32 and the user then decides that values up to 64 might merit investigation, ponymath will only need to encode videos to find the points from 33 to 64 - those from 16 to 32 will be saved from previous graphs. It also generates the appropriate gnuplot script, saving the need to edit paramaters spread between two files to match.

A varient of the script, ponymath_2d, is made just to study the two paramaters that control the inline deblocking filter. As it produces a two-dimensional result, it's graph is a heat map rather than the more recogniseable plot. It almost always just says that the default values (0,0) are optimal, but sometimes suggests changing them when working on animation or very low bitrate video.

SSIM vs bframes graphSSIM vs frameref graph
SSIM vs merange graphHeat map for SSIM vs deblocking parameters.

The last graph is an example of ponymath_2d output from a low-bitrate (100kbps for 720p video) animation encode: A heat map showing the SSIM vs alpha and beta. It shows that the SSIM could be improved by setting the alpha value slightly negative, perhaps to -1 or -2. The benefit is very small - but it is an increase, and another way to squeeze more quality from precious bits.x264 is not able accept fractional values for these paramaters. I have both attempted this experimentally and asked one of the x264 developers, and both alpha and beta are strictly integer-only.

Ponymath is a pair of perl scripts written for linux, but which should work under windows. It requires you have installed mencoder (with x264 support) and gnuplot.

The name has no special meaning - it was just named such because a My Little Pony episode was used for testing.