Rate control for video encoders can be partitioned into procedures of rate allocation and bit achievement at several
levels. For non-real-time applications, we propose to adopt a two-pass video encoding mechanism, where the framelevel
rate allocation in the second pass is characterized of using content-aware models constructed by using information
collected in the first pass. In our proposed scheme, a video sequence is divided into units of non-overlapping window,
where a two-pass procedure is sequentially applied. The goal of the first pass is to find the encoding modes and motion
vectors (MVs) for each MB and generate the proposed R-λ (rate vs. Lagrangian multiplier) and D-λ (distortion vs.
Lagrangian multiplier) models to represent content characteristics of each frame. In the second pass, the encoding modes
and MVs for MBs found in the first pass are retained, but the QPs are re-assigned MB-by-MB according to bit-rate and
distortion predictions based on the above-constructed models. The performance of the proposed two-pass video encoder
was compared with the H.264 reference model JM8.0. From the results, the proposed method outperforms JM 8.0 in
PSNR by up to 1.38 dB for the test images used. Besides, the proposed algorithm is capable of keeping a controlled bit
rate of much more precision (< 0.017% of error, two orders better than JM8.0), as well as a slightly smoother video
quality, than that obtained by JM 8.0.